Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] finish implementing pasttype while; implement until, repeat_…
…while, repeat_until; add 14-while.t (all pass); add 05-comments.t b/c it passes.
- Loading branch information
Showing
3 changed files
with
216 additions
and
5 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
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,57 @@ | ||
#! nqp | ||
|
||
# check comments | ||
|
||
say('1..8'); | ||
|
||
#Comment preceding | ||
say("ok 1"); | ||
|
||
say("ok 2"); #Comment following | ||
|
||
#say("not ok 3"); | ||
# say("not ok 4"); | ||
|
||
{ say('ok 3'); } # comment | ||
{ say('ok 4'); } | ||
|
||
=for comment | ||
say("not ok 5"); | ||
=for comment say("not ok 6"); | ||
=begin comment | ||
say("not ok 7"); | ||
say("not ok 8"); | ||
=end comment | ||
|
||
=comment say("not ok 9"); | ||
say("not ok 10"); | ||
=for comment blah | ||
say("ok 5"); | ||
|
||
=begin comment | ||
=end comment | ||
say("ok 6"); | ||
|
||
# This doesn't quite work right... but it doesn't work in STD either | ||
#=for comment | ||
#=begin comment | ||
#=end comment | ||
#=say("ok 7"); | ||
|
||
=comment | ||
|
||
say("ok 7"); | ||
|
||
=begin comment indented pod | ||
this is indented pod | ||
say("not ok 8"); | ||
=end comment | ||
|
||
say("ok 8"); | ||
|
||
|
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,104 @@ | ||
#!./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'); | ||
|
||
$sum := 0; | ||
$sum := $sum + 1 while $sum < 45; | ||
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'); | ||
|
||
$sum := 0; | ||
$sum := $sum + 1 until $sum > 44; | ||
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'); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|