Debian Codegraph @

js/src/tests/non262/Map/getOrInsertComputed/this-not-object-throw.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` is not an Object.
9 info: |
10 Map.prototype.getOrInsertComputed ( key , callbackfn )
11
12 1. Let M be the this value
13 2. Perform ? RequireInternalSlot(M, [[MapData]])
14 ...
15 features: [Symbol, arrow-function]
16 ---*/
17
18 var m = new Map();
19
20 assertThrowsInstanceOf(function () {
21 m.getOrInsertComputed.call(false, 1, () => 1);
22 }, TypeError);
23
24 assertThrowsInstanceOf(function () {
25 m.getOrInsertComputed.call(1, 1, () => 1);
26 }, TypeError);
27
28 assertThrowsInstanceOf(function () {
29 m.getOrInsertComputed.call("", 1, () => 1);
30 }, TypeError);
31
32 assertThrowsInstanceOf(function () {
33 m.getOrInsertComputed.call(undefined, 1, () => 1);
34 }, TypeError);
35
36 assertThrowsInstanceOf(function () {
37 m.getOrInsertComputed.call(null, 1, () => 1);
38 }, TypeError);
39
40 assertThrowsInstanceOf(function () {
41 m.getOrInsertComputed.call(Symbol(), 1, () => 1);
42 }, TypeError);
43
44 reportCompare(0, 0);