File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,8 @@ This tests the &?BLOCK magical from Synopsis 6
10
10
11
11
# L<S06/The C<&?BLOCK> object>
12
12
13
- plan 1 ;
13
+ plan 3 ;
14
14
15
- # ?rakudo skip '&?BLOCK NYI RT #125131'
16
15
{
17
16
# L<S02/Names/Which block am I in?>
18
17
# L<S06/The C<&?BLOCK> object/tail-recursion on an anonymous block:>
@@ -21,4 +20,19 @@ my $anonfactorial = -> Int $n { $n < 2 ?? 1 !! $n * &?BLOCK($n-1) };
21
20
my $ result = $ anonfactorial (3 );
22
21
is ($ result , 6 , ' the &?BLOCK magical worked' );
23
22
}
23
+
24
+ {
25
+ my @ collected ;
26
+ sub foo ($ a ) {
27
+ -> $ n {
28
+ @ collected . push ($ a );
29
+ $ n == 1 ?? 1 !! $ n * & ? BLOCK ($ n - 1 )
30
+ }
31
+ }
32
+ my $ b1 = foo(' a' );
33
+ my $ b2 = foo(' b' );
34
+ is $ b1 (4 ), 24 , ' Correct result from function generator returning function using &?BLOCK' ;
35
+ is @ collected . join (' ' ), ' aaaa' , ' Correct closure semantics with &?BLOCK' ;
36
+ }
37
+
24
38
# vim: ft=perl6
You can’t perform that action at this time.
0 commit comments