Debian Codegraph @

js/src/tests/non262/WeakMap/getOrInsertComputed/callbackfn-throws.js

raw
1 // |reftest| shell-option(--enable-upsert) skip-if(!WeakMap.prototype.getOrInsertComputed)
2 // Copyright (C) 2024 Jonas Haukenes, Mathias Ness. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: proposal-upsert
6 description: >
7 Map.getOrInsertComputed throws when callbackfn throws,
8 return if abrubt completion Call(callbackfn, undefined, key)
9
10 info: |
11 WeakMap.prototype.getOrInsertComputed ( key , callbackfn )
12
13 ...
14 6. Let value be ? Call(callbackfn, undefined, key).
15 ...
16 ---*/
17
18 var map = new WeakMap();
19
20 var bar = {};
21
22 assertThrowsInstanceOf(function() {
23 map.getOrInsertComputed(bar, function() {
24 throw new Error('throw in callback');
25 })
26 }, Error);
27
28 reportCompare(0, 0);