diff --git a/Userland/Libraries/LibJS/Tests/syntax/async-await.js b/Userland/Libraries/LibJS/Tests/syntax/async-await.js index 43456d42b5..a561b7e426 100644 --- a/Userland/Libraries/LibJS/Tests/syntax/async-await.js +++ b/Userland/Libraries/LibJS/Tests/syntax/async-await.js @@ -201,14 +201,71 @@ describe("await cannot be used in class static init blocks", () => { }); }); -test.xfailIf(isBytecodeInterpreterEnabled(), "async returning a thenable", () => { - let isCalled = false; - const f = async () => ({ - then() { - isCalled = true; - }, +describe("await thenables", () => { + // FIXME: This test crashes for AST, and fails for bytecode. + test.skip("async returning a thanable variable without fulfilling", () => { + let isCalled = false; + const obj = { + then() { + isCalled = true; + }, + }; + + const f = async () => await obj; + f(); + runQueuedPromiseJobs(); + expect(isCalled).toBe(true); }); - f(); - runQueuedPromiseJobs(); - expect(isCalled).toBe(true); + + test.xfailIf( + isBytecodeInterpreterEnabled(), + "async returning a thanable variable that fulfills", + () => { + let isCalled = false; + const obj = { + then(fulfill) { + isCalled = true; + fulfill(isCalled); + }, + }; + + const f = async () => await obj; + f(); + runQueuedPromiseJobs(); + expect(isCalled).toBe(true); + } + ); + + test.xfailIf( + isBytecodeInterpreterEnabled(), + "async returning a thenable directly without fulfilling", + () => { + let isCalled = false; + const f = async () => ({ + then() { + isCalled = true; + }, + }); + f(); + runQueuedPromiseJobs(); + expect(isCalled).toBe(true); + } + ); + + test.xfailIf( + isBytecodeInterpreterEnabled(), + "async returning a thenable directly that fulfills", + () => { + let isCalled = false; + const f = async () => ({ + then(fulfill) { + isCalled = true; + fulfill(isCalled); + }, + }); + f(); + runQueuedPromiseJobs(); + expect(isCalled).toBe(true); + } + ); });