Debian Codegraph @

js/src/tests/non262/Map/getOrInsert/does-not-have-mapdata-internal-slot-set.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` is a Set Object
9 info: |
10 Map.prototype.getOrInsert ( key , value )
11
12 ...
13 1. Let M be the this value.
14 2. Perform ? RequireInternalSlot(M, [[MapData]])
15 ...
16 features: [Set]
17 ---*/
18
19 assertThrowsInstanceOf(function () {
20 Map.prototype.getOrInsert.call(new Set(), 1, 1);
21 }, TypeError);
22
23 assertThrowsInstanceOf(function () {
24 var map = new Map();
25 map.getOrInsert.call(new Set(), 1, 1);
26 }, TypeError);
27
28 reportCompare(0, 0);