Debian Codegraph @

js/src/tests/non262/WeakMap/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-map.js

raw
1 // |reftest| shell-option(--enable-upsert) skip-if(!WeakMap.prototype.getOrInsertComputed)
2 // Copyright (C) 2015 the V8 project authors. All rights reserved.
3 // Copyright (C) 2025 Jonas Haukenes. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: proposal-upsert
7 description: >
8 Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
9 info: |
10 WeakMap.prototype.getOrInsertComputed ( key, callbackfn )
11
12 ...
13 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
14 ...
15 features: [Map]
16 ---*/
17
18 assertThrowsInstanceOf(function() {
19 WeakMap.prototype.getOrInsertComputed.call(new Map(), {}, () => 1);
20 }, TypeError);
21
22 assertThrowsInstanceOf(function() {
23 var map = new WeakMap();
24 map.getOrInsertComputed.call(new Map(), {}, () => 1);
25 }, TypeError);
26
27 reportCompare(0, 0);