Skip to content

Commit 13810f2

Browse files
committed
And and rename Array.fromAsync thenable rejection test cases
Adds built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js. This is related to tc39/ecma262#1849 and tc39/ecma262#2600. This closes tc39/proposal-array-from-async#49. Renames built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js to built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js for consistency with the new test.
1 parent cf4c281 commit 13810f2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (C) 2025 J. S. Choi. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-array.fromasync
6+
description: >
7+
Array.fromAsync closes any sync-iterable input with a rejecting thenable.
8+
includes: [asyncHelpers.js]
9+
flags: [async]
10+
features: [Array.fromAsync]
11+
---*/
12+
13+
asyncTest(async function () {
14+
const expectedValue = {};
15+
let finallyCounter = 0;
16+
const inputThenable = {
17+
then(resolve, reject) {
18+
reject();
19+
},
20+
};
21+
function* createInput() {
22+
try {
23+
yield inputThenable;
24+
} finally {
25+
finallyCounter++;
26+
}
27+
}
28+
const input = createInput();
29+
try {
30+
await Array.fromAsync(input);
31+
} finally {
32+
assert.sameValue(finallyCounter, 1);
33+
}
34+
});

0 commit comments

Comments
 (0)