mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Break and continue keywords are working
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
|
||||
|
||||
//test true jump
|
||||
if (true) {
|
||||
assert true, "if-then failed";
|
||||
assert true, "if-then failed (1)";
|
||||
}
|
||||
else {
|
||||
assert false, "if-then failed";
|
||||
assert false, "if-then failed (2)";
|
||||
}
|
||||
|
||||
|
||||
//test false jump
|
||||
if (false) {
|
||||
assert false, "if-then failed";
|
||||
assert false, "if-then failed (3)";
|
||||
}
|
||||
else {
|
||||
assert true, "if-then failed";
|
||||
assert true, "if-then failed (4)";
|
||||
}
|
||||
|
||||
|
||||
@@ -36,4 +34,49 @@ for (var i = 0; i < 20; i = i + 1) {
|
||||
assert forCache == 19, "for-loop failed";
|
||||
|
||||
|
||||
print "All good";
|
||||
//test break - while
|
||||
var breakWhileCache = 0;
|
||||
while(true) {
|
||||
breakWhileCache = breakWhileCache + 1;
|
||||
|
||||
if (breakWhileCache >= 7) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert breakWhileCache == 7, "break-while failed";
|
||||
|
||||
|
||||
//test continue - while
|
||||
var continueWhileCache = 0;
|
||||
while (continueWhileCache < 10) {
|
||||
continueWhileCache = continueWhileCache + 1;
|
||||
|
||||
if (continueWhileCache >= 7) {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert continueWhileCache < 7, "continue-while failed";
|
||||
}
|
||||
|
||||
|
||||
//test break - for
|
||||
for (var i = 0; i < 10; i = i + 1) {
|
||||
if (i >= 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
assert i < 7, "break-for failed";
|
||||
}
|
||||
|
||||
|
||||
//test break - continue
|
||||
for (var i = 0; i < 10; i = i + 1) {
|
||||
if (i >= 7) {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert i < 7, "continue-for failed";
|
||||
}
|
||||
|
||||
print "All good";
|
||||
Reference in New Issue
Block a user