Test state vars following padranges [Perl #121134]
authorMatthew Horsfall <wolfsage@gmail.com>
Fri, 31 Jan 2014 21:52:04 +0000 (16:52 -0500)
committerTony Cook <tony@develop-help.com>
Sun, 2 Feb 2014 23:20:09 +0000 (10:20 +1100)
t/op/state.t

index ad51d8b..b4542e1 100644 (file)
@@ -9,7 +9,7 @@ BEGIN {
 
 use strict;
 
-plan tests => 132;
+plan tests => 136;
 
 # Before loading feature.pm, test it with CORE::
 ok eval 'CORE::state $x = 1;', 'CORE::state outside of feature.pm scope';
@@ -416,6 +416,36 @@ foreach my $forbidden (<DATA>) {
     ok(defined $f, 'state init not skipped');
 }
 
+# [perl #121134] Make sure padrange doesn't mess with these
+{
+    sub thing {
+       my $expect = shift;
+        my ($x, $y);
+        state $z;
+
+        is($z, $expect, "State variable is correct");
+
+        $z = 5;
+    }
+
+    thing(undef);
+    thing(5);
+
+    sub thing2 {
+        my $expect = shift;
+        my $x;
+        my $y;
+        state $z;
+
+        is($z, $expect, "State variable is correct");
+
+        $z = 6;
+    }
+
+    thing2(undef);
+    thing2(6);
+}
+
 
 __DATA__
 state ($a) = 1;