Debian Codegraph @

js/src/jit-test/tests/collections/Set-surfaces-2.js

raw
1 // Set methods throw when passed a this-value that isn't a Set.
2
3 load(libdir + "asserts.js");
4
5 function testcase(obj, fn, ...args) {
6 assertEq(typeof fn, "function");
7 assertThrowsInstanceOf(function () { fn.apply(obj, args); }, TypeError);
8 }
9
10 var Set_size_getter = Object.getOwnPropertyDescriptor(Set.prototype, "size").get;
11
12 function test(obj) {
13 testcase(obj, Set.prototype.has, 12);
14 testcase(obj, Set.prototype.add, 12);
15 testcase(obj, Set.prototype.delete, 12);
16 testcase(obj, Set.prototype.clear);
17 testcase(obj, Set.prototype.keys);
18 testcase(obj, Set.prototype.values);
19 testcase(obj, Set.prototype.entries);
20 testcase(obj, Set_size_getter);
21 }
22
23 test(Set.prototype);
24 test(Object.create(new Set));
25 test(new Map());
26 test({});
27 test(null);
28 test(undefined);