-
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"stderr": [ | ||
"TS1116: A 'break' statement can only jump to a label of an enclosing statement", | ||
"TS1114: Duplicate label 'duplicate'.", | ||
"TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.", | ||
"TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.", | ||
"TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.", | ||
"EOF" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
break nonexistent; | ||
Check failure on line 2 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 2 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 2 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
|
||
} | ||
|
||
duplicate: | ||
Check failure on line 5 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 5 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 5 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
|
||
{ | ||
duplicate: {} | ||
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
Check failure on line 7 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node lts/*)
|
||
} | ||
|
||
for (let i = 0; i < 3; i++) { | ||
continue nonexistent; | ||
Check failure on line 11 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 11 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 11 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
|
||
} | ||
|
||
labelA: | ||
{ | ||
continue labelA; | ||
Check failure on line 16 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 16 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 16 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
|
||
} | ||
|
||
labelB: | ||
switch (0) { | ||
case 0: continue labelB; | ||
Check failure on line 21 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 21 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 21 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
|
||
} | ||
|
||
ERROR("EOF") | ||
Check failure on line 24 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node lts/*)
Check failure on line 24 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (macos, node current)
Check failure on line 24 in tests/compiler/labeled-break-continue-errors.ts GitHub Actions / Compiler (ubuntu, node current)
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
function tests(): string[] { | ||
const results: string[] = []; | ||
|
||
label: | ||
for (let i = 0; i < 6; i++) { | ||
if (i == 2) { | ||
results.push("continue!"); | ||
continue label; | ||
} | ||
|
||
if (i == 4) { | ||
results.push("break!"); | ||
break label; | ||
} | ||
|
||
results.push(`first loop ${i}`); | ||
} | ||
|
||
sweetch: | ||
switch (1) { | ||
case 1: | ||
for (let i = 0; i < 6; i++) { | ||
results.push(`second ${i}`); | ||
if (i == 3) break sweetch; | ||
} | ||
results.push("skipped"); | ||
} | ||
|
||
escape: | ||
{ | ||
results.push("hi"); | ||
break escape; | ||
results.push("skipped"); | ||
} | ||
|
||
outer: | ||
for (let i = 0; i < 5; i++) { | ||
exit: | ||
if (i % 2 == 0) { | ||
for (let j = 0; j < 4; j++) { | ||
if (i == j) continue outer; | ||
else if (j > i) break exit; | ||
|
||
results.push(`did ${i} ${j}`); | ||
} | ||
} | ||
|
||
results.push(`reached end of ${i}`); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
const results = tests(); | ||
const expected = [ | ||
"first loop 0", | ||
"first loop 1", | ||
"continue!", | ||
"first loop 3", | ||
"break!", | ||
"second 0", | ||
"second 1", | ||
"second 2", | ||
"second 3", | ||
"hi", | ||
"reached end of 1", | ||
"did 2 0", | ||
"did 2 1", | ||
"reached end of 3", | ||
"did 4 0", | ||
"did 4 1", | ||
"did 4 2", | ||
"did 4 3", | ||
"reached end of 4" | ||
]; | ||
|
||
assert(results.length == expected.length); | ||
for (let i = 0; i < expected.length; i++) assert(results[i] == expected[i]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
labelA: | ||
{ | ||
a; | ||
b; | ||
} | ||
|
||
labelB: | ||
for (let i = 0; i < 3; i++) {} | ||
|
||
labelC: | ||
for (const x of y) {} | ||
|
||
labelD: | ||
do {} while (0) | ||
|
||
labelE: | ||
while (0) {} | ||
|
||
labelF: | ||
try {} catch (e) {} | ||
|
||
labelG: | ||
if (0) {} else {} | ||
|
||
labelH: // ERROR 1344: "A label is not allowed here." | ||
let x = 123; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
labelA: | ||
{ | ||
a; | ||
b; | ||
} | ||
labelB: | ||
for (let i = 0; i < 3; i++) {} | ||
labelC: | ||
for (const x of y) {} | ||
labelD: | ||
do {} while (0); | ||
labelE: | ||
while (0) {} | ||
labelF: | ||
try { | ||
} catch (e) { | ||
} | ||
labelG: | ||
if (0) {} else {} | ||
let x = 123; | ||
// ERROR 1344: "A label is not allowed here." in labels.ts(25,1+6) |