1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:07:34 +00:00

LibJS: Call resolve instead of reject in AsyncFromSyncIteratorPrototype

This commit is contained in:
davidot 2022-08-31 17:41:41 +02:00 committed by Linus Groh
parent 3b1c3e574f
commit fb61e9274a
2 changed files with 25 additions and 1 deletions

View file

@ -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", () => {