Debian Codegraph @

js/src/tests/non262/Map/getOrInsertComputed/not-a-function-callbackfn-throws.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 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 `callbackfn` is not callable.
9 info: |
10 Map.prototype.getOrInsertComputed ( key , callbackfn )
11
12 ...
13 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
14 ...
15 features: [Symbol]
16 ---*/
17
18 var m = new Map();
19
20 assertThrowsInstanceOf(function () {
21 m.getOrInsertComputed.call(m, 1, 1);
22 }, TypeError);
23
24 assertThrowsInstanceOf(function () {
25 m.getOrInsertComputed.call(m, 1, "");
26 }, TypeError);
27
28 assertThrowsInstanceOf(function () {
29 m.getOrInsertComputed.call(m, 1, true);
30 }, TypeError);
31
32 assertThrowsInstanceOf(function () {
33 m.getOrInsertComputed.call(m, 1, undefined);
34 }, TypeError);
35
36 assertThrowsInstanceOf(function () {
37 m.getOrInsertComputed.call(m, 1, null);
38 }, TypeError);
39
40 assertThrowsInstanceOf(function () {
41 m.getOrInsertComputed.call(m, 1, {});
42 }, TypeError);
43
44 assertThrowsInstanceOf(function () {
45 m.getOrInsertComputed.call(m, 1, []);
46 }, TypeError);
47
48 assertThrowsInstanceOf(function () {
49 m.getOrInsertComputed.call(m, 1, Symbol());
50 }, TypeError);
51
52 reportCompare(0, 0);