michael@0: // Map methods throw when passed a this-value that isn't a Map. 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 Map_size_getter = Object.getOwnPropertyDescriptor(Map.prototype, "size").get; michael@0: michael@0: function test(obj) { michael@0: testcase(obj, Map.prototype.get, "x"); michael@0: testcase(obj, Map.prototype.has, "x"); michael@0: testcase(obj, Map.prototype.set, "x", 1); michael@0: testcase(obj, Map.prototype.delete, "x"); michael@0: testcase(obj, Map.prototype.clear); michael@0: testcase(obj, Map.prototype.keys); michael@0: testcase(obj, Map.prototype.values); michael@0: testcase(obj, Map.prototype.entries); michael@0: testcase(obj, Map_size_getter); michael@0: } michael@0: michael@0: test(Map.prototype); michael@0: test(Object.create(new Map)); michael@0: test(new Set()); michael@0: test({}); michael@0: test(null); michael@0: test(undefined);