break-continue-errors.js (1074B)
1 load(libdir + "asserts.js"); 2 3 function test(s, expected) { 4 assertErrorMessage(() => Function(s), SyntaxError, expected); 5 } 6 7 test("A: continue;", "continue must be inside loop"); 8 test("A: continue B;", "continue must be inside loop"); 9 test("A: if (false) { continue; }", "continue must be inside loop"); 10 test("A: if (false) { continue B; }", "continue must be inside loop"); 11 test("while (false) { (() => { continue B; })(); }", "continue must be inside loop"); 12 test("B: while (false) { (() => { continue B; })(); }", "continue must be inside loop"); 13 14 test("do { continue B; } while (false);", "label not found"); 15 test("A: for (;;) { continue B; }", "label not found"); 16 test("A: while (false) { if (x) { continue B; } }", "label not found"); 17 test("A: while (false) { B: if (x) { continue B; } }", "label not found"); 18 19 test("A: if (false) { break B; }", "label not found"); 20 test("A: while (false) { break B; }", "label not found"); 21 test("A: while (true) { if (x) { break B; } }", "label not found"); 22 test("B: while (false) { (() => { break B; })(); }", "label not found");