Debian Codegraph @

js/src/tests/test262/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js

raw
1 // |reftest| async
2 // Copyright (C) 2025 J. S. Choi. 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 Array.fromAsync closes any sync-iterable input with a rejecting thenable.
9 includes: [asyncHelpers.js]
10 flags: [async]
11 features: [Array.fromAsync]
12 ---*/
13
14 asyncTest(async function () {
15 const expectedValue = {};
16 let finallyCounter = 0;
17 const inputThenable = {
18 then(resolve, reject) {
19 reject();
20 },
21 };
22 function* createInput() {
23 try {
24 yield inputThenable;
25 } finally {
26 finallyCounter++;
27 }
28 }
29 const input = createInput();
30 try {
31 await Array.fromAsync(input);
32 } finally {
33 assert.sameValue(finallyCounter, 1);
34 }
35 });