mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibJS: Integrate labels into the Interpreter
The interpreter now considers a statement or block's label when considering whether or not to break. All statements can be labelled.
This commit is contained in:
parent
03615a7872
commit
d52ea37717
6 changed files with 87 additions and 21 deletions
|
@ -1,12 +1,42 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
test:
|
||||
{
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue