Debian Codegraph @

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

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