diff options
author | Leonardo Balter <leonardo.balter@gmail.com> | 2015-06-29 16:17:07 -0400 |
---|---|---|
committer | Leonardo Balter <leonardo.balter@gmail.com> | 2015-07-07 12:03:53 -0400 |
commit | dc55c21084c22718d10dec6a1c884812e59d14e1 (patch) | |
tree | c34ef83ae789f7f6c9fdc7c9df13bbe0d7abc171 /test/built-ins/Map | |
parent | b103418a17a09d978800495be52b1a8a483c24f1 (diff) | |
download | qtdeclarative-testsuites-dc55c21084c22718d10dec6a1c884812e59d14e1.tar.gz |
Map.prototype.has
Diffstat (limited to 'test/built-ins/Map')
10 files changed, 292 insertions, 0 deletions
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 000000000..8463ed436 --- /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 000000000..a095316c3 --- /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 000000000..0a43e5b92 --- /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 000000000..1785c6731 --- /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 000000000..7ad1d6d28 --- /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 000000000..cf6b6f912 --- /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 000000000..c8a31e1d3 --- /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 000000000..4567fb119 --- /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 000000000..21fdb2f72 --- /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 000000000..4664fed22 --- /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); +}); |