Debian Codegraph @

js/src/tests/non262/WeakMap/getOrInsert/does-not-have-weakmapdata-internal-slot-array.js

raw
1 // |reftest| shell-option(--enable-upsert) skip-if(!WeakMap.prototype.getOrInsert)
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.getOrInsert ( key, value )
11
12 ...
13 1. Let M be the this value.
14 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
15 ...
16
17 ---*/
18
19 assertThrowsInstanceOf(function() {
20 WeakMap.prototype.getOrInsert.call([], {}, 1);
21 }, TypeError);
22
23 assertThrowsInstanceOf(function() {
24 var map = new WeakMap();
25 map.getOrInsert.call([], {}, 1);
26 }, TypeError);
27
28 reportCompare(0, 0);