mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 08:24:23 +02:00
harness/asyncHelpers.js: Remove dependency on Promise.
This commit is contained in:
parent
98952c3c51
commit
4bd0545b29
@ -10,9 +10,14 @@ function asyncTest(testFunc) {
|
|||||||
if (!Object.hasOwn(globalThis, "$DONE")) {
|
if (!Object.hasOwn(globalThis, "$DONE")) {
|
||||||
throw new Test262Error("asyncTest called without async flag");
|
throw new Test262Error("asyncTest called without async flag");
|
||||||
}
|
}
|
||||||
|
const resolveThenable = {
|
||||||
|
then(resolve, reject) {
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
};
|
||||||
if (typeof testFunc !== "function") {
|
if (typeof testFunc !== "function") {
|
||||||
$DONE(new Test262Error("asyncTest called with non-function argument"));
|
$DONE(new Test262Error("asyncTest called with non-function argument"));
|
||||||
return Promise.resolve();
|
return resolveThenable;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return testFunc().then(
|
return testFunc().then(
|
||||||
@ -25,7 +30,7 @@ function asyncTest(testFunc) {
|
|||||||
);
|
);
|
||||||
} catch (syncError) {
|
} catch (syncError) {
|
||||||
$DONE(syncError);
|
$DONE(syncError);
|
||||||
return Promise.resolve();
|
return resolveThenable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user