mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 23:44:27 +02:00
Add test case for passing canonical key in getOrInsertComputed
This commit is contained in:
parent
823f4cfd20
commit
a073f479f8
33
test/built-ins/Map/prototype/getOrInsertComputed/canonical-key-passed-to-callback.js
vendored
Normal file
33
test/built-ins/Map/prototype/getOrInsertComputed/canonical-key-passed-to-callback.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-map.prototype.getorinsertcomputed
|
||||||
|
description: |
|
||||||
|
Ensure the canonical key is passed to the callback function.
|
||||||
|
info: |
|
||||||
|
Map.prototype.getOrInsertComputed ( key, callbackfn )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Set key to CanonicalizeKeyedCollectionKey(key).
|
||||||
|
...
|
||||||
|
6. Let value be ? Call(callbackfn, key).
|
||||||
|
...
|
||||||
|
|
||||||
|
CanonicalizeKeyedCollectionKey ( key )
|
||||||
|
|
||||||
|
1. If key is -0𝔽, return +0𝔽.
|
||||||
|
2. Return key.
|
||||||
|
features: [upsert]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
for (var key of [-0, +0]) {
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
var canonicalKey;
|
||||||
|
map.getOrInsertComputed(key, function(keyArg) {
|
||||||
|
canonicalKey = keyArg;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(+0, canonicalKey);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user