]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/set-constructor.js
1 // Set constructor behaviors.
3 if (typeof Set
!== 'function')
4 throw "Error: bad value" + typeof Set
;
6 function testCallTypeError(item
) {
14 throw "Error: error not thrown";
15 if (String(error
) !== "TypeError: Set cannot be called as a function")
16 throw "Error: bad error " + String(error
);
23 [ [0, 1, 2, 3, 4], 5 ],
24 [ [0, 0, 0, 1, 0], 2 ],
25 [ ["A", "B", "A"], 2 ],
26 [ new String("cocoa"), 3 ],
27 [ new String("Cocoa"), 4 ],
28 [ new Set([0,1,2,3,4]), 5],
29 [ new Set([1,1,1,1]), 1],
30 [ new Map([[1, 2],[1, 2]]), 1],
31 [ new Map([[1, 2],[2, 2]]), 2],
34 for (var pair
of pass
) {
35 var set = new Set(pair
[0]);
36 if (set.size
!== pair
[1])
37 throw "Error: bad set size " + set.size
;
38 testCallTypeError(pair
[0]);
41 function testTypeError(item
) {
44 var set = new Set(item
);
49 throw "Error: error not thrown";
50 if (String(error
) !== "TypeError: Type error")
51 throw "Error: bad error " + String(error
);
62 Object(Symbol("Matcha")),
66 for (var item
of nonIterable
) {
68 testCallTypeError(item
);