mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-04 08:36:12 +00:00
LibJS: Call resolve instead of reject in AsyncFromSyncIteratorPrototype
This commit is contained in:
parent
3b1c3e574f
commit
fb61e9274a
Notes:
sideshowbarker
2024-07-17 07:34:33 +09:00
Author: https://github.com/davidot
Commit: fb61e9274a
Pull-request: https://github.com/SerenityOS/serenity/pull/15100
Reviewed-by: https://github.com/linusg
2 changed files with 25 additions and 1 deletions
|
@ -44,6 +44,30 @@ describe("basic behavior", () => {
|
|||
expect(loopIterations).toBe(1);
|
||||
expect(rejected).toBeFalse();
|
||||
});
|
||||
|
||||
test("can break a for-await-of loop", () => {
|
||||
var loopIterations = 0;
|
||||
var rejected = false;
|
||||
async function f() {
|
||||
for await (const v of [1, 2, 3]) {
|
||||
expect(v).toBe(1);
|
||||
loopIterations++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
f().then(
|
||||
() => {
|
||||
expect(loopIterations).toBe(1);
|
||||
},
|
||||
() => {
|
||||
rejected = true;
|
||||
}
|
||||
);
|
||||
runQueuedPromiseJobs();
|
||||
expect(loopIterations).toBe(1);
|
||||
expect(rejected).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe("only allowed in async functions", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue