]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/weak-map-constructor.js
3f26053091fee1007dd381999807f4037ab95d8f
1 // WeakMap constructor behaviors.
3 if (typeof WeakMap
!== 'function')
4 throw "Error: bad value" + typeof WeakMap
;
6 function testCallTypeError(item
) {
9 var map
= WeakMap(item
);
14 throw "Error: error not thrown";
15 if (String(error
) !== "TypeError: WeakMap cannot be called as a function")
16 throw "Error: bad error " + String(error
);
20 var obj3
= new Date();
21 var obj4
= new Error();
68 for (var value
of pass
) {
69 var map
= new WeakMap(value
);
70 testCallTypeError(value
);
73 function testTypeError(item
, message
) {
76 var map
= new WeakMap(item
);
81 throw "Error: error not thrown";
83 message
= "TypeError: Type error";
84 if (String(error
) !== message
)
85 throw "Error: bad error " + String(error
);
96 Object(Symbol("Matcha")),
100 for (var item
of nonIterable
) {
102 testCallTypeError(item
);
105 var notContainNextItem
= [
112 new Set([0,1,2,3,4]),
116 for (var item
of notContainNextItem
) {
118 testCallTypeError(item
);
121 var nonObjectKeys
= [
141 for (var item
of nonObjectKeys
) {
142 testTypeError(item
, 'TypeError: Attempted to set a non-object key in a WeakMap');
143 testCallTypeError(item
);