Move WeakMap.prototype.getOrInsertComputed tests from staging to built-ins

This commit is contained in:
Daniel Minor 2025-06-09 09:45:43 -04:00 committed by Jordan Harband
parent 609614febe
commit 6a73fa8f11
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
24 changed files with 153 additions and 126 deletions

View File

@ -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.getorinsertcomputed
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: |
9. Append p to M.[[WeakMapData]]. 9. 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 = {};

View File

@ -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.getorinsertcomputed
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: |
9. Append p to M.[[WeakMapData]]. 9. 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');

View File

@ -1,7 +1,7 @@
// Copyright (C) 2025 Jonas Haukenes, Mathias Ness. All rights reserved. // Copyright (C) 2025 Jonas Haukenes, Mathias Ness. 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.getorinsertcomputed
description: | description: |
Does not throw if `callbackfn` is callable. Does not throw if `callbackfn` is callable.
info: | info: |
@ -10,8 +10,7 @@ info: |
... ...
3. If IsCallable(callbackfn) is false, throw a TypeError exception. 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
... ...
features: [arrow-function, upsert] features: [arrow-function, upsert, WeakMap]
flags: [noStrict]
---*/ ---*/
var bar = {}; var bar = {};
var baz = {}; var baz = {};

View File

@ -1,7 +1,7 @@
// Copyright (C) 2024 Jonas Haukenes, Mathias Ness. All rights reserved. // Copyright (C) 2024 Jonas Haukenes, Mathias Ness. 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.getorinsertcomputed
description: | description: |
WeakMap.getOrInsertComputed throws when callbackfn throws return if abrubt completion Call(callbackfn, key) WeakMap.getOrInsertComputed throws when callbackfn throws return if abrubt completion Call(callbackfn, key)
info: | info: |
@ -10,8 +10,7 @@ info: |
... ...
6. Let value be ? Call(callbackfn, undefined, key). 6. Let value be ? Call(callbackfn, undefined, key).
... ...
features: [upsert] features: [upsert, WeakMap]
flags: [noStrict]
---*/ ---*/
var map = new WeakMap(); var map = new WeakMap();

View File

@ -0,0 +1,24 @@
// Copyright (C) 2025 Daniel Minor. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-weakmap.prototype.getorinsertcomputed
description: |
Check that callbackfn receives undefined for this and exactly one argument.
info: |
WeakMap.prototype.getOrInsertComputed ( key , callbackfn )
...
6. Let value be ? Call(callbackfn, key).
...
features: [upsert, Symbol, WeakMap]
flags: [onlyStrict]
---*/
var map = new WeakMap();
var symbol = Symbol('a description');
map.getOrInsertComputed(symbol, function () {
assert.sameValue(this, undefined);
assert.sameValue(arguments.length, 1);
assert.sameValue(arguments[0], symbol);
});

View File

@ -0,0 +1,61 @@
// Copyright (C) 2025 Daniel Minor. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-weakmap.prototype.getorinsertcomputed
description: |
Check state after callback function throws
info: |
WeakMap.prototype.getOrInsertComputed ( key , callbackfn )
...
6. Let value be ? Call(callbackfn, key).
...
features: [upsert, WeakMap, Symbol]
---*/
var map = new WeakMap();
const obj0 = {};
const obj1 = {};
const obj2 = {};
const obj3 = {};
map.set(obj0, 'zero');
map.set(obj1, 'one');
map.set(obj2, 'two');
assert.throws(Error, function() {
map.getOrInsertComputed(Symbol('3'), function() {
throw new Error('throw in callback');
})
});
// Check the values after throwing in callbackfn.
assert.sameValue(map.get(obj0), 'zero');
assert.sameValue(map.get(obj1), 'one');
assert.sameValue(map.get(obj2), 'two');
assert.sameValue(map.has(obj3), false);
assert.throws(Error, function() {
map.getOrInsertComputed(obj3, function() {
map.set(obj1, 'mutated');
throw new Error('throw in callback');
})
});
// Check the values after throwing in callbackfn, with mutation.
assert.sameValue(map.get(obj0), 'zero');
assert.sameValue(map.get(obj1), 'mutated');
assert.sameValue(map.get(obj2), 'two');
assert.sameValue(map.has(obj3), false);
assert.throws(Error, function() {
map.getOrInsertComputed(obj3, function() {
map.set(obj3, 'mutated');
throw new Error('throw in callback');
})
});
// Check the values after throwing in callbackfn, with mutation.
assert.sameValue(map.get(obj0), 'zero');
assert.sameValue(map.get(obj1), 'mutated');
assert.sameValue(map.get(obj2), 'two');
assert.sameValue(map.get(obj3), 'mutated');

View File

