Skip to content

Commit e1540b7

Browse files
committed
Test anonymous state variables.
1 parent 82f5bc3 commit e1540b7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

S04-declarations/state.t

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

33
use Test;
44

5-
plan 42;
5+
plan 44;
66

77
# L<S04/The Relationship of Blocks and Declarations/There is a new state declarator that introduces>
88

@@ -328,4 +328,11 @@ eval_lives_ok 'state $x; $x', 'state outside control structure';
328328
is r(), '7 40', 'state vars and list assignment mixes';
329329
}
330330

331+
{
332+
my $x = 1;
333+
sub foo() { state $ = $x++ };
334+
is foo(), 1, 'anonymous state variable (1)';
335+
is foo(), 1, 'anonymous state variable (2)';
336+
}
337+
331338
# vim: ft=perl6

0 commit comments

Comments
 (0)