summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2007-09-09 19:51:50 +0000
committerDave Mitchell <davem@fdisolutions.com>2007-09-09 19:51:50 +0000
commita74073ad6436c46fca5196ffa4ea01684b55afc4 (patch)
tree1a7ba237b7c773bd3173c7b167bcbabd984a8bb3 /t/op
parentbbe8372978680ed3788dc9752a23b00b0bca8736 (diff)
downloadperl-a74073ad6436c46fca5196ffa4ea01684b55afc4.tar.gz
state variables shouldn't be shared between anon subs
p4raw-id: //depot/perl@31833
Diffstat (limited to 't/op')
-rw-r--r--t/op/state.t14
1 files changed, 13 insertions, 1 deletions
diff --git a/t/op/state.t b/t/op/state.t
index 6d835c466d..c372bf6e12 100644
--- a/t/op/state.t
+++ b/t/op/state.t
@@ -10,7 +10,7 @@ BEGIN {
use strict;
use feature ":5.10";
-plan tests => 117;
+plan tests => 119;
ok( ! defined state $uninit, q(state vars are undef by default) );
@@ -321,6 +321,18 @@ foreach my $spam (@spam) {
is $x, "two", "masked"
}
+# normally closureless anon subs share a CV and pad. If the anon sub has a
+# state var, this would mean that it is shared. Check that this doesn't
+# happen
+
+{
+ my @f;
+ push @f, sub { state $x; ++$x } for 1..2;
+ $f[0]->() for 1..10;
+ is $f[0]->(), 11;
+ is $f[1]->(), 1;
+}
+
foreach my $forbidden (<DATA>) {
chomp $forbidden;
no strict 'vars';