-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keywords 'break' & 'continue' tested
There were a couple bugs - I'm glad I'm so thorough with these tests. See #152
- Loading branch information
1 parent
b84a70c
commit 23eb3e4
Showing
4 changed files
with
181 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,100 @@ | ||
//make sure it works with multiple repititions | ||
|
||
//------------------------- | ||
|
||
//test break | ||
while (true) { | ||
print "1"; | ||
break; | ||
print "2"; | ||
assert false, "break failed"; | ||
} | ||
|
||
print "3"; | ||
//test continue | ||
var flag1: bool = true; | ||
while (flag1) { | ||
flag1 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
|
||
//------------------------- | ||
|
||
//test break | ||
while (true) { | ||
print 1; | ||
while (true) { | ||
print 2; | ||
if (true) { | ||
print 3; | ||
while (true) { | ||
print 4; | ||
break; | ||
print 5; | ||
} | ||
print 6; | ||
} | ||
print 7; | ||
} | ||
print 8; | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
print 9; | ||
//test continue | ||
var flag2: bool = true; | ||
while (flag2) { | ||
flag2 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
|
||
//------------------------- | ||
|
||
//test break | ||
while (true) { | ||
print 1; | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag3: bool = true; | ||
while (flag3) { | ||
flag3 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
|
||
//------------------------- | ||
|
||
{ | ||
//test break | ||
while (true) { | ||
print 2; | ||
if (true) { | ||
print 3; | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag4: bool = true; | ||
while (flag4) { | ||
flag4 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
} | ||
|
||
//------------------------- | ||
|
||
{ | ||
//test break | ||
while (true) { | ||
{ | ||
break; | ||
print 6; | ||
} | ||
print 7; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag5: bool = true; | ||
while (flag5) { | ||
flag5 = false; | ||
{ | ||
continue; | ||
} | ||
assert false, "continue failed"; | ||
} | ||
print 8; | ||
|
||
print "done"; | ||
} | ||
|
||
print 9; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
tests/integrations/test_keyword_while_break_continue.toy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
//make sure it works with multiple repititions | ||
|
||
//------------------------- | ||
|
||
//test break | ||
while (true) { | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag1: bool = true; | ||
while (flag1) { | ||
flag1 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
|
||
//------------------------- | ||
|
||
//test break | ||
while (true) { | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag2: bool = true; | ||
while (flag2) { | ||
flag2 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
|
||
//------------------------- | ||
|
||
//test break | ||
while (true) { | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag3: bool = true; | ||
while (flag3) { | ||
flag3 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
|
||
//------------------------- | ||
|
||
{ | ||
//test break | ||
while (true) { | ||
break; | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag4: bool = true; | ||
while (flag4) { | ||
flag4 = false; | ||
continue; | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
} | ||
|
||
//------------------------- | ||
|
||
{ | ||
//test break | ||
while (true) { | ||
{ | ||
break; | ||
} | ||
assert false, "break failed"; | ||
} | ||
|
||
//test continue | ||
var flag5: bool = true; | ||
while (flag5) { | ||
flag5 = false; | ||
{ | ||
continue; | ||
} | ||
assert false, "continue failed"; | ||
} | ||
|
||
print "done"; | ||
} | ||
|