mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
LibJS: Close sync iterator when async wrapper yields rejection
This is a normative change in the ECMA-262 spec. See:
ff129b1
This commit is contained in:
parent
15faaeb2bb
commit
568524f8ba
Notes:
github-actions[bot]
2025-04-29 11:34:26 +00:00
Author: https://github.com/trflynn89
Commit: 568524f8ba
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4514
3 changed files with 162 additions and 45 deletions
|
@ -617,6 +617,37 @@ class ExpectationError extends Error {
|
|||
}
|
||||
};
|
||||
|
||||
asyncTest = async (message, callback) => {
|
||||
if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {};
|
||||
|
||||
const suite = __TestResults__[suiteMessage];
|
||||
if (Object.prototype.hasOwnProperty.call(suite, message)) {
|
||||
suite[message] = {
|
||||
result: "fail",
|
||||
details: "Another test with the same message did already run",
|
||||
duration: 0,
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
const time_ms = () => Date.now() - start;
|
||||
|
||||
try {
|
||||
await callback();
|
||||
suite[message] = {
|
||||
result: "pass",
|
||||
duration: time_ms(),
|
||||
};
|
||||
} catch (e) {
|
||||
suite[message] = {
|
||||
result: "fail",
|
||||
details: String(e),
|
||||
duration: time_ms(),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
test.skip = (message, callback) => {
|
||||
if (typeof callback !== "function")
|
||||
throw new Error("test.skip has invalid second argument (must be a function)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue