ladybird/Libraries/LibJS/Tests/break-continue-syntax-errors.js
Matthew Olsson e49ea1b520 LibJS: Disallow 'continue' & 'break' outside of their respective scopes
'continue' is no longer allowed outside of a loop, and an unlabeled
'break' is not longer allowed outside of a loop or switch statement.
Labeled 'break' statements are still allowed everywhere, even if the
label does not exist.
2020-10-08 10:20:49 +02:00

18 lines
645 B
JavaScript

test("'break' syntax errors", () => {
expect("break").not.toEval();
expect("break label").not.toEval();
expect("{ break }").not.toEval();
// FIXME: Parser does not throw error on nonexistent label
// expect("{ break label }.not.toEval();
expect("label: { break label }").toEval();
});
test("'continue' syntax errors", () => {
expect("continue").not.toEval();
expect("continue label").not.toEval();
expect("{ continue }").not.toEval();
expect("{ continue label }").not.toEval();
expect("label: { continue label }").not.toEval();
expect("switch (true) { case true: continue; }").not.toEval();
});