Debian Codegraph @

js/src/tests/non262/WeakMap/getOrInsertComputed/does-not-have-weakmapdata-internal-slot-array.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 ---*/
16
17 assertThrowsInstanceOf(function() {
18 WeakMap.prototype.getOrInsertComputed.call([], {}, () => 1);
19 }, TypeError);
20
21 assertThrowsInstanceOf(function() {
22 var map = new WeakMap();
23 map.getOrInsertComputed.call([], {}, () => 1);
24 }, TypeError);
25
26 reportCompare(0, 0);