Bladeren bron

LibJS/Tests: Add a test for an async function which returns a thenable

This test passes when running in the AST interpreter, but fails when
running for bytecode.
Shannon Booth 2 jaren geleden
bovenliggende
commit
016b31fae2
1 gewijzigde bestanden met toevoegingen van 12 en 0 verwijderingen
  1. 12 0
      Userland/Libraries/LibJS/Tests/syntax/async-await.js

+ 12 - 0
Userland/Libraries/LibJS/Tests/syntax/async-await.js

@@ -200,3 +200,15 @@ describe("await cannot be used in class static init blocks", () => {
         expect("class A{ static { async function* await() {} } }").not.toEval();
     });
 });
+
+test("async returning a thenable", () => {
+    let isCalled = false;
+    const f = async () => ({
+        then() {
+            isCalled = true;
+        },
+    });
+    f();
+    runQueuedPromiseJobs();
+    expect(isCalled).toBe(true);
+});