mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
WeakMap.prototype.has
This commit is contained in:
parent
7acd163264
commit
0887df4c67
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
@ -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);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
@ -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);
|
||||
});
|
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
@ -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);
|
||||
});
|
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
@ -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);
|
||||
});
|
@ -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);
|
||||
});
|
23
test/built-ins/WeakMap/prototype/has/has.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/has/has.js
vendored
Normal file
@ -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');
|
22
test/built-ins/WeakMap/prototype/has/length.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/has/length.js
vendored
Normal file
@ -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');
|
22
test/built-ins/WeakMap/prototype/has/name.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/has/name.js
vendored
Normal file
@ -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');
|
21
test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
vendored
Normal file
@ -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);
|
25
test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js
vendored
Normal file
25
test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js
vendored
Normal file
@ -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);
|
22
test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js
vendored
Normal file
@ -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);
|
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
vendored
Normal file
@ -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, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js
vendored
Normal file
@ -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, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js
vendored
Normal file
@ -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, {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js
vendored
Normal file
@ -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('', {});
|
||||
});
|
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
vendored
Normal file
@ -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(), {});
|
||||
});
|
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js
vendored
Normal file
20
test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js
vendored
Normal file
@ -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, {});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user