Debian Codegraph @

js/src/tests/non262/Map/getOrInsertComputed/does-not-have-mapdata-internal-slot.js

raw
1 // |reftest| shell-option(--enable-upsert) skip-if(!Map.prototype.getOrInsertComputed)
2 // Copyright (C) 2015 the V8 project authors. All rights reserved.
3 // Copyright (C) 2024 Sune Eriksson Lianes, Mathias Ness. 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 a TypeError if `this` object does not have a [[MapData]] internal slot.
9 info: |
10 Map.getOrInsertComputed ( key , callbackfn )
11
12 ...
13 1. Let M be the this value.
14 2. Perform ? RequireInternalSlot(M, [[MapData]]).
15 ...
16
17 features: [arrow-function]
18 ---*/
19
20 var map = new Map();
21
22 assertThrowsInstanceOf(function () {
23 Map.prototype.getOrInsertComputed.call([], 1, () => 1);
24 }, TypeError);
25
26 assertThrowsInstanceOf(function () {
27 map.getOrInsertComputed.call([], 1, () => 1);
28 }, TypeError);
29
30 assertThrowsInstanceOf(function () {
31 Map.prototype.getOrInsertComputed.call({}, 1, () => 1);
32 }, TypeError);
33
34 assertThrowsInstanceOf(function () {
35 map.getOrInsertComputed.call({}, 1, () => 1);
36 }, TypeError);
37
38 reportCompare(0, 0);