diff --git a/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js b/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 0000000000000000000000000000000000000000..8463ed436a394b28bdd0f320889e92e2a2e22be2 --- /dev/null +++ b/test/built-ins/Map/prototype/has/does-not-have-mapdata-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.1.3.7 +description: > + Throws a TypeError if `this` is a Set object. +info: > + Map.prototype.has ( key ) + + ... + 3. If M does not have a [[MapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + Map.prototype.has.call(new Set(), 1); +}); + +assert.throws(TypeError, function() { + var m = new Map(); + m.has.call(new Set(), 1); +}); diff --git a/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js b/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 0000000000000000000000000000000000000000..a095316c349e4df2a0cdeeb6fb2b58935d4a9968 --- /dev/null +++ b/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.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.1.3.7 +description: > + Throws a TypeError if `this` is a WeakMap object. +info: > + Map.prototype.has ( key ) + + ... + 3. If M does not have a [[MapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakMap] +---*/ + +assert.throws(TypeError, function() { + Map.prototype.has.call(new WeakMap(), 1); +}); + +assert.throws(TypeError, function() { + var m = new Map(); + m.has.call(new WeakMap(), 1); +}); diff --git a/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot.js b/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot.js new file mode 100644 index 0000000000000000000000000000000000000000..0a43e5b92034e94f5b4c36e7d090ccf62bf32c25 --- /dev/null +++ b/test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,32 @@ +// 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.1.3.7 +description: > + Throws a TypeError if `this` object does not have a [[MapData]] internal slot. +info: > + Map.prototype.has ( key ) + + ... + 3. If M does not have a [[MapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var m = new Map(); + +assert.throws(TypeError, function() { + Map.prototype.has.call([], 1); +}); + +assert.throws(TypeError, function() { + m.has.call([], 1); +}); + +assert.throws(TypeError, function() { + Map.prototype.has.call({}, 1); +}); + +assert.throws(TypeError, function() { + m.has.call({}, 1); +}); diff --git a/test/built-ins/Map/prototype/has/has.js b/test/built-ins/Map/prototype/has/has.js new file mode 100644 index 0000000000000000000000000000000000000000..1785c6731dbc427a19434acb9b160f8e27ac71e8 --- /dev/null +++ b/test/built-ins/Map/prototype/has/has.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.1.3.7 +description: > + Property type and descriptor. +info: > + Map.prototype.has ( key ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Map.prototype.has, + 'function', + '`typeof Map.prototype.has` is `function`' +); + +verifyNotEnumerable(Map.prototype, 'has'); +verifyWritable(Map.prototype, 'has'); +verifyConfigurable(Map.prototype, 'has'); diff --git a/test/built-ins/Map/prototype/has/length.js b/test/built-ins/Map/prototype/has/length.js new file mode 100644 index 0000000000000000000000000000000000000000..7ad1d6d286b56cd2f164ad4fab284b7ddf323b4f --- /dev/null +++ b/test/built-ins/Map/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.1.3.7 +description: > + Map.prototype.has.length value and descriptor. +info: > + Map.prototype.has ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Map.prototype.has.length, 1, + 'The value of `Map.prototype.has.length` is `1`' +); + +verifyNotEnumerable(Map.prototype.has, 'length'); +verifyNotWritable(Map.prototype.has, 'length'); +verifyConfigurable(Map.prototype.has, 'length'); diff --git a/test/built-ins/Map/prototype/has/name.js b/test/built-ins/Map/prototype/has/name.js new file mode 100644 index 0000000000000000000000000000000000000000..cf6b6f912326a83e6382a68164b86ab53c0e61ef --- /dev/null +++ b/test/built-ins/Map/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.1.3.7 +description: > + Map.prototype.has.name value and descriptor. +info: > + Map.prototype.has ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Map.prototype.has.name, 'has', + 'The value of `Map.prototype.has.name` is `"has"`' +); + +verifyNotEnumerable(Map.prototype.has, 'name'); +verifyNotWritable(Map.prototype.has, 'name'); +verifyConfigurable(Map.prototype.has, 'name'); diff --git a/test/built-ins/Map/prototype/has/normalizes-zero-key.js b/test/built-ins/Map/prototype/has/normalizes-zero-key.js new file mode 100644 index 0000000000000000000000000000000000000000..c8a31e1d3a9ba51c0fcadcd32fa08afdbc85573b --- /dev/null +++ b/test/built-ins/Map/prototype/has/normalizes-zero-key.js @@ -0,0 +1,30 @@ +// 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.1.3.7 +description: > + -0 and +0 are normalized to +0; +info: > + Map.prototype.has ( key ) + + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return true. + ... +---*/ + +var map = new Map(); + +assert.sameValue(map.has(-0), false); +assert.sameValue(map.has(+0), false); + +map.set(-0, 42); +assert.sameValue(map.has(-0), true); +assert.sameValue(map.has(+0), true); + +map.clear(); + +map.set(+0, 42); +assert.sameValue(map.has(-0), true); +assert.sameValue(map.has(+0), true); diff --git a/test/built-ins/Map/prototype/has/return-false-different-key-types.js b/test/built-ins/Map/prototype/has/return-false-different-key-types.js new file mode 100644 index 0000000000000000000000000000000000000000..4567fb119da9c8661a4d793c8570d78960f05166 --- /dev/null +++ b/test/built-ins/Map/prototype/has/return-false-different-key-types.js @@ -0,0 +1,29 @@ +// 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.1.3.7 +description: > + Returns true for existing keys, using different key types. +info: > + Map.prototype.has ( key ) + + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + i. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return true. + ... +features: [Symbol] +---*/ + +var map = new Map(); + +assert.sameValue(map.has('str'), false); +assert.sameValue(map.has(1), false); +assert.sameValue(map.has(NaN), false); +assert.sameValue(map.has(true), false); +assert.sameValue(map.has(false), false); +assert.sameValue(map.has({}), false); +assert.sameValue(map.has([]), false); +assert.sameValue(map.has(Symbol()), false); +assert.sameValue(map.has(null), false); +assert.sameValue(map.has(undefined), false); diff --git a/test/built-ins/Map/prototype/has/return-true-different-key-types.js b/test/built-ins/Map/prototype/has/return-true-different-key-types.js new file mode 100644 index 0000000000000000000000000000000000000000..21fdb2f723069d789ad995766615b48109536e84 --- /dev/null +++ b/test/built-ins/Map/prototype/has/return-true-different-key-types.js @@ -0,0 +1,44 @@ +// 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.1.3.7 +description: > + Returns true for existing keys, using different key types. +info: > + Map.prototype.has ( key ) + + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + i. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return true. + ... +features: [Symbol] +---*/ + +var map = new Map(); + +var obj = {}; +var arr = []; +var symb = Symbol(); + +map.set('str', undefined); +map.set(1, undefined); +map.set(NaN, undefined); +map.set(true, undefined); +map.set(false, undefined); +map.set(obj, undefined); +map.set(arr, undefined); +map.set(symb, undefined); +map.set(null, undefined); +map.set(undefined, undefined); + +assert.sameValue(map.has('str'), true); +assert.sameValue(map.has(1), true); +assert.sameValue(map.has(NaN), true); +assert.sameValue(map.has(true), true); +assert.sameValue(map.has(false), true); +assert.sameValue(map.has(obj), true); +assert.sameValue(map.has(arr), true); +assert.sameValue(map.has(symb), true); +assert.sameValue(map.has(null), true); +assert.sameValue(map.has(undefined), true); diff --git a/test/built-ins/Map/prototype/has/this-not-object-throw.js b/test/built-ins/Map/prototype/has/this-not-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4664fed22f386638775c1ff902b7e86068d81e1f --- /dev/null +++ b/test/built-ins/Map/prototype/has/this-not-object-throw.js @@ -0,0 +1,43 @@ +// 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.1.3.7 +description: > + Throws a TypeError if `this` is not an Object. +info: > + Map.prototype.has ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Map.prototype.has.call(false, 1); +}); + +assert.throws(TypeError, function() { + Map.prototype.has.call(1, 1); +}); + +assert.throws(TypeError, function() { + Map.prototype.has.call('', 1); +}); + +assert.throws(TypeError, function() { + Map.prototype.has.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + Map.prototype.has.call(null, 1); +}); + +assert.throws(TypeError, function() { + Map.prototype.has.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var map = new Map(); + map.has.call(false, 1); +});