Skip to content

Commit

Permalink
harness/asyncHelpers.js: Remove dependency on Promise.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjtenny authored and ptomato committed Feb 21, 2023
1 parent 98952c3 commit 4bd0545
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions harness/asyncHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ function asyncTest(testFunc) {
if (!Object.hasOwn(globalThis, "$DONE")) {
throw new Test262Error("asyncTest called without async flag");
}
const resolveThenable = {
then(resolve, reject) {
resolve();
},
};
if (typeof testFunc !== "function") {
$DONE(new Test262Error("asyncTest called with non-function argument"));
return Promise.resolve();
return resolveThenable;
}
try {
return testFunc().then(
Expand All @@ -25,7 +30,7 @@ function asyncTest(testFunc) {
);
} catch (syncError) {
$DONE(syncError);
return Promise.resolve();
return resolveThenable;
}
}

Expand Down

0 comments on commit 4bd0545

Please sign in to comment.