Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[t/spec] State/cloned closure interaction tests; based of bug report …

…from masak++.

git-svn-id: http://svn.pugscode.org/pugs@25870 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 1b4a67a708494f30f9864974daad171f4178574b 1 parent 91d82c5
jnthn authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 S04-declarations/state.t
View
12 S04-declarations/state.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 20;
+plan 23;
# L<S04/The Relationship of Blocks and Declarations/There is a new state declarator that introduces>
@@ -159,6 +159,16 @@ plan 20;
}
}
+# state with multiple explicit calls to clone - a little bit subtle
+{
+ my $i = 0;
+ my $func = { state $x = $i++; $x };
+ my ($a, $b) = $func.clone, $func.clone;
+ is $a(), 0, 'state was initialized correctly for clone 1';
+ is $b(), 1, 'state was initialized correctly for clone 2';
+ is $a(), 0, 'state between clones is independent';
+}
+
# recursive state with list assignment initialization happens only first time
#?rakudo skip 'recurses infinitely'
{
Please sign in to comment.
Something went wrong with that request. Please try again.