diff --git a/test/built-ins/WeakMap/prototype/set/adds-element.js b/test/built-ins/WeakMap/prototype/set/adds-element.js new file mode 100644 index 0000000000000000000000000000000000000000..0b0d86f63e4d20ddc9d2576fa515cf87dc8e6871 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/adds-element.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: > + Appends value as the last element of entries. +info: > + WeakMap.prototype.set ( key, value ) + + ... + 7. Let p be the Record {[[key]]: key, [[value]]: value}. + 8. Append p as the last element of entries. + ... +---*/ + +var map = new WeakMap(); +var foo = {}; +var bar = {}; +var baz = {}; + +map.set(foo, 1); +map.set(bar, 2); +map.set(baz, 3); + +assert(map.has(foo)); +assert(map.has(bar)); +assert(map.has(baz)); diff --git a/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js new file mode 100644 index 0000000000000000000000000000000000000000..b98e11d2fda6fd2fa07f9476d88c2b6677350260 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.set ( key, value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call([], {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call([], {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js new file mode 100644 index 0000000000000000000000000000000000000000..b17dbc7f63e749ee9ab27283630b3429bd4c4ed0 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.set ( key, value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +features: [Map] +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(new Map(), {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(new Map(), {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js new file mode 100644 index 0000000000000000000000000000000000000000..5adc57bc5946acf2ab9d5cd881478efb8cfda294 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.set ( key, value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call({}, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call({}, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js new file mode 100644 index 0000000000000000000000000000000000000000..0ef36a59371abb605399a37eaa0bc37e1d86ce30 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.set ( key, value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(new Set(), {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(new Set(), {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..59d4308dde8b85072751146d3f48ad6cddfcbc74 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.set ( key, value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(WeakMap.prototype, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(WeakMap.prototype, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/key-not-object-throw.js b/test/built-ins/WeakMap/prototype/set/key-not-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4b4031d1c58433f6d80bebfccd506e2f0a74da75 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/key-not-object-throw.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `key` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 5. If Type(key) is not Object, throw a TypeError exception. +features: [Symbol] +---*/ + +var s = new WeakMap(); + +assert.throws(TypeError, function() { + s.set(1, 1); +}); + +assert.throws(TypeError, function() { + s.set(false, 1); +}); + +assert.throws(TypeError, function() { + s.set(undefined, 1); +}); + +assert.throws(TypeError, function() { + s.set('string', 1); +}); + +assert.throws(TypeError, function() { + s.set(null, 1); +}); + +assert.throws(TypeError, function() { + s.set(Symbol(), 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/length.js b/test/built-ins/WeakMap/prototype/set/length.js new file mode 100644 index 0000000000000000000000000000000000000000..0d687e51f21fda4ac3428a24cd14b571331d6644 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/length.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: WeakMap.prototype.set.length descriptor +info: > + WeakMap.prototype.set ( key, value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakMap.prototype.set.length, 2, + 'The value of `WeakMap.prototype.set.length` is `2`' +); + +verifyNotEnumerable(WeakMap.prototype.set, 'length'); +verifyNotWritable(WeakMap.prototype.set, 'length'); +verifyConfigurable(WeakMap.prototype.set, 'length'); diff --git a/test/built-ins/WeakMap/prototype/set/name.js b/test/built-ins/WeakMap/prototype/set/name.js new file mode 100644 index 0000000000000000000000000000000000000000..9c4f63080fe4ccd8d6974908702d1a47573992bf --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: WeakMap.prototype.set.name descriptor +info: > + WeakMap.prototype.set ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakMap.prototype.set.name, 'set', + 'The value of WeakMap.prototype.set.name is "set"' +); + +verifyNotEnumerable(WeakMap.prototype.set, 'name'); +verifyNotWritable(WeakMap.prototype.set, 'name'); +verifyConfigurable(WeakMap.prototype.set, 'name'); diff --git a/test/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js b/test/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js new file mode 100644 index 0000000000000000000000000000000000000000..b7221250469dd1a3178c2fca14cd2977969a24a4 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Returns `this` when new value is duplicate. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + ... + 6. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, then + i. Set p.[[value]] to value. + ii. Return M. + ... +---*/ + +var foo = {}; +var map = new WeakMap([[foo, 1]]); + +assert.sameValue(map.set(foo, 1), map, '`map.set(foo, 1)` returns `map`'); diff --git a/test/built-ins/WeakMap/prototype/set/returns-this.js b/test/built-ins/WeakMap/prototype/set/returns-this.js new file mode 100644 index 0000000000000000000000000000000000000000..d92c5fc801973e92ea9d5b76ccf8315f54f62a73 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/returns-this.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Returns `this` after setting a new value. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be this value. + ... + 9. Return M. + +---*/ + +var map = new WeakMap(); + +assert.sameValue(map.set({}, 1), map, '`map.set({}, 1)` returns `map`'); diff --git a/test/built-ins/WeakMap/prototype/set/set.js b/test/built-ins/WeakMap/prototype/set/set.js new file mode 100644 index 0000000000000000000000000000000000000000..173b3e0ebf122f36291dc7ad2eeb9a3f70a9cc97 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/set.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: WeakMap.prototype.set property descriptor +info: > + WeakMap.prototype.set ( key, value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof WeakMap.prototype.set, + 'function', + 'typeof WeakMap.prototype.set is "function"' +); + +verifyNotEnumerable(WeakMap.prototype, 'set'); +verifyWritable(WeakMap.prototype, 'set'); +verifyConfigurable(WeakMap.prototype, 'set'); diff --git a/test/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..e36b6201e7e577f075486027e0078786fab53fe3 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(false, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(false, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js new file mode 100644 index 0000000000000000000000000000000000000000..dba5205606adf3df32d4ce8925559b4980d00d9a --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(null, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(null, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js new file mode 100644 index 0000000000000000000000000000000000000000..e4745ca50e50b3367cbacc425c67e34ace8618e6 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(0, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(0, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js new file mode 100644 index 0000000000000000000000000000000000000000..8764b24258ac6c9537809f440d9c1c1195ccea11 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call('', {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call('', {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..c7f1cfe453808cd90da21bb80befd148bb79006f --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(Symbol(), {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(Symbol(), {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..4c8d0fdfff9cbbb6fe59f0d7260fd29de3028c98 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.3.5 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.set ( key, value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.set.call(undefined, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.set.call(undefined, {}, 1); +});