@ -1,7 +1,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.getorinsertcomputed
description: | description: |
Does not evaluate the callback function if the key is already in the map. Does not evaluate the callback function if the key is already in the map.
info: | info: |
@ -13,25 +13,30 @@ info: |
6. Let value be ? Call(callbackfn, undefined, « key »). 6. Let value be ? Call(callbackfn, undefined, « key »).
... ...
features: [WeakMap, upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map([ const obj1 = {};
[1, 0] const obj2 = {};
]); const obj3 = {};
const obj4 = {};
const map = new WeakMap();
map.set(obj1, 0);
let callbackCalls = 0;
function callback() { function callback() {
throw new Error('Callbackfn should not be evaluated if key is present'); callbackCalls += 1;
throw new Error('Callbackfn should not be evaluated if key is present');
} }
assert.sameValue(map.getOrInsertComputed(1, callback), 0); assert.sameValue(map.getOrInsertComputed(obj1, callback), 0);
map.set(2, 1); map.set(obj2, 1);
assert.sameValue(map.getOrInsertComputed(2, callback), 1); assert.sameValue(map.getOrInsertComputed(obj2, callback), 1);
map.set(3, 2); map.set(obj3, 2);
assert.sameValue(map.getOrInsertComputed(3, callback), 2); assert.sameValue(map.getOrInsertComputed(obj3, callback), 2);
assert.throws(Error, function() { assert.throws(Error, function() {
map.getOrInsertComputed(4, callback) map.getOrInsertComputed(obj4, callback)
}, Error); }, Error);
assert.sameValue(callbackCalls, 1);

View File

@ -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.getorinsertcomputed
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: |
@ -11,15 +11,14 @@ info: |
... ...
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
... ...
features: [upsert] features: [upsert, WeakMap]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
WeakMap.prototype.getOrInsertComputed.call([], {}, () => 1); WeakMap.prototype.getOrInsertComputed.call([], {}, () => 1);
}); });
var map = new WeakMap();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
var map = new WeakMap();
map.getOrInsertComputed.call([], {}, () => 1); map.getOrInsertComputed.call([], {}, () => 1);
}); });

View File

@ -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.getorinsertcomputed
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: |
@ -11,15 +11,14 @@ info: |
... ...
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
... ...
features: [Map, upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
WeakMap.prototype.getOrInsertComputed.call(new Map(), {}, () => 1); WeakMap.prototype.getOrInsertComputed.call(new Map(), {}, () => 1);
}); });
var map = new WeakMap();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
var map = new WeakMap();
map.getOrInsertComputed.call(new Map(), {}, () => 1); map.getOrInsertComputed.call(new Map(), {}, () => 1);
}); });

View File

@ -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.getorinsertcomputed
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: |
@ -11,15 +11,14 @@ info: |
... ...
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
... ...
features: [upsert] features: [upsert, WeakMap]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
WeakMap.prototype.getOrInsertComputed.call({}, {}, () => 1); WeakMap.prototype.getOrInsertComputed.call({}, {}, () => 1);
}); });
var map = new WeakMap();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
var map = new WeakMap();
map.getOrInsertComputed.call({}, {}, () => 1); map.getOrInsertComputed.call({}, {}, () => 1);
}); });

View File

@ -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.getorinsertcomputed
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: |
@ -11,15 +11,14 @@ info: |
... ...
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
... ...
features: [Set, upsert] features: [Set, WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
WeakMap.prototype.getOrInsertComputed.call(new Set(), {}, () => 1); WeakMap.prototype.getOrInsertComputed.call(new Set(), {}, () => 1);
}); });
var map = new WeakMap();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
var map = new WeakMap();
map.getOrInsertComputed.call(new Set(), {}, () => 1); map.getOrInsertComputed.call(new Set(), {}, () => 1);
}); });

View File

@ -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.getorinsertcomputed
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: |
@ -11,15 +11,14 @@ info: |
... ...
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]). 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
... ...
features: [upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
WeakMap.prototype.getOrInsertComputed.call(WeakMap.prototype, {}, () => 1); WeakMap.prototype.getOrInsertComputed.call(WeakMap.prototype, {}, () => 1);
}); });
var map = new WeakMap();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
var map = new WeakMap();
map.getOrInsertComputed.call(WeakMap.prototype, {}, () => 1); map.getOrInsertComputed.call(WeakMap.prototype, {}, () => 1);
}); });

View File

