Debian Codegraph @

js/src/tests/test262/built-ins/Array/fromAsync/mapfn-sync-throws.js

raw
1 // |reftest| async
2 // Copyright (C) 2023 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-array.fromasync
7 description: >
8 The output promise rejects if the synchronous mapping function throws.
9 info: |
10 3.j.ii.6. If _mapping_ is *true*, then
11 a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »).
12 b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_).
13 ...
14 flags: [async]
15 includes: [asyncHelpers.js]
16 features: [Array.fromAsync]
17 ---*/
18
19 asyncTest(async () => {
20 await assert.throwsAsync(Test262Error, () => Array.fromAsync([1, 2, 3], () => {
21 throw new Test262Error("mapfn throws");
22 }), "sync mapfn throwing should cause fromAsync to reject");
23 });