Espruino/tests/test_switch_control.js
Gordon Williams af58af1132 Fix recent regression in switch handling caused by Strings only being interpreted when executing
Seems to have been made visible with 8cbcbefdca99e43307224086c83fb54f48a9bb25 not storing the string in a buffer
2023-06-09 14:48:41 +01:00

62 lines
1019 B
JavaScript

//https://github.com/espruino/Espruino/issues/2339
(() => {
let i = 0;
while (i < 1) {
console.log("i=", i);
i++;
switch (i) {
case 1:
continue; // this is crashing
}
}
})();
(() => {
let i = 0;
for (let i = 0; i < 1; i++) {
console.log("i=", i);
switch (i) {
case 0:
continue; // this is crashing
}
}
})();
(() => {
let i = 0;
while (i < 1) {
console.log("i=", i);
i++;
switch (i) {
default:
continue;
}
throw new Error("this should never be logged"); // this is still being logged in espruino
}
})();
(() => {
let i = 0;
for (let i = 0; i < 1; i++) {
console.log("i=", i);
switch (i) {
default:
continue;
}
throw new Error("this should never be logged"); // this is still being logged in espruino
}
})();
(() => {
switch ("continue") {
case "continue": print("Correct");break;
default: throw Error("Not correct");
}
})();
/* if there was a problem earlier, an error
should have occurred and we won't get here */
result = 1;