@ -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.getorinsertcomputed
description: | description: |
WeakMap.prototype.getOrInsertComputed property descriptor WeakMap.prototype.getOrInsertComputed property descriptor
info: | info: |
@ -10,16 +10,9 @@ info: |
17 ECMAScript Standard Built-in Objects 17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js] includes: [propertyHelper.js]
features: [upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
assert.sameValue( verifyPrimordialCallableProperty(WeakMap.prototype, "getOrInsertComputed", "getOrInsertComputed", 2, {
typeof WeakMap.prototype.getOrInsertComputed,
'function',
'typeof WeakMap.prototype.getOrInsertComputed is "function"'
);
verifyProperty(WeakMap.prototype, "getOrInsertComputed", {
value: WeakMap.prototype.getOrInsertComputed, value: WeakMap.prototype.getOrInsertComputed,
writable: true, writable: true,
enumerable: false, enumerable: false,

View File

@ -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.getorinsertcomputed
description: | description: |
WeakMap.prototype.getOrInsertComputed does not implement [[Construct]], is not new-able WeakMap.prototype.getOrInsertComputed 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.getOrInsertComputed), isConstructor(WeakMap.prototype.getOrInsertComputed),
@ -27,7 +26,8 @@ assert.sameValue(
'isConstructor(WeakMap.prototype.getOrInsertComputed) must return false' 'isConstructor(WeakMap.prototype.getOrInsertComputed) must return false'
); );
let wm = new WeakMap();
assert.throws(TypeError, () => { assert.throws(TypeError, () => {
let wm = new WeakMap(); new wm.getOrInsertComputed({}, () => 1); new wm.getOrInsertComputed({}, () => 1);
}); });

View File

@ -2,7 +2,7 @@
// Copyright (C) 2025 Jonas Haukenes, Mathias Ness. All rights reserved. // Copyright (C) 2025 Jonas Haukenes, Mathias Ness. 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.getorinsertcomputed
description: | description: |
Throws a TypeError if `callbackfn` is not callable. Throws a TypeError if `callbackfn` is not callable.
info: | info: |
@ -11,41 +11,45 @@ info: |
... ...
3. If IsCallable(callbackfn) is false, throw a TypeError exception. 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
... ...
features: [Symbol, upsert] features: [WeakMap, Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var bar = {}; var bar = {};
var m = new WeakMap(); var m = new WeakMap();
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, 1); m.getOrInsertComputed(bar, 1);
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, ""); m.getOrInsertComputed(bar, "");
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, true); m.getOrInsertComputed(bar, true);
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, undefined); m.getOrInsertComputed(bar, undefined);
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, null); m.getOrInsertComputed(bar, null);
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, {}); m.getOrInsertComputed(bar, {});
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, []); m.getOrInsertComputed(bar, []);
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
m.getOrInsertComputed.call(m, bar, Symbol()); m.getOrInsertComputed(bar, Symbol());
}); });
// Check that it also throws if the key is already present (thus it does not try to call the callback)
m.set(bar, "foo");
assert.throws(TypeError, function () {
m.getOrInsertComputed(bar, 1);
});

View File

@ -1,7 +1,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.getorinsertcomputed
description: | description: |
If the callbackfn inserts a value on the given key, the value is overwritten. If the callbackfn inserts a value on the given key, the value is overwritten.
info: | info: |
@ -16,8 +16,7 @@ info: |
8. Let p be the Record { [[Key]]: key, [[Value]]: value }. 8. Let p be the Record { [[Key]]: key, [[Value]]: value }.
9. Append p to M.[[WeakMapData]]. 9. Append p to M.[[WeakMapData]].
... ...
features: [upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
var map = new WeakMap(); var map = new WeakMap();
var foo = {}; var foo = {};

View File

@ -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.getorinsertcomputed
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: |
9. Append p to M.[[WeakMapData]]. 9. Append p to M.[[WeakMapData]].
10. Return value. 10. Return value.
features: [WeakMap, upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
var foo = {}; var foo = {};
var bar = {}; var bar = {};

View File

@ -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.getorinsertcomputed
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: |
9. Append p to M.[[WeakMapData]]. 9. Append p to M.[[WeakMapData]].
10. Return value. 10. 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');

View File

@ -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.getorinsertcomputed
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 = {};

View File

@ -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.getorinsertcomputed
description: | description: |
Returns the value from the specified Symbol key Returns the value from the specified Symbol key
info: | info: |
@ -14,7 +14,6 @@ info: |
10. Return value. 10. 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');

View File

@ -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.getorinsertcomputed
description: | description: |
Throws a TypeError if `this` is not an Object. Throws a TypeError if `this` is not an Object.
info: | info: |
@ -11,8 +11,7 @@ info: |
1. Let M be the this value 1. Let M be the this value
2. Perform ? RequireInternalSlot(M, [[WeakMapData]]) 2. Perform ? RequireInternalSlot(M, [[WeakMapData]])
... ...
features: [Symbol, upsert] features: [WeakMap, Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var m = new WeakMap(); var m = new WeakMap();

View File

@ -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.getorinsertcomputed
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: |
4. If CanBeHeldWeakly(_key_) is *false*, throw a *TypeError* exception. 4. 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();

View File

@ -1,22 +0,0 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
description: |
WeakMap.prototype.getOrInsertComputed.length descriptor
info: |
WeakMap.prototype.getOrInsertComputed ( key, callbackfn )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
features: [upsert]
flags: [noStrict]
---*/
verifyProperty(WeakMap.prototype.getOrInsertComputed, "length", {
value: 2,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -1,22 +0,0 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// Copyright (C) 2025 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
description: |
WeakMap.prototype.getOrInsertComputed.name descriptor
info: |
WeakMap.prototype.getOrInsertComputed ( key, callbackfn )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
features: [upsert]
flags: [noStrict]
---*/
verifyProperty(Map.prototype.getOrInsertComputed, "name", {
value: "getOrInsertComputed",
writable: false,
enumerable: false,
configurable: true
});