Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it'd be good to add assert.sameValue(map.get(-0), 43); at the end as well.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Append a new value in the map normalizing +0 and -0.
info: |
Expand All @@ -16,7 +16,6 @@ info: |
6. Append p to M.[[MapData]].
...
features: [Symbol, upsert]
flags: [noStrict]
---*/
var map = new Map();
map.getOrInsert(-0, 42);
Expand All @@ -25,4 +24,4 @@ assert.sameValue(map.get(0), 42);
map = new Map();
map.getOrInsert(+0, 43);
assert.sameValue(map.get(0), 43);

assert.sameValue(map.get(-0), 43);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Append a new value as the last element of entries.
info: |
Expand All @@ -16,7 +16,6 @@ info: |
6. Append p to M.[[MapData]].
...
features: [Symbol, upsert]
flags: [noStrict]
---*/
var s = Symbol(2);
var map = new Map([[4, 4], ['foo3', 3], [s, 2]]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Inserts the value for the specified key on different types, when key not present.
info: |
Expand All @@ -13,7 +13,6 @@ info: |
6. Append p to M.[[MapData]].
...
features: [Symbol, upsert]
flags: [noStrict]
---*/
var map = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Throws a TypeError if `this` is a Set Object
info: |
Expand All @@ -13,7 +13,6 @@ info: |
2. Perform ? RequireInternalSlot(M, [[MapData]])
...
features: [Set, upsert]
flags: [noStrict]
---*/
assert.throws(TypeError, function () {
Map.prototype.getOrInsert.call(new Set(), 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Throws a TypeError if `this` is a WeakMap object.
info: |
Expand All @@ -13,7 +13,6 @@ info: |
2. Perform ? RequireInternalSlot(M, [[MapData]]).
...
features: [WeakMap, upsert]
flags: [noStrict]
---*/
assert.throws(TypeError, function() {
Map.prototype.getOrInsert.call(new WeakMap(), 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
info: |
Expand All @@ -13,7 +13,6 @@ info: |
2. Perform ? RequireInternalSLot(M, [[MapData]])
...
features: [upsert]
flags: [noStrict]
---*/
var map = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Property type and descriptor.
info: |
Expand All @@ -11,7 +11,6 @@ info: |
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
features: [upsert]
flags: [noStrict]
---*/
assert.sameValue(
typeof Map.prototype.getOrInsert,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Map.prototype.getOrInsert.length value and descriptor.
info: |
Expand All @@ -11,7 +11,6 @@ info: |
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
features: [upsert]
flags: [noStrict]
---*/
verifyProperty(Map.prototype.getOrInsert, "length", {
value: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Map.prototype.getOrInsert.name value and descriptor.
info: |
Expand All @@ -11,7 +11,6 @@ info: |
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
features: [upsert]
flags: [noStrict]
---*/
verifyProperty(Map.prototype.getOrInsert, "name", {
value: "getOrInsert",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This code is governed by the BSD license found in the LICENSE file.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Returns the value from the specified key on different types, when key not present.
info: |
Expand All @@ -14,7 +14,6 @@ info: |
7. Return p.[[Value]].
...
features: [Symbol, upsert]
flags: [noStrict]
---*/
var map = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Returns the value set before getOrInsert from the specified key on different types.
info: |
Expand All @@ -13,7 +13,6 @@ info: |
a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
...
features: [Symbol, upsert]
flags: [noStrict]
---*/
var map = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Jonas Haukenes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Returns the value from the specified key normalizing +0 and -0.
info: |
Expand All @@ -13,7 +13,6 @@ info: |
a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
...
features: [upsert]
flags: [noStrict]
---*/
var map = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (C) 2024 Sune Eriksson Lianes. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: proposal-upsert
esid: sec-map.prototype.getorinsert
description: |
Throws a TypeError if `this` is not an Object.
info: |
Expand All @@ -12,7 +12,6 @@ info: |
2. Perform ? RequireInternalSlot(M, [[MapData]])
...
features: [Symbol, upsert]
flags: [noStrict]
---*/
var m = new Map();

Expand Down