mirror of
https://github.com/tc39/test262.git
synced 2025-07-20 20:44:43 +02:00
Move WeakMap.prototype.getOrInsert tests from staging to built-ins (#4476)
* Fix esid and remove noStrict * Fixup length.js and returns-value-if-key-is-not-present-symbol-key.js
This commit is contained in:
parent
1049f77ba3
commit
c2e3e37b68
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Adds a value with an Object key if key is not already in the map.
|
Adds a value with an Object key if key is not already in the map.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
6. Append p to M.[[WeakMapData]].
|
6. Append p to M.[[WeakMapData]].
|
||||||
...
|
...
|
||||||
features: [WeakMap, upsert]
|
features: [WeakMap, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var map = new WeakMap();
|
var map = new WeakMap();
|
||||||
var foo = {};
|
var foo = {};
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Adds a value with a Symbol key if key is not already in the map.
|
Adds a value with a Symbol key if key is not already in the map.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
6. Append p to M.[[WeakMapData]].
|
6. Append p to M.[[WeakMapData]].
|
||||||
...
|
...
|
||||||
features: [Symbol, WeakMap, symbols-as-weakmap-keys, upsert]
|
features: [Symbol, WeakMap, symbols-as-weakmap-keys, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var map = new WeakMap();
|
var map = new WeakMap();
|
||||||
var foo = Symbol('a description');
|
var foo = Symbol('a description');
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||||
...
|
...
|
||||||
features: [upsert]
|
features: [upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
WeakMap.prototype.getOrInsert.call([], {}, 1);
|
WeakMap.prototype.getOrInsert.call([], {}, 1);
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||||
...
|
...
|
||||||
features: [Map, upsert]
|
features: [Map, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
WeakMap.prototype.getOrInsert.call(new Map(), {}, 1);
|
WeakMap.prototype.getOrInsert.call(new Map(), {}, 1);
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||||
...
|
...
|
||||||
features: [upsert]
|
features: [upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
WeakMap.prototype.getOrInsert.call({}, {}, 1);
|
WeakMap.prototype.getOrInsert.call({}, {}, 1);
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||||
...
|
...
|
||||||
features: [Set, upsert]
|
features: [Set, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
WeakMap.prototype.getOrInsert.call(new Set(), {}, 1);
|
WeakMap.prototype.getOrInsert.call(new Set(), {}, 1);
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||||
...
|
...
|
||||||
features: [upsert]
|
features: [upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
WeakMap.prototype.getOrInsert.call(WeakMap.prototype, {}, 1);
|
WeakMap.prototype.getOrInsert.call(WeakMap.prototype, {}, 1);
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
WeakMap.prototype.getOrInsert property descriptor
|
WeakMap.prototype.getOrInsert property descriptor
|
||||||
info: |
|
info: |
|
||||||
@ -11,7 +11,6 @@ info: |
|
|||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
features: [upsert]
|
features: [upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof WeakMap.prototype.getOrInsert,
|
typeof WeakMap.prototype.getOrInsert,
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
WeakMap.prototype.getOrInsert.length descriptor
|
WeakMap.prototype.getOrInsert.length descriptor
|
||||||
info: |
|
info: |
|
||||||
@ -11,7 +11,6 @@ info: |
|
|||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
features: [upsert]
|
features: [upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
verifyProperty(WeakMap.prototype.getOrInsert, "length", {
|
verifyProperty(WeakMap.prototype.getOrInsert, "length", {
|
||||||
value: 2,
|
value: 2,
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
WeakMap.prototype.getOrInsert.name descriptor
|
WeakMap.prototype.getOrInsert.name descriptor
|
||||||
info: |
|
info: |
|
||||||
@ -11,7 +11,6 @@ info: |
|
|||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
features: [upsert]
|
features: [upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
verifyProperty(Map.prototype.getOrInsert, "name", {
|
verifyProperty(Map.prototype.getOrInsert, "name", {
|
||||||
value: "getOrInsert",
|
value: "getOrInsert",
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
WeakMap.prototype.getOrInsert does not implement [[Construct]], is not new-able
|
WeakMap.prototype.getOrInsert does not implement [[Construct]], is not new-able
|
||||||
info: |
|
info: |
|
||||||
@ -19,7 +19,6 @@ info: |
|
|||||||
...
|
...
|
||||||
includes: [isConstructor.js]
|
includes: [isConstructor.js]
|
||||||
features: [Reflect.construct, WeakMap, arrow-function, upsert]
|
features: [Reflect.construct, WeakMap, arrow-function, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
isConstructor(WeakMap.prototype.getOrInsert),
|
isConstructor(WeakMap.prototype.getOrInsert),
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Returns the value given as parameter when key is not present.
|
Returns the value given as parameter when key is not present.
|
||||||
info: |
|
info: |
|
||||||
@ -15,7 +15,6 @@ info: |
|
|||||||
6. Append p to M.[[WeakMapData]].
|
6. Append p to M.[[WeakMapData]].
|
||||||
7. Return value.
|
7. Return value.
|
||||||
features: [WeakMap, upsert]
|
features: [WeakMap, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var foo = {};
|
var foo = {};
|
||||||
var bar = {};
|
var bar = {};
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Returns the value given as parameter when key is not present.
|
Returns the value given as parameter when key is not present.
|
||||||
info: |
|
info: |
|
||||||
@ -15,17 +15,16 @@ info: |
|
|||||||
6. Append p to M.[[WeakMapData]].
|
6. Append p to M.[[WeakMapData]].
|
||||||
7. Return value.
|
7. Return value.
|
||||||
features: [Symbol, WeakMap, symbols-as-weakmap-keys, upsert]
|
features: [Symbol, WeakMap, symbols-as-weakmap-keys, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var foo = Symbol('a description');
|
var foo = Symbol('a description');
|
||||||
var bar = Symbol('a description');
|
var bar = Symbol('a description');
|
||||||
var baz = Symbol('different description');
|
var baz = Symbol('different description');
|
||||||
var map = new WeakMap();
|
var map = new WeakMap();
|
||||||
|
|
||||||
assert.sameValue(map.getOrInsert(foo, 0), 0, 'Regular symbol as key, added in constructor');
|
assert.sameValue(map.getOrInsert(foo, 0), 0);
|
||||||
|
|
||||||
assert.sameValue(map.getOrInsert(baz, 2), 2, 'Regular symbol as key, added with set()');
|
assert.sameValue(map.getOrInsert(baz, 2), 2);
|
||||||
assert.sameValue(map.getOrInsert(bar, 1), 1, "Symbols with the same description don't overwrite each other");
|
assert.sameValue(map.getOrInsert(bar, 1), 1);
|
||||||
|
|
||||||
assert.sameValue(map.getOrInsert(Symbol.hasInstance, 3), 3, 'Well-known symbol as key');
|
assert.sameValue(map.getOrInsert(Symbol.hasInstance, 3), 3);
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Returns the value from the specified Object key
|
Returns the value from the specified Object key
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
|
a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
|
||||||
...
|
...
|
||||||
features: [WeakMap, upsert]
|
features: [WeakMap, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var foo = {};
|
var foo = {};
|
||||||
var bar = {};
|
var bar = {};
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Returns the value from the specified Symbol key
|
Returns the value from the specified Symbol key
|
||||||
info: |
|
info: |
|
||||||
@ -13,7 +13,6 @@ info: |
|
|||||||
a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
|
a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
|
||||||
...
|
...
|
||||||
features: [Symbol, WeakMap, symbols-as-weakmap-keys, upsert]
|
features: [Symbol, WeakMap, symbols-as-weakmap-keys, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var foo = Symbol('a description');
|
var foo = Symbol('a description');
|
||||||
var bar = Symbol('a description');
|
var bar = Symbol('a description');
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes, Sune Eriksson Lianes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes, Sune Eriksson Lianes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws a TypeError if `this` is not an Object.
|
Throws a TypeError if `this` is not an Object.
|
||||||
info: |
|
info: |
|
||||||
@ -12,7 +12,6 @@ info: |
|
|||||||
2. Perform ? RequireInternalSlot(M, [[WeakMapData]])
|
2. Perform ? RequireInternalSlot(M, [[WeakMapData]])
|
||||||
...
|
...
|
||||||
features: [Symbol, upsert]
|
features: [Symbol, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var m = new WeakMap();
|
var m = new WeakMap();
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: proposal-upsert
|
esid: sec-weakmap.prototype.getOrInsert
|
||||||
description: |
|
description: |
|
||||||
Throws TypeError if key cannot be held weakly.
|
Throws TypeError if key cannot be held weakly.
|
||||||
info: |
|
info: |
|
||||||
@ -12,7 +12,6 @@ info: |
|
|||||||
3. If CanBeHeldWeakly(key) is false, throw a TypeError exception.
|
3. If CanBeHeldWeakly(key) is false, throw a TypeError exception.
|
||||||
...
|
...
|
||||||
features: [Symbol, WeakMap, upsert]
|
features: [Symbol, WeakMap, upsert]
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
---*/
|
||||||
var s = new WeakMap();
|
var s = new WeakMap();
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user