mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 23:44:27 +02:00
Map.prototype.delete
This commit is contained in:
parent
66c08508ae
commit
e345635a75
23
test/built-ins/Map/prototype/delete/context-is-not-map-object.js
vendored
Normal file
23
test/built-ins/Map/prototype/delete/context-is-not-map-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.1.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call({}, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call([], 'attr');
|
||||||
|
});
|
38
test/built-ins/Map/prototype/delete/context-is-not-object.js
vendored
Normal file
38
test/built-ins/Map/prototype/delete/context-is-not-object.js
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( 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.delete.call(1, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(true, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call('', 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(null, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(undefined, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(Symbol(), 'attr');
|
||||||
|
});
|
20
test/built-ins/Map/prototype/delete/context-is-set-object-throws.js
vendored
Normal file
20
test/built-ins/Map/prototype/delete/context-is-set-object-throws.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.1.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(new Set(), 'attr');
|
||||||
|
});
|
20
test/built-ins/Map/prototype/delete/context-is-weakmap-object-throws.js
vendored
Normal file
20
test/built-ins/Map/prototype/delete/context-is-weakmap-object-throws.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.1.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(new WeakMap(), 'attr');
|
||||||
|
});
|
21
test/built-ins/Map/prototype/delete/delete.js
vendored
Normal file
21
test/built-ins/Map/prototype/delete/delete.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.1.3.3
|
||||||
|
description: >
|
||||||
|
Map.prototype.delete ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.delete,
|
||||||
|
'function',
|
||||||
|
'typeof Map.prototype.delete is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'delete');
|
||||||
|
verifyWritable(Map.prototype, 'delete');
|
||||||
|
verifyConfigurable(Map.prototype, 'delete');
|
32
test/built-ins/Map/prototype/delete/does-not-break-iterators.js
vendored
Normal file
32
test/built-ins/Map/prototype/delete/does-not-break-iterators.js
vendored
Normal file
@ -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.3
|
||||||
|
description: >
|
||||||
|
Deleting an entry does not break a [[MapData]] List.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
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, then
|
||||||
|
i. Set p.[[key]] to empty.
|
||||||
|
ii. Set p.[[value]] to empty.
|
||||||
|
iii. Return true.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([['a',1], ['b', 2], ['c', 3]]);
|
||||||
|
var e = m.entries();
|
||||||
|
|
||||||
|
e.next();
|
||||||
|
m.delete('b');
|
||||||
|
|
||||||
|
var n = e.next();
|
||||||
|
|
||||||
|
assert.sameValue(n.value[0], 'c');
|
||||||
|
assert.sameValue(n.value[1], 3);
|
||||||
|
|
||||||
|
n = e.next();
|
||||||
|
assert.sameValue(n.value, undefined);
|
||||||
|
assert.sameValue(n.done, true);
|
22
test/built-ins/Map/prototype/delete/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/delete/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.1.3.3
|
||||||
|
description: >
|
||||||
|
Map.prototype.delete.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.delete.length, 1,
|
||||||
|
'The value of `Map.prototype.delete.length` is `1`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.delete, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.delete, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.delete, 'length');
|
22
test/built-ins/Map/prototype/delete/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/delete/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.1.3.3
|
||||||
|
description: >
|
||||||
|
Map.prototype.delete.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.delete.name, 'delete',
|
||||||
|
'The value of `Map.prototype.delete.name` is `"delete"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.delete, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.delete, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.delete, 'name');
|
23
test/built-ins/Map/prototype/delete/returns-false.js
vendored
Normal file
23
test/built-ins/Map/prototype/delete/returns-false.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.1.3.3
|
||||||
|
description: >
|
||||||
|
Returns false when it does not delete an entry.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
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, then
|
||||||
|
...
|
||||||
|
iii. Return true.
|
||||||
|
6. Return false.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([['a',1], ['b', 2]]);
|
||||||
|
|
||||||
|
assert.sameValue(m.delete('not-in-the-map'), false);
|
||||||
|
|
||||||
|
m.delete('a');
|
||||||
|
assert.sameValue(m.delete('a'), false);
|
24
test/built-ins/Map/prototype/delete/returns-true-for-deleted-entry.js
vendored
Normal file
24
test/built-ins/Map/prototype/delete/returns-true-for-deleted-entry.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.1.3.3
|
||||||
|
description: >
|
||||||
|
Returns true when deletes an entry.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
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, then
|
||||||
|
i. Set p.[[key]] to empty.
|
||||||
|
ii. Set p.[[value]] to empty.
|
||||||
|
iii. Return true.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([['a',1], ['b', 2]]);
|
||||||
|
|
||||||
|
var result = m.delete('a');
|
||||||
|
|
||||||
|
assert(result);
|
||||||
|
assert.sameValue(m.size, 1);
|
Loading…
x
Reference in New Issue
Block a user