Permalink
Browse files

[t/spec] Test difference between state @foo = @bar and (state @foo) = @…

…bar. Test submitted by nicholas++.

git-svn-id: http://svn.pugscode.org/pugs@25872 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent be90935 commit 0eaa0ad324a7eaa41f044b31674a25679c47d6b4 jnthn committed Mar 17, 2009
Showing with 14 additions and 1 deletion.
  1. +14 −1 S04-declarations/state.t
View
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 28;
+plan 30;
# L<S04/The Relationship of Blocks and Declarations/There is a new state declarator that introduces>
@@ -76,6 +76,19 @@ plan 28;
is swatest2(), '[2, 2, 3]', 'array state retained between calls';
}
+# (state @foo) = @bar differs from state @foo = @bar
+{
+ my @bar = 1,2,3;
+ sub swatest3 {
+ (state @foo) = @bar;
+ my $x = @foo.perl;
+ @foo[0]++;
+ return $x
+ }
+ is swatest3(), '[1, 2, 3]', '(state @foo) = @bar is not state @foo = @bar';
+ is swatest3(), '[1, 2, 3]', '(state @foo) = @bar is not state @foo = @bar';
+}
+
# RHS of state is only run once per init
{
my $rhs_calls = 0;

0 comments on commit 0eaa0ad

Please sign in to comment.