mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +00:00
The interpreter now considers a statement or block's label when considering whether or not to break. All statements can be labelled.
43 lines
743 B
JavaScript
43 lines
743 B
JavaScript
load("test-common.js");
|
|
|
|
try {
|
|
test: {
|
|
let o = 1;
|
|
assert(o === 1);
|
|
break test;
|
|
assertNotReached();
|
|
}
|
|
|
|
outer: {
|
|
{
|
|
break outer;
|
|
}
|
|
assertNotReached();
|
|
}
|
|
|
|
let counter = 0;
|
|
outer:
|
|
for (a of [1, 2, 3]) {
|
|
for (b of [4, 5, 6]) {
|
|
if (a === 2 && b === 5)
|
|
break outer;
|
|
counter++;
|
|
}
|
|
}
|
|
assert(counter === 4);
|
|
|
|
let counter = 0;
|
|
outer:
|
|
for (a of [1, 2, 3]) {
|
|
for (b of [4, 5, 6]) {
|
|
if (b === 6)
|
|
continue outer;
|
|
counter++;
|
|
}
|
|
}
|
|
assert(counter === 6);
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|