mirror of https://github.com/tc39/test262.git
WeakMap.prototype.delete
This commit is contained in:
parent
806beb5ae3
commit
e44e0c1762
|
@ -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 M’s [[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');
|
|
@ -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 M’s [[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');
|
|
@ -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');
|
23
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-array.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/delete/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.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([], {});
|
||||||
|
});
|
24
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-map.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/delete/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.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(), {});
|
||||||
|
});
|
23
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-object.js
vendored
Normal file
23
test/built-ins/WeakMap/prototype/delete/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.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({}, {});
|
||||||
|
});
|
24
test/built-ins/WeakMap/prototype/delete/does-not-have-weakmapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/WeakMap/prototype/delete/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.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(), {});
|
||||||
|
});
|
|
@ -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, {});
|
||||||
|
});
|
|
@ -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');
|
|
@ -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');
|
22
test/built-ins/WeakMap/prototype/delete/returns-false-value-is-not-object.js
vendored
Normal file
22
test/built-ins/WeakMap/prototype/delete/returns-false-value-is-not-object.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.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);
|
21
test/built-ins/WeakMap/prototype/delete/returns-false-when-delete-is-noop.js
vendored
Normal file
21
test/built-ins/WeakMap/prototype/delete/returns-false-when-delete-is-noop.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.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);
|
|
@ -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, {});
|
||||||
|
});
|
|
@ -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, {});
|
||||||
|
});
|
|
@ -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, {});
|
||||||
|
});
|
|
@ -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('', {});
|
||||||
|
});
|
|
@ -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(), {});
|
||||||
|
});
|
|
@ -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, {});
|
||||||
|
});
|
Loading…
Reference in New Issue