Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Two more passing test files.
- Loading branch information
Showing
2 changed files
with
146 additions
and
0 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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| #!./parrot nqp.pbc | ||
|
|
||
| # while, until statements | ||
|
|
||
| plan(14); | ||
|
|
||
| my $a; my $sum; | ||
|
|
||
| $a := 1; $sum := 0; | ||
| while $a != 10 { | ||
| $sum := $sum + $a; | ||
| $a := $a + 1; | ||
| } | ||
| ok($sum == 45, 'basic while loop test'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| $sum := $sum + $a++ while $a < 10; | ||
| ok($sum == 45, 'basic while statement modifier'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| until $a == 10 { | ||
| $sum := $sum + $a; | ||
| $a := $a + 1; | ||
| } | ||
| ok($sum == 45, 'basic until loop test'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| $sum := $sum + $a++ until $a > 9; | ||
| ok($sum == 45, 'basic until statement modifier'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| while $a != 1 { | ||
| $sum := 99; | ||
| $a := 1; | ||
| } | ||
| ok($sum == 0, 'while loop exits initial false immediately'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| until $a == 1 { | ||
| $sum := 99; | ||
| $a := 1; | ||
| } | ||
| ok($sum == 0, 'until loop exits initial true immediately'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat { | ||
| $sum := $sum + $a; | ||
| $a := $a + 1; | ||
| } while $a != 10; | ||
| ok($sum == 45, 'basic repeat_while loop'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat { | ||
| $sum := $sum + $a; | ||
| $a := $a + 1; | ||
| } until $a == 10; | ||
| ok($sum == 45, 'basic repeat_until loop'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat while $a != 10 { | ||
| $sum := $sum + $a; | ||
| $a := $a + 1; | ||
| }; | ||
| ok($sum == 45, 'basic repeat_while loop'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat until $a == 10 { | ||
| $sum := $sum + $a; | ||
| $a := $a + 1; | ||
| }; | ||
| ok($sum == 45, 'basic repeat_until loop'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat { | ||
| $sum := 99; | ||
| } while $a != 1; | ||
| ok($sum == 99, 'repeat_while always executes at least once'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat { | ||
| $sum := 99; | ||
| } until $a == 1; | ||
| ok($sum == 99, 'repeat_until always executes at least once'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat while $a != 1 { | ||
| $sum := 99; | ||
| }; | ||
| ok($sum == 99, 'repeat_while always executes at least once'); | ||
|
|
||
| $a := 1; $sum := 0; | ||
| repeat until $a == 1 { | ||
| $sum := 99; | ||
| }; | ||
| ok($sum == 99, 'repeat_until always executes at least once'); | ||
|
|
||
|
|
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,49 @@ | ||
| #!./parrot nqp.pbc | ||
|
|
||
| # combination of conditional modifier and loop modifier | ||
|
|
||
| plan(11); | ||
|
|
||
| my $a; my $s; | ||
|
|
||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 if $a > 7 while $a++ < 9; | ||
| ok( $s == 5 && $a == 10, 'true if + while'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 if $a > 17 while $a++ < 9; | ||
| ok( $s == 0 && $a == 10, 'false if + while'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 if $a > 7 until $a++ > 9; | ||
| ok( $s == 5 && $a == 11, 'true if + until'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 if $a > 17 until $a++ > 9; | ||
| ok( $s == 0 && $a == 11, 'false if + until'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 unless $a > 0 while $a++ < 9; | ||
| ok( $s == 0 && $a == 10, 'true unless + while'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 unless $a < 0 while $a++ < 9; | ||
| ok( $s == 5 && $a == 10, 'false unless + while'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 if $a > 0 until $a++ > 9; | ||
| ok( $s == 5 && $a == 11, 'true if + until'); | ||
|
|
||
| $a := 0; $s := 0; | ||
| $s := 5 if $a < 0 until $a++ > 9; | ||
| ok( $s == 0 && $a == 11, 'false if + until'); | ||
|
|
||
| # Ensure that close curly can end a statement | ||
| { ok(1, "correct parse"); $a := 10; } | ||
| while $a == 10 { ok($a == 10, 'while still works'); $a++; } | ||
|
|
||
| $a := 1; | ||
| $a := $a * $_ for <1 2 3>; | ||
| ok( $a == 6 , 'for'); | ||
|
|