michael@0: // Set methods throw when passed a this-value that isn't a Set. michael@0: michael@0: load(libdir + "asserts.js"); michael@0: michael@0: function testcase(obj, fn) { michael@0: assertEq(typeof fn, "function"); michael@0: var args = Array.slice(arguments, 2); michael@0: assertThrowsInstanceOf(function () { fn.apply(obj, args); }, TypeError); michael@0: } michael@0: michael@0: var Set_size_getter = Object.getOwnPropertyDescriptor(Set.prototype, "size").get; michael@0: michael@0: function test(obj) { michael@0: testcase(obj, Set.prototype.has, 12); michael@0: testcase(obj, Set.prototype.add, 12); michael@0: testcase(obj, Set.prototype.delete, 12); michael@0: testcase(obj, Set.prototype.clear); michael@0: testcase(obj, Set.prototype.keys); michael@0: testcase(obj, Set.prototype.values); michael@0: testcase(obj, Set.prototype.entries); michael@0: testcase(obj, Set_size_getter); michael@0: } michael@0: michael@0: test(Set.prototype); michael@0: test(Object.create(new Set)); michael@0: test(new Map()); michael@0: test({}); michael@0: test(null); michael@0: test(undefined);