Debian Codegraph @

js/src/jit-test/tests/collections/WeakSet-error.js

raw
1 load(libdir + "asserts.js");
2 load(libdir + "iteration.js");
3
4 function testMethod(name) {
5 var method = WeakSet.prototype[name];
6
7 assertThrowsInstanceOf(function() { method.call(1); }, TypeError);
8 assertThrowsInstanceOf(function() { method.call({}); }, TypeError);
9 assertThrowsInstanceOf(function() { method.call(new WeakMap); }, TypeError);
10 assertThrowsInstanceOf(function() { method.call(WeakSet.prototype); }, TypeError);
11 }
12
13 testMethod("has");
14 testMethod("add");
15 testMethod("delete");
16 testMethod("clear");
17
18 assertThrowsInstanceOf(function() { var ws = new WeakSet(); ws.add(1); }, TypeError);
19 assertThrowsInstanceOf(function() { new WeakSet({[Symbol.iterator]: 2}) }, TypeError);
20 assertEq(typeof [][Symbol.iterator], "function");
21
22 assertThrowsInstanceOf(function() { WeakSet(); }, TypeError);