Permalink
Browse files

S04-declatations/state: test two niecza regressions, fix \(state $) test

  • Loading branch information...
1 parent 8cc349a commit 9055b810c5554a51874f93c9ce50f453f2e3a8c1 @sorear sorear committed Jul 12, 2011
Showing with 8 additions and 6 deletions.
  1. +8 −6 S04-declarations/state.t
View
@@ -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>
@@ -134,7 +134,6 @@ plan 38;
# Return of a reference to a state() var
#?rakudo skip 'references'
-#?niecza skip '\\'
{
my $gen = {
state $svar = 42;
@@ -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
@@ -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'
@@ -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.