Add and rename Array.fromAsync thenable rejection test cases

This commit is contained in:
J. S. Choi 2025-04-14 09:47:05 -06:00 committed by GitHub
parent afc3d1bce4
commit 7cc98501d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
// Copyright (C) 2025 J. S. Choi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.fromasync
description: >
Array.fromAsync closes any sync-iterable input with a rejecting thenable.
includes: [asyncHelpers.js]
flags: [async]
features: [Array.fromAsync]
---*/
asyncTest(async function () {
const expectedValue = {};
let finallyCounter = 0;
const inputThenable = {
then(resolve, reject) {
reject();
},
};
function* createInput() {
try {
yield inputThenable;
} finally {
finallyCounter++;
}
}
const input = createInput();
try {
await Array.fromAsync(input);
} finally {
assert.sameValue(finallyCounter, 1);
}
});