Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
S04-declatations/state: test two niecza regressions, fix \(state $) test
  • Loading branch information
sorear committed Jul 12, 2011
1 parent 8cc349a commit 9055b81
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions S04-declarations/state.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 38;
plan 40;

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

Expand Down Expand Up @@ -134,7 +134,6 @@ plan 38;

# Return of a reference to a state() var
#?rakudo skip 'references'
#?niecza skip '\\'
{
my $gen = {
state $svar = 42;
Expand All @@ -151,13 +150,11 @@ plan 38;

# Anonymous state vars
# L<http://groups.google.de/group/perl.perl6.language/msg/07aefb88f5fc8429>
# fudged a bit on syntax
#?pugs todo 'anonymous state vars'
#?rakudo skip 'references and anonymous state vars'
#?niecza skip '\\'
{
# XXX -- currently this is parsed as \&state()
my $gen = eval '{ try { \state } }';
$gen //= sub { my $x; \$x };
my $gen = sub { \(state $ ) };

my $svar_ref = $gen(); # $svar == 0
try { $$svar_ref++; $$svar_ref++ }; # $svar == 2
Expand All @@ -166,6 +163,8 @@ plan 38;
is try { $$svar_ref }, 2, "anonymous state() vars";
}

eval_lives_ok 'if 0 { \(state $) }', '$) not misinterpreted in capterm';

# L<http://www.nntp.perl.org/group/perl.perl6.language/20888>
# ("Re: Declaration and definition of state() vars" from Larry)
#?pugs eval 'Parse error'
Expand Down Expand Up @@ -297,4 +296,7 @@ sub bughunt1 { (state $svar) } #OK not used
'state var in anonymous closure in loop is not shared';
}

# niecza regression: state not working at top level
eval_lives_ok 'state $x; $x', 'state outside control structure';

# vim: ft=perl6

0 comments on commit 9055b81

Please sign in to comment.