WeakMap.prototype.has

This commit is contained in:
Leonardo Balter 2015-07-01 15:03:48 -04:00
parent 7acd163264
commit 0887df4c67
17 changed files with 374 additions and 0 deletions

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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(WeakMap.prototype, {}, 1);
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.has.call(WeakMap.prototype, {}, 1);
});

View 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');

View 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');

View 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');

View 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);

View 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);

View 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);

View 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, {});
});

View 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, {});
});

View 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, {});
});

View 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('', {});
});

View 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(), {});
});

View 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, {});
});