summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Object/duplProps.js
blob: 41b8d67fb0130444808304df7fe03d0a18832224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * ES6 allows duplicate property names in object literals, even in strict mode.
 * These tests modify the tests in test262 to reflect this change.
 */

// test262/ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js
a = function() { "use strict"; return { foo: 0, foo : 1 }};
assertEq(a().foo, 1);
a = function() { return { foo: 0, foo : 1 }};
assertEq(a().foo, 1);

// test262/ch11/11.1/11.1.5/11.1.5_4-4-b-1.js
a = function() { "use strict"; return { foo : 1, get foo() { return 2; }}};
assertEq(a().foo, 2);
a = function() { return { foo : 1, get foo() { return 2;} }};
assertEq(a().foo, 2);

// test262/ch11/11.1/11.1.5/11.1.5_4-4-c-1.js
a = function() { "use strict"; return { get foo() { return 2; }, foo : 1 }};
assertEq(a().foo, 1);
a = function() { return { get foo() { return 2; }, foo : 1 }};
assertEq(a().foo, 1);

// test262/ch11/11.1/11.1.5/11.1.5_4-4-b-2.js
a = function() { "use strict"; return { foo : 1, set foo(a) { throw 2; }}};
try {
    a().foo = 5;
    throw new Error("2 should be thrown here");
} catch (e) {
    if (e !== 2)
        throw new Error("2 should be thrown here");
}
a = function() { return { foo : 1, set foo(a) { throw 2;} }};
try {
    a().foo = 5;
    throw new Error("2 should be thrown here");
} catch (e) {
    if (e !== 2)
        throw new Error("2 should be thrown here");
}

// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-1.js
a = function() { "use strict"; return { get foo() { return 2; }, get foo() { return 3; } }};
assertEq(a().foo, 3);
a = function() { return { get foo() { return 2; }, get foo() { return 3; } }};
assertEq(a().foo, 3);

// test262/ch11/11.1/11.1.5/11.1.5_4-4-c-2.js
a = function() { "use strict"; return { set foo(a) { throw 2; }, foo : 1 }};
assertEq(a().foo, 1);
a = function() { return { set foo(a) { throw 2; }, foo : 1 }};
assertEq(a().foo, 1);

// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-2.js
a = function() { "use strict"; return { set foo(a) { throw 2; }, set foo(a) { throw 3; }}};
try {
    a().foo = 5;
    throw new Error("3 should be thrown here");
} catch (e) {
    if (e !== 3)
        throw new Error("3 should be thrown here");
}
a = function() { return { set foo(a) { throw 2; }, set foo(a) { throw 3; }}};
try {
    a().foo = 5;
    throw new Error("3 should be thrown here");
} catch (e) {
    if (e !== 3)
        throw new Error("3 should be thrown here");
}

// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-3.js
a = function() { "use strict"; return { get foo() { return 2; }, set foo(a) { throw 3; },
            get foo() { return 4; }}};
try {
    assertEq(a().foo, 4);
    a().foo = 5;
    throw new Error("3 should be thrown here");
} catch (e) {
    if (e !== 3)
        throw new Error("3 should be thrown here");
}
a = function() { return { get foo() { return 2; }, set foo(a) { throw 3; },
            get foo() { return 4; }}};
try {
    assertEq(a().foo, 4);
    a().foo = 5;
    throw new Error("3 should be thrown here");
} catch (e) {
    if (e !== 3)
        throw new Error("3 should be thrown here");
}

// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-4.js
a = function() { "use strict"; return { set foo(a) { throw 2; }, get foo() { return 4; },
            set foo(a) { throw 3; }}};
try {
    assertEq(a().foo, 4);
    a().foo = 5;
    throw new Error("3 should be thrown here");
} catch (e) {
    if (e !== 3)
        throw new Error("3 should be thrown here");
}
a = function() { return { set foo(a) { throw 2; }, get foo() { return 4; },
            set foo(a) { throw 3; }}};
try {
    assertEq(a().foo, 4);
    a().foo = 5;
    throw new Error("3 should be thrown here");
} catch (e) {
    if (e !== 3)
        throw new Error("3 should be thrown here");
}

reportCompare(0, 0);