mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 01:26:22 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
95
Libraries/LibJS/Tests/loops/for-await-of.js
Normal file
95
Libraries/LibJS/Tests/loops/for-await-of.js
Normal file
|
@ -0,0 +1,95 @@
|
|||
describe("basic behavior", () => {
|
||||
test("empty array", () => {
|
||||
var enteredFunction = false;
|
||||
var rejected = false;
|
||||
async function f() {
|
||||
enteredFunction = true;
|
||||
for await (const v of []) {
|
||||
expect().fail("Should not enter loop");
|
||||
}
|
||||
}
|
||||
|
||||
f().then(
|
||||
() => {
|
||||
expect(enteredFunction).toBeTrue();
|
||||
},
|
||||
() => {
|
||||
rejected = true;
|
||||
}
|
||||
);
|
||||
runQueuedPromiseJobs();
|
||||
expect(enteredFunction).toBeTrue();
|
||||
expect(rejected).toBeFalse();
|
||||
});
|
||||
|
||||
test("sync iterator", () => {
|
||||
var loopIterations = 0;
|
||||
var rejected = false;
|
||||
async function f() {
|
||||
for await (const v of [1]) {
|
||||
expect(v).toBe(1);
|
||||
loopIterations++;
|
||||
}
|
||||
}
|
||||
|
||||
f().then(
|
||||
() => {
|
||||
expect(loopIterations).toBe(1);
|
||||
},
|
||||
() => {
|
||||
rejected = true;
|
||||
}
|
||||
);
|
||||
runQueuedPromiseJobs();
|
||||
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", () => {
|
||||
test("async functions", () => {
|
||||
expect("async function foo() { for await (const v of []) return v; }").toEval();
|
||||
expect("(async function () { for await (const v of []) return v; })").toEval();
|
||||
expect("async () => { for await (const v of []) return v; }").toEval();
|
||||
});
|
||||
|
||||
test("regular functions", () => {
|
||||
expect("function foo() { for await (const v of []) return v; }").not.toEval();
|
||||
expect("(function () { for await (const v of []) return v; })").not.toEval();
|
||||
expect("() => { for await (const v of []) return v; }").not.toEval();
|
||||
});
|
||||
|
||||
test("generator functions", () => {
|
||||
expect("function* foo() { for await (const v of []) return v; }").not.toEval();
|
||||
expect("(function* () { for await (const v of []) return v; })").not.toEval();
|
||||
});
|
||||
|
||||
test("async generator functions", () => {
|
||||
expect("async function* foo() { for await (const v of []) yield v; }").toEval();
|
||||
expect("(async function* () { for await (const v of []) yield v; })").toEval();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue