mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
LibJS: Move tests to /Tests/LibJS
This commit is contained in:
committed by
Tim Flynn
parent
c059c6a2f5
commit
e3faa9b5ad
Notes:
github-actions[bot]
2026-02-06 11:17:48 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/e3faa9b5add Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7572 Reviewed-by: https://github.com/trflynn89 ✅
69
Tests/LibJS/Runtime/syntax/switch-as-statement.js
Normal file
69
Tests/LibJS/Runtime/syntax/switch-as-statement.js
Normal file
@@ -0,0 +1,69 @@
|
||||
describe("switch statement is a valid statement and gets executed", () => {
|
||||
test("switch statement in a block", () => {
|
||||
let hit = false;
|
||||
{
|
||||
switch (true) {
|
||||
case true:
|
||||
hit = true;
|
||||
}
|
||||
expect(hit).toBeTrue();
|
||||
}
|
||||
});
|
||||
|
||||
test("switch statement in an if statement when true", () => {
|
||||
let hit = false;
|
||||
var a = true;
|
||||
if (a)
|
||||
switch (true) {
|
||||
case true:
|
||||
hit = true;
|
||||
}
|
||||
else
|
||||
switch (true) {
|
||||
case true:
|
||||
expect().fail();
|
||||
}
|
||||
|
||||
expect(hit).toBeTrue();
|
||||
});
|
||||
|
||||
test("switch statement in an if statement when false", () => {
|
||||
let hit = false;
|
||||
var a = false;
|
||||
if (a)
|
||||
switch (a) {
|
||||
default:
|
||||
expect().fail();
|
||||
}
|
||||
else
|
||||
switch (a) {
|
||||
default:
|
||||
hit = true;
|
||||
}
|
||||
|
||||
expect(hit).toBeTrue();
|
||||
});
|
||||
|
||||
test("switch statement in an while statement", () => {
|
||||
var a = 0;
|
||||
var loops = 0;
|
||||
while (a < 1 && loops++ < 5)
|
||||
switch (a) {
|
||||
case 0:
|
||||
a = 1;
|
||||
}
|
||||
|
||||
expect(a).toBe(1);
|
||||
});
|
||||
|
||||
test("switch statement in an for statement", () => {
|
||||
var loops = 0;
|
||||
for (let a = 0; a < 1 && loops++ < 5; )
|
||||
switch (a) {
|
||||
case 0:
|
||||
a = 1;
|
||||
}
|
||||
|
||||
expect(loops).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user