1
1
use v6 ;
2
2
use Test ;
3
- plan 18 ;
3
+ plan 19 ;
4
4
5
- # L<S04/The Relationship of Blocks and Declarations/A bare closure
6
- # (except the block associated with a conditional statement)>
5
+ # L<S04/The Relationship of Blocks and Declarations/A bare closure
6
+ # (except the block associated with a conditional statement)>
7
7
8
8
{
9
9
# test with explicit $_
@@ -19,7 +19,7 @@ plan 18;
19
19
20
20
{
21
21
# { } has implicit signature ($_ is rw = $OUTER::_)
22
-
22
+
23
23
$ _ = ' Hello' ;
24
24
is (try { { $ _ }. () }, ' Hello' , ' $_ in bare block defaults to outer' );
25
25
is ({ $ _ }. (' Goodbye' ), ' Goodbye' , ' but it is only a default' );
@@ -33,15 +33,14 @@ plan 18;
33
33
}
34
34
35
35
{
36
- $ _ = ' Ack' ;
36
+ $ _ = ' Ack! ' ;
37
37
dies_ok({ (-> { " Boo!" }). (42 ) }, ' -> {} is arity 0' );
38
38
dies_ok({ (-> { $ _ }). (42 ) }, ' Even when we use $_>' );
39
-
40
- # ?rakudo 2 todo 'pointy blocks and $_'
39
+
41
40
# ?niecza todo
42
41
is ((-> { $ _ }). (), ' Ack!' , ' $_ is lexical here' );
43
42
# ?niecza todo
44
- is (-> $ a { $ _ }. (42 ), ' Ack!' , ' Even with parameters (?) ' );
43
+ is (-> $ a { $ _ }. (42 ), ' Ack!' , ' Even with parameters' );
45
44
is (-> $ _ { $ _ }. (42 ), 42 , ' But not when the parameter is $_' );
46
45
47
46
eval_dies_ok( ' sub () { -> { $^a }.() }' , ' Placeholders not allowed in ->' );
@@ -53,4 +52,15 @@ plan 18;
53
52
eval_dies_ok(' sub () { $^foo }.(42)' , ' Placeholders not allowed in sub()' );
54
53
}
55
54
55
+ # RT #114696
56
+ {
57
+ my $ string ;
58
+ $ _ = ' Moo' ;
59
+ for . chars ... 1 -> $ len {
60
+ $ string ~ = $ _ ;
61
+ { $ string ~ = $ _ ; }
62
+ }
63
+ is $ string , ' MooMooMooMooMooMoo' , ' outer $_ is seen within nested blocks' ;
64
+ }
65
+
56
66
# vim: ft=perl6
0 commit comments