Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from MoeOrganization/prakashk/unless+modifiers
unless statement and statement modifiers
- Loading branch information
Showing
13 changed files
with
215 additions
and
79 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
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
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
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
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
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,45 @@ | ||
use Test::More; | ||
|
||
{ | ||
my $r = eval("unless (false) { 10 }"); | ||
ok(not($!.defined), '... the statement worked correctly'); | ||
is($r, 10, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval("unless (true) { 10 } else { 20 }"); | ||
ok(not($!.defined), '... the statement worked correctly'); | ||
is($r, 20, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval("unless (false) { 10 } elsif (true) { 20 }"); | ||
ok(not($!.defined), '... the statement worked correctly'); | ||
is($r, 10, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval("unless (true) { 10 } elsif (true) { 20 }"); | ||
ok(not($!.defined), '... the statement worked correctly'); | ||
is($r, 20, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval("unless (true) { 10 } elsif (false) { 20 } else { 30 }"); | ||
ok(not($!.defined), '... the statement worked correctly'); | ||
is($r, 30, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval("10 unless false"); | ||
ok(not($!.defined), '... the modifier statement worked correctly'); | ||
is($r, 10, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval("my $a = 0; $a = $a + 1 unless $a > 0; $a"); | ||
ok(not($!.defined), '... the modifier statement worked correctly'); | ||
is($r, 1, '... got the expected value'); | ||
} | ||
|
||
done_testing(); |
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,25 @@ | ||
use Test::More; | ||
|
||
{ | ||
my $r = eval( | ||
"my $x = 0;" ~ | ||
"while ($x < 10) {" ~ | ||
" $x = $x + 1;" ~ | ||
"}" ~ | ||
"$x" | ||
); | ||
ok(not($!.defined), '... the statement worked correctly'); | ||
is($r, 10, '... got the expected value'); | ||
} | ||
|
||
{ | ||
my $r = eval( | ||
"my $a = 0;" ~ | ||
"$a = $a + 1 while $a < 5;" ~ | ||
"$a" | ||
); | ||
ok(not($!.defined), '... the modifier statement worked correctly'); | ||
is($r, 5, '... got the expected value'); | ||
} | ||
|
||
done_testing(); |
Oops, something went wrong.