Debian Codegraph @

js/src/tests/non262/WeakMap/getOrInsertComputed/not-a-function-callbackfn-throws.js

raw
1 // |reftest| shell-option(--enable-upsert) skip-if(!WeakMap.prototype.getOrInsertComputed)
2 // Copyright (C) 2015 the V8 project authors. All rights reserved.
3 // Copyright (C) 2025 Jonas Haukenes, 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 WeakMap.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 bar = {};
19 var m = new WeakMap();
20
21 assertThrowsInstanceOf(function () {
22 m.getOrInsertComputed.call(m, bar, 1);
23 }, TypeError);
24
25 assertThrowsInstanceOf(function () {
26 m.getOrInsertComputed.call(m, bar, "");
27 }, TypeError);
28
29 assertThrowsInstanceOf(function () {
30 m.getOrInsertComputed.call(m, bar, true);
31 }, TypeError);
32
33 assertThrowsInstanceOf(function () {
34 m.getOrInsertComputed.call(m, bar, undefined);
35 }, TypeError);
36
37 assertThrowsInstanceOf(function () {
38 m.getOrInsertComputed.call(m, bar, null);
39 }, TypeError);
40
41 assertThrowsInstanceOf(function () {
42 m.getOrInsertComputed.call(m, bar, {});
43 }, TypeError);
44
45 assertThrowsInstanceOf(function () {
46 m.getOrInsertComputed.call(m, bar, []);
47 }, TypeError);
48
49 assertThrowsInstanceOf(function () {
50 m.getOrInsertComputed.call(m, bar, Symbol());
51 }, TypeError);
52
53 reportCompare(0, 0);