1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

LibJS: Implement await properly for async functions

Fixes #20275

```
Summary:
    Diff Tests:
        +4     -4    

Diff Tests:
    test/built-ins/Array/fromAsync/non-iterable-input-with-thenable
    -async-mapped-awaits-callback-result-once.js  -> 
    test/language/expressions/await/async-await-interleaved.js  -> 
    test/language/expressions/await/await-awaits-thenables-that-
    throw.js  -> 
    test/language/expressions/await/await-awaits-thenables.js  -> 
```
This commit is contained in:
Luke Wilde 2023-08-09 22:12:07 +01:00 committed by Andreas Kling
parent 5003b1a421
commit ae7a0c43a9
5 changed files with 175 additions and 69 deletions

View file

@ -7,7 +7,7 @@ describe("correct behaviour", () => {
yield b + 1;
yield Promise.resolve(b + 2);
yield* [Promise.resolve(b + 3), Promise.resolve(b + 4), Promise.resolve(b + 5)];
return b + 6;
return Promise.resolve(b + 6);
}
test("length is 1", () => {
@ -64,7 +64,7 @@ describe("correct behaviour", () => {
expect(seventhRunResult).toBe(9);
});
test("can return a value", () => {
test("can return a value and return implicitly awaits", () => {
const eighthRunResult = runGenerator("bad7", false);
expect(eighthRunResult.value).toBe(10);
expect(eighthRunResult.done).toBeTrue();