WeakMap.prototype.delete

This commit is contained in:
Leonardo Balter 2015-07-01 12:15:00 -04:00
parent 806beb5ae3
commit e44e0c1762
18 changed files with 408 additions and 0 deletions

View File

@ -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.3.3.2
description: >
Delete an entry from initial iterable.
info: >
WeakMap.prototype.delete ( value )
...
5. Let entries be the List that is the value of Ms [[WeakMapData]] internal
slot.
6. If Type(key) is not Object, return false.
7. 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, then
i. Set p.[[key]] to empty.
ii. Set p.[[value]] to empty.
iii. Return true.
...
---*/
var foo = {};
var map = new WeakMap([[foo, 42]]);
var result = map.delete(foo);
assert.sameValue(map.has(foo), false);
assert.sameValue(result, true, 'WeakMap#delete returns true');

View File

@ -0,0 +1,31 @@
// 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.2
description: >
Delete an entry.
info: >
WeakMap.prototype.delete ( value )
...
5. Let entries be the List that is the value of Ms [[WeakMapData]] internal
slot.
6. If Type(key) is not Object, return false.
7. 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, then
i. Set p.[[key]] to empty.
ii. Set p.[[value]] to empty.
iii. Return true.
...
---*/
var foo = {};
var map = new WeakMap();
map.set(foo, 42);
var result = map.delete(foo);
assert.sameValue(map.has(foo), false);
assert.sameValue(result, true, 'WeakMap#delete returns true');

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.2
description: >
WeakMap.prototype.delete property descriptor
info: >
WeakMap.prototype.delete ( value )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
assert.sameValue(
typeof WeakMap.prototype.delete,
'function',
'typeof WeakMap.prototype.delete is "function"'
);
verifyNotEnumerable(WeakMap.prototype, 'delete');
verifyWritable(WeakMap.prototype, 'delete');
verifyConfigurable(WeakMap.prototype, 'delete');

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.2
description: >
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
info: >
WeakMap.prototype.delete ( value )
...
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
exception.
...
---*/
assert.throws(TypeError, function() {
WeakMap.prototype.delete.call([], {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.call([], {});
});

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.2
description: >
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
info: >
WeakMap.prototype.delete ( value )
...
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
exception.
...
features: [Map]
---*/
assert.throws(TypeError, function() {
WeakMap.prototype.delete.call(new Map(), {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.call(new Map(), {});
});

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.2
description: >
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
info: >
WeakMap.prototype.delete ( value )
...
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
exception.
...
---*/
assert.throws(TypeError, function() {
WeakMap.prototype.delete.call({}, {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.call({}, {});
});

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.2
description: >
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
info: >
WeakMap.prototype.delete ( value )
...
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
exception.
...
features: [Set]
---*/
assert.throws(TypeError, function() {
WeakMap.prototype.delete.call(new Set(), {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.call(new Set(), {});
});

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.2
description: >
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
info: >
WeakMap.prototype.delete ( value )
...
3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
exception.
...
---*/
assert.throws(TypeError, function() {
WeakMap.prototype.delete.call(WeakMap.prototype, {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.call(WeakMap.prototype, {});
});

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.2
description: >
WeakMap.prototype.delete.length value and writability.
info: >
WeakMap.prototype.delete ( value )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
assert.sameValue(
WeakMap.prototype.delete.length, 1,
'The value of WeakMap.prototype.delete.length is 1'
);
verifyNotEnumerable(WeakMap.prototype.delete, 'length');
verifyNotWritable(WeakMap.prototype.delete, 'length');
verifyConfigurable(WeakMap.prototype.delete, '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.2
description: >
WeakMap.prototype.delete.name value and writability.
info: >
WeakMap.prototype.delete ( value )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
assert.sameValue(
WeakMap.prototype.delete.name, 'delete',
'The value of WeakMap.prototype.delete.name is "delete"'
);
verifyNotEnumerable(WeakMap.prototype.delete, 'name');
verifyNotWritable(WeakMap.prototype.delete, 'name');
verifyConfigurable(WeakMap.prototype.delete, 'name');

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.2
description: >
Return false if value is not an Object.
info: >
WeakMap.prototype.delete ( value )
5. If Type(key) is not Object, return false.
features: [Symbol]
---*/
var map = new WeakMap();
assert.sameValue(map.delete(1), false);
assert.sameValue(map.delete(''), false);
assert.sameValue(map.delete(NaN), false);
assert.sameValue(map.delete(null), false);
assert.sameValue(map.delete(undefined), false);
assert.sameValue(map.delete(true), false);
assert.sameValue(map.delete(Symbol()), false);

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.2
description: >
Return false if entry is not in the WeakMap.
info: >
WeakMap.prototype.delete ( value )
...
7. Return false.
---*/
var map = new WeakMap();
var foo = {};
var bar = {};
map.set(foo, 42);
assert.sameValue(map.delete(bar), 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.2
description: Throws TypeError if `this` is not Object.
info: >
WeakMap.prototype.delete ( 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.delete.call(false, {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.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.2
description: Throws TypeError if `this` is not Object.
info: >
WeakMap.prototype.delete ( 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.delete.call(null, {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.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.2
description: Throws TypeError if `this` is not Object.
info: >
WeakMap.prototype.delete ( 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.delete.call(0, {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.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.2
description: Throws TypeError if `this` is not Object.
info: >
WeakMap.prototype.delete ( 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.delete.call('', {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.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.2
description: Throws TypeError if `this` is not Object.
info: >
WeakMap.prototype.delete ( 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.delete.call(Symbol(), {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.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.2
description: Throws TypeError if `this` is not Object.
info: >
WeakMap.prototype.delete ( 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.delete.call(undefined, {});
});
assert.throws(TypeError, function() {
var map = new WeakMap();
map.delete.call(undefined, {});
});