From 872fcb0827582624bb8767608f285e6bf638efd2 Mon Sep 17 00:00:00 2001 From: Matthew Horsfall Date: Fri, 31 Jan 2014 16:52:04 -0500 Subject: [PATCH] Test state vars following padranges [Perl #121134] --- t/op/state.t | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/op/state.t b/t/op/state.t index ad51d8b..b4542e1 100644 --- a/t/op/state.t +++ b/t/op/state.t @@ -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 () { 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; -- 2.7.4