LibJS: Replace Array.fromAsync with a native JavaScript implementation

This allows us to use the bytecode implementation of await, which
correctly suspends execution contexts and handles completion
injections.

This gains us 4 test262 tests around mutating Array.fromAsync's
iterable whilst it's suspended as well.

This is also one step towards removing spin_until, which the
non-bytecode implementation of await uses.

```
Duration:
     -5.98s

Summary:
    Diff Tests:
        +4     -4 

Diff Tests:
    [...]/Array/fromAsync/asyncitems-array-add-to-singleton.js  -> 
    [...]/Array/fromAsync/asyncitems-array-add.js               -> 
    [...]/Array/fromAsync/asyncitems-array-mutate.js            -> 
    [...]/Array/fromAsync/asyncitems-array-remove.js            -> 
```
This commit is contained in:
Luke Wilde 2025-11-06 19:20:29 +00:00 committed by Andreas Kling
parent a63b0cfaba
commit 0eceee0a05
Notes: github-actions[bot] 2025-11-30 10:56:04 +00:00
15 changed files with 942 additions and 233 deletions

View file

@ -101,4 +101,36 @@ describe("normal behavior", () => {
expect(counter).toBe(1);
});
asyncTest("mapper exception takes priority over iterator closure exception", async () => {
let exceptionOrder = [];
async function* iterator() {
try {
yield 1;
yield 2;
} finally {
exceptionOrder.push("iterator");
throw "iterator exception";
}
}
let exception = null;
try {
await Array.fromAsync(iterator(), value => {
if (value === 1) {
exceptionOrder.push("mapper");
throw "mapper exception";
}
return value;
});
} catch (e) {
exception = e;
}
expect(exceptionOrder).toEqual(["mapper", "iterator"]);
expect(exception).toBe("mapper exception");
});
});