Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[t] moved check.t to spec/, simplified a bit
git-svn-id: http://svn.pugscode.org/pugs@22193 c213334d-75ef-0310-aa23-eaa082d1ae64
- Loading branch information
moritz
committed
Sep 9, 2008
1 parent
04abb4f
commit 7d82b18
Showing
1 changed file
with
35 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,35 @@ | ||
use v6; | ||
|
||
use Test; | ||
|
||
plan 5; | ||
|
||
# L<S04/"Closure traits"/CHECK "at compile time" ALAP> | ||
# CHECK {...} block in "void" context | ||
{ | ||
my $str = ''; | ||
BEGIN { $str ~= "begin1 "; } | ||
CHECK { $str ~= "check "; } | ||
BEGIN { $str ~= "begin2 "; } | ||
|
||
is $str, "begin1 begin2 check ", "check blocks run after begin blocks"; | ||
} | ||
|
||
{ | ||
my $str = ''; | ||
CHECK { $str ~= "check1 "; } | ||
BEGIN { $str ~= "begin "; } | ||
CHECK { $str ~= "check2 "; } | ||
|
||
is $str, "begin check2 check1 ", "check blocks run in reverse order"; | ||
} | ||
|
||
# CHECK {...} blocks as rvalues | ||
{ | ||
my $str = ''; | ||
my $handle = { my $retval = CHECK { $str ~= 'C' } }; | ||
|
||
is $handle(), 'C', 'our CHECK {...} block returned the correct var (1)'; | ||
is $handle(), 'C', 'our CHECK {...} block returned the correct var (2)'; | ||
is $str, 'C', 'our rvalue CHECK {...} block was executed exactly once'; | ||
} |