diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js new file mode 100644 index 0000000000000000000000000000000000000000..33dc84e34205bc70701e9d9c4a3ed786a9f233e9 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.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.4 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.has ( value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.has.call([], {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call([], {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js new file mode 100644 index 0000000000000000000000000000000000000000..5fd060eac756e9c1ec011ca4a3e1b245438404eb --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.has ( value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +features: [Map] +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.has.call(new Map(), {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(new Map(), {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js new file mode 100644 index 0000000000000000000000000000000000000000..013b2478702e6eb1de8193e1e2a61eb464ae140e --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.has ( value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.has.call({}, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call({}, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js new file mode 100644 index 0000000000000000000000000000000000000000..1f9bb68aeed5a8e427661a7aec400900b0ba7827 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.has ( value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.has.call(new Set(), {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(new Set(), {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..297b9da18301a85d446d9a6d9548d1aac0291f16 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: > + Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot. +info: > + WeakMap.prototype.has ( value ) + + ... + 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.has.call(WeakMap.prototype, {}, 1); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(WeakMap.prototype, {}, 1); +}); diff --git a/test/built-ins/WeakMap/prototype/has/has.js b/test/built-ins/WeakMap/prototype/has/has.js new file mode 100644 index 0000000000000000000000000000000000000000..9567bb7cf7cbdab7225af657a4c56b825c383d0b --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/has.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.4 +description: > + WeakMap.prototype.has property descriptor +info: > + WeakMap.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof WeakMap.prototype.has, + 'function', + 'typeof WeakMap.prototype.has is "function"' +); + +verifyNotEnumerable(WeakMap.prototype, 'has'); +verifyWritable(WeakMap.prototype, 'has'); +verifyConfigurable(WeakMap.prototype, 'has'); diff --git a/test/built-ins/WeakMap/prototype/has/length.js b/test/built-ins/WeakMap/prototype/has/length.js new file mode 100644 index 0000000000000000000000000000000000000000..17291222b98a0463227c5bcf2f7eba220163cc57 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/length.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.4 +description: > + WeakMap.prototype.has.length value and writability. +info: > + WeakMap.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakMap.prototype.has.length, 1, + 'The value of WeakMap.prototype.has.length is 1' +); + +verifyNotEnumerable(WeakMap.prototype.has, 'length'); +verifyNotWritable(WeakMap.prototype.has, 'length'); +verifyConfigurable(WeakMap.prototype.has, 'length'); diff --git a/test/built-ins/WeakMap/prototype/has/name.js b/test/built-ins/WeakMap/prototype/has/name.js new file mode 100644 index 0000000000000000000000000000000000000000..04c7c0e0fd69199b8d5945909affb855bfab52ee --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/name.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.4 +description: > + WeakMap.prototype.has.name value and writability. +info: > + WeakMap.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakMap.prototype.has.name, 'has', + 'The value of WeakMap.prototype.has.name is "has"' +); + +verifyNotEnumerable(WeakMap.prototype.has, 'name'); +verifyNotWritable(WeakMap.prototype.has, 'name'); +verifyConfigurable(WeakMap.prototype.has, 'name'); diff --git a/test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..e721e1506921eb138eac9538987e9cc4e6a21e64 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.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.4 +description: > + Returns false if value is not an Object. +info: > + WeakMap.prototype.has ( value ) + + 5. If Type(key) is not Object, return false. +features: [Symbol] +---*/ + +var map = new WeakMap(); + +assert.sameValue(map.has(1), false); +assert.sameValue(map.has(''), false); +assert.sameValue(map.has(null), false); +assert.sameValue(map.has(undefined), false); +assert.sameValue(map.has(true), false); +assert.sameValue(map.has(Symbol()), false); diff --git a/test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js new file mode 100644 index 0000000000000000000000000000000000000000..adce12027d2488fe4037c6a38898b2323b1893fa --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js @@ -0,0 +1,25 @@ +// 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.4 +description: > + Return false when value is not present in the WeakMap entries. +info: > + WeakMap.prototype.has ( value ) + + ... + 7. Return false. + +---*/ + +var foo = {}; +var bar = {}; +var map = new WeakMap(); + +assert.sameValue(map.has(foo), false); + +map.set(foo, 1); +assert.sameValue(map.has(bar), false); + +map.delete(foo); +assert.sameValue(map.has(foo), false); diff --git a/test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js b/test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js new file mode 100644 index 0000000000000000000000000000000000000000..07724ea278accd8ba597e5d89f56a6cd0c0ee2f6 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.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.4 +description: > + Returns true when value is present in the WeakMap entries list. +info: > + WeakMap.prototype.has ( 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, return + true. + ... +---*/ + +var foo = {}; +var map = new WeakMap(); + +map.set(foo, 1); +assert.sameValue(map.has(foo), true); diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..6d6f862f02495b3f1157e7f301ab2e5c1112eb68 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.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.4 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + WeakMap.prototype.has.call(false, {}); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(false, {}); +}); diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8f7863016f75e427a4cdf583edadadd7ca91731b --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.has ( 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.has.call(null, {}); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(null, {}); +}); diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js new file mode 100644 index 0000000000000000000000000000000000000000..b6bb5c9830dd8566bcdefdf72e7a1f9cfc4cdd2f --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.has ( 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.has.call(0, {}); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(0, {}); +}); diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js new file mode 100644 index 0000000000000000000000000000000000000000..5b44cdb08d4c25ff28b2e1459524179c77ac4572 --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.has ( 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.has.call('', {}); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call('', {}); +}); diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..1eb3680cbc406923dcbcc1de0a81948ed8d26cae --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.has ( 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.has.call(Symbol(), {}); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(Symbol(), {}); +}); diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..2c8fb4be06ccc3496b9322c28889b6b4bd46cc3c --- /dev/null +++ b/test/built-ins/WeakMap/prototype/has/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.4 +description: Throws TypeError if `this` is not Object. +info: > + WeakMap.prototype.has ( 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.has.call(undefined, {}); +}); + +assert.throws(TypeError, function() { + var map = new WeakMap(); + map.has.call(undefined, {}); +});