Move Map.prototype.getOrInsert tests from staging (#4472)

* Move Map.prototype.getOrInsert tests from staging

* Fix esid and remove noStrict

* Add check for map.get(-0) to append-new-values-normalizes-zero-key.js
This commit is contained in:
Daniel Minor 2025-05-12 16:27:39 -04:00 committed by GitHub
parent 545df3a432
commit 2e59aad8d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 15 additions and 29 deletions

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Append a new value in the map normalizing +0 and -0. Append a new value in the map normalizing +0 and -0.
info: | info: |
@ -16,7 +16,6 @@ info: |
6. Append p to M.[[MapData]]. 6. Append p to M.[[MapData]].
... ...
features: [Symbol, upsert] features: [Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map(); var map = new Map();
map.getOrInsert(-0, 42); map.getOrInsert(-0, 42);
@ -25,4 +24,4 @@ assert.sameValue(map.get(0), 42);
map = new Map(); map = new Map();
map.getOrInsert(+0, 43); map.getOrInsert(+0, 43);
assert.sameValue(map.get(0), 43); assert.sameValue(map.get(0), 43);
assert.sameValue(map.get(-0), 43);

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Append a new value as the last element of entries. Append a new value as the last element of entries.
info: | info: |
@ -16,7 +16,6 @@ info: |
6. Append p to M.[[MapData]]. 6. Append p to M.[[MapData]].
... ...
features: [Symbol, upsert] features: [Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var s = Symbol(2); var s = Symbol(2);
var map = new Map([[4, 4], ['foo3', 3], [s, 2]]); var map = new Map([[4, 4], ['foo3', 3], [s, 2]]);

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Inserts the value for the specified key on different types, when key not present. Inserts the value for the specified key on different types, when key not present.
info: | info: |
@ -13,7 +13,6 @@ info: |
6. Append p to M.[[MapData]]. 6. Append p to M.[[MapData]].
... ...
features: [Symbol, upsert] features: [Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map(); var map = new Map();

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Throws a TypeError if `this` is a Set Object Throws a TypeError if `this` is a Set Object
info: | info: |
@ -13,7 +13,6 @@ info: |
2. Perform ? RequireInternalSlot(M, [[MapData]]) 2. Perform ? RequireInternalSlot(M, [[MapData]])
... ...
features: [Set, upsert] features: [Set, upsert]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
Map.prototype.getOrInsert.call(new Set(), 1, 1); Map.prototype.getOrInsert.call(new Set(), 1, 1);

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Throws a TypeError if `this` is a WeakMap object. Throws a TypeError if `this` is a WeakMap object.
info: | info: |
@ -13,7 +13,6 @@ info: |
2. Perform ? RequireInternalSlot(M, [[MapData]]). 2. Perform ? RequireInternalSlot(M, [[MapData]]).
... ...
features: [WeakMap, upsert] features: [WeakMap, upsert]
flags: [noStrict]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Map.prototype.getOrInsert.call(new WeakMap(), 1, 1); Map.prototype.getOrInsert.call(new WeakMap(), 1, 1);

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Throws a TypeError if `this` object does not have a [[MapData]] internal slot. Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
info: | info: |
@ -13,7 +13,6 @@ info: |
2. Perform ? RequireInternalSLot(M, [[MapData]]) 2. Perform ? RequireInternalSLot(M, [[MapData]])
... ...
features: [upsert] features: [upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map(); var map = new Map();

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Property type and descriptor. Property type and 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 Map.prototype.getOrInsert, typeof Map.prototype.getOrInsert,

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Map.prototype.getOrInsert.length value and descriptor. Map.prototype.getOrInsert.length value and 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, "length", { verifyProperty(Map.prototype.getOrInsert, "length", {
value: 2, value: 2,

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Map.prototype.getOrInsert.name value and descriptor. Map.prototype.getOrInsert.name value and 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",

View File

@ -3,7 +3,7 @@
// 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-map.prototype.getorinsert
description: | description: |
Map.prototype.getOrInsert does not implement [[Construct]], is not new-able Map.prototype.getOrInsert does not implement [[Construct]], is not new-able
info: | info: |
@ -20,7 +20,6 @@ info: |
... ...
includes: [isConstructor.js] includes: [isConstructor.js]
features: [Map, Reflect.construct, arrow-function, upsert] features: [Map, Reflect.construct, arrow-function, upsert]
flags: [noStrict]
---*/ ---*/
assert.sameValue(isConstructor(Map.prototype.getOrInsert), false, 'isConstructor(Map.prototype.getOrInsert) must return false'); assert.sameValue(isConstructor(Map.prototype.getOrInsert), false, 'isConstructor(Map.prototype.getOrInsert) must return false');

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Returns the value from the specified key on different types, when key not present. Returns the value from the specified key on different types, when key not present.
info: | info: |
@ -14,7 +14,6 @@ info: |
7. Return p.[[Value]]. 7. Return p.[[Value]].
... ...
features: [Symbol, upsert] features: [Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map(); var map = new Map();

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Returns the value set before getOrInsert from the specified key on different types. Returns the value set before getOrInsert from the specified key on different types.
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, upsert] features: [Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map(); var map = new Map();

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved. // Copyright (C) 2024 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-map.prototype.getorinsert
description: | description: |
Returns the value from the specified key normalizing +0 and -0. Returns the value from the specified key normalizing +0 and -0.
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: [upsert] features: [upsert]
flags: [noStrict]
---*/ ---*/
var map = new Map(); var map = new Map();

View File

@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved. // Copyright (C) 2024 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-map.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, [[MapData]]) 2. Perform ? RequireInternalSlot(M, [[MapData]])
... ...
features: [Symbol, upsert] features: [Symbol, upsert]
flags: [noStrict]
---*/ ---*/
var m = new Map(); var m = new Map();