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