Skip to content

Commit 77be933

Browse files
committed
Add test for phasers in loops + recursion.
1 parent b7c19a8 commit 77be933

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

S04-phasers/in-loop.t

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 8;
5+
plan 11;
66

77
# TODO, based on synopsis 4:
88
#
@@ -124,4 +124,23 @@ plan 8;
124124
is rt126001_b(), 2, 'LAST phaser without block does not put Mu in the iteration variable';
125125
}
126126

127+
{
128+
my (@first, @next, @last);
129+
sub foo($a) {
130+
for ^$a {
131+
FIRST @first.push($a);
132+
NEXT @next.push($a);
133+
LAST @last.push($a);
134+
foo($a - 1)
135+
}
136+
}
137+
foo(3);
138+
is @first, [3, 2, 1, 1, 2, 1, 1, 2, 1, 1],
139+
'FIRST in loop works fine with recursion';
140+
is @next, [1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3],
141+
'NEXT in loop works fine with recursion';
142+
is @last, [1, 1, 2, 1, 1, 2, 1, 1, 2, 3],
143+
'LAST in loop works fine with recursion';
144+
}
145+
127146
# vim: ft=perl6

0 commit comments

Comments
 (0)