This is an automatically generated mail to inform you that tests are now
available in t/spec/S04-phasers/rvalue.t
commit 4e1049963df253c5287810a4c579541fd55f16d6
Author: moritz <mor...@c213334d-75ef-0310-aa23-eaa082d1ae64>
Date: Sat May 8 09:01:01 2010 +0000
[t/spec] simpler tests for BEGIN blocks as expressions; tests RT #62188 and
RT #74836
git-svn-id: http://svn.pugscode.org/p...@30585
c213334d-75ef-0310-aa23-eaa082d1ae64
diff --git a/t/spec/S04-phasers/rvalue.t b/t/spec/S04-phasers/rvalue.t
index 877b069..55ca63a 100644
--- a/t/spec/S04-phasers/rvalue.t
+++ b/t/spec/S04-phasers/rvalue.t
@@ -5,47 +5,74 @@ use v6;
use Test;
-plan 10;
+plan 16;
# L<S04/Phasers/"marked with a *" "used within" expression>
-my $hist = '';
+{
+ my $x = BEGIN { 8 };
+ is $x, 8, 'BEGIN block as expression';
-# Test INIT {} as rval:
+ # test that built-ins are available within a BEGIN block:
+ my $y = BEGIN { ucfirst 'moin' };
+ is $y, 'Moin', 'can access built-in functions in BEGIN blocks';
-my $init_val;
-my $init = {
- $init_val = INIT { $hist ~= 'I' };
+ my $z = BEGIN { 'moin'.ucfirst };
+ is $z, 'Moin', 'can access built-in methods in BEGIN blocks';
}
-is $init(), 'BCI', 'INIT {} runs only once';
-is $init_val, 'BCI', 'INIT {} as rval is its ret val';
-is $init(), 'BCI', 'INIT {} runs only once';
+{
+ my $x = BEGIN 8;
+ is $x, 8, 'BEGIN statement prefix as expression';
-# Test CHECK {} as rval:
+ # test that built-ins are available within a BEGIN block:
+ my $y = BEGIN ucfirst 'moin';
+ is $y, 'Moin', 'can access built-in functions in BEGIN statement prefix';
-my $check_val;
-my $check = {
- $check_val = CHECK { $hist ~= 'C' };
+ my $z = BEGIN 'moin'.ucfirst;
+ is $z, 'Moin', 'can access built-in methods in BEGIN statement prefix';
}
-is $check(), 'BC', 'CHECK {} runs only once';
-is $check_val, 'BC', 'CHECK {} as rval is its ret val';
-is $check(), 'BC', 'CHECK {} runs only once';
+#?rakudo skip 'lexicals in phasers'
+{
+ my $hist = '';
-# Test BEGIN {} as rval:
+ # Test INIT {} as rval:
-my $begin_val;
-my $begin = {
- $begin_val = BEGIN { $hist ~= 'B' };
-}
+ my $init_val;
+ my $init = {
+ $init_val = INIT { $hist ~= 'I' };
+ }
+
+ is $init(), 'BCI', 'INIT {} runs only once';
+ is $init_val, 'BCI', 'INIT {} as rval is its ret val';
+ is $init(), 'BCI', 'INIT {} runs only once';
+
+ # Test CHECK {} as rval:
+
+ my $check_val;
+ my $check = {
+ $check_val = CHECK { $hist ~= 'C' };
+ }
-is $begin(), 'B', 'BEGIN {} runs only once';
-is $begin_val, 'B', 'BEGIN {} as rval is its ret val';
-is $begin(), 'B', 'BEGIN {} runs only once';
+ is $check(), 'BC', 'CHECK {} runs only once';
+ is $check_val, 'BC', 'CHECK {} as rval is its ret val';
+ is $check(), 'BC', 'CHECK {} runs only once';
-# Test END {} as rval:
+ # Test BEGIN {} as rval:
-ok !eval 'my $end_val = END { 3 }', "END {} can't be used as a rvalue";
+ my $begin_val;
+ my $begin = {
+ $begin_val = BEGIN { $hist ~= 'B' };
+ }
+
+ is $begin(), 'B', 'BEGIN {} runs only once';
+ is $begin_val, 'B', 'BEGIN {} as rval is its ret val';
+ is $begin(), 'B', 'BEGIN {} runs only once';
+
+ # Test END {} as rval:
+
+ ok !eval 'my $end_val = END { 3 }', "END {} can't be used as a rvalue";
+}
# vim: ft=perl6