Debian Codegraph @

js/src/tests/non262/Map/getOrInsertComputed/not-a-constructor.js

raw
1 // |reftest| shell-option(--enable-upsert) skip-if(!Map.prototype.getOrInsertComputed)
2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
3 // Copyright (C) 2024 Jonas Haukenes, Mathias Ness. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
5
6 /*---
7 esid: proposal-upsert
8 description: >
9 Map.prototype.getOrInsertComputed does not implement [[Construct]], is not new-able
10 info: |
11 ECMAScript Function Objects
12
13 Built-in function objects that are not identified as constructors do not
14 implement the [[Construct]] internal method unless otherwise specified in
15 the description of a particular function.
16
17 sec-evaluatenew
18
19 ...
20 7. If IsConstructor(constructor) is false, throw a TypeError exception.
21 ...
22 includes: [isConstructor.js]
23 features: [Reflect.construct, Map, arrow-function]
24 ---*/
25
26 assertEq(isConstructor(Map.prototype.getOrInsertComputed), false, 'isConstructor(Map.prototype.getOrInsertComputed) must return false');
27
28 assertThrowsInstanceOf(() => {
29 let m = new Map(); new m.getOrInsertComputed();
30 }, TypeError);
31
32 reportCompare(0, 0);