Debian Codegraph @

js/src/tests/test262/built-ins/Array/fromAsync/mapfn-async-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 asynchronous mapping function rejects.
9 info: |
10 3.j.ii.6. If _mapping_ is *true*, then
11 a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »).
12 ...
13 c. Set _mappedValue_ to Await(_mappedValue_).
14 d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_).
15 flags: [async]
16 includes: [asyncHelpers.js]
17 features: [Array.fromAsync]
18 ---*/
19
20 asyncTest(async () => {
21 await assert.throwsAsync(Test262Error, () => Array.fromAsync([1, 2, 3], async () => {
22 throw new Test262Error("mapfn throws");
23 }), "async mapfn rejecting should cause fromAsync to reject");
24 });