From 7d82b1885b6edb0b0c5f78e74328d3bc0c0e8524 Mon Sep 17 00:00:00 2001 From: moritz Date: Tue, 9 Sep 2008 08:13:26 +0000 Subject: [PATCH] [t] moved check.t to spec/, simplified a bit git-svn-id: http://svn.pugscode.org/pugs@22193 c213334d-75ef-0310-aa23-eaa082d1ae64 --- S04-closure-traits/check.t | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 S04-closure-traits/check.t diff --git a/S04-closure-traits/check.t b/S04-closure-traits/check.t new file mode 100644 index 0000000000..b4cb0d19ec --- /dev/null +++ b/S04-closure-traits/check.t @@ -0,0 +1,35 @@ +use v6; + +use Test; + +plan 5; + +# L +# 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'; +}