summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-03 22:49:14 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-03 22:49:14 +0000
commitaa2c63737286632915551d619f384bdece155a3f (patch)
tree6ef81f5ceea23c1b0ac6b2c2eeff37421b4e1c25 /t
parent5d1e1362bca3ef5bc255eeeafbbd67ab16a83104 (diff)
downloadperl-aa2c63737286632915551d619f384bdece155a3f.tar.gz
Ensure that C<(state $x) = $y> is not a state assignment
(due to the parentheses that make it a regular assignment to a variable declared inside a list) p4raw-id: //depot/perl@28089
Diffstat (limited to 't')
-rw-r--r--t/op/state.t10
1 files changed, 9 insertions, 1 deletions
diff --git a/t/op/state.t b/t/op/state.t
index 260fa8bf38..6da247874e 100644
--- a/t/op/state.t
+++ b/t/op/state.t
@@ -9,7 +9,7 @@ BEGIN {
use strict;
use feature "state";
-plan tests => 23;
+plan tests => 25;
ok( ! defined state $uninit, q(state vars are undef by default) );
@@ -77,3 +77,11 @@ is( $f2->(), 2, 'generator 2 once more' );
::is( foo(), 20, "increments correctly, twice" );
::is( $fetchcount, 1, "fetch only called once" );
}
+
+sub stateless {
+ # stateless assignment
+ (state $reinitme) = 42;
+ ++$reinitme;
+}
+is( stateless(), 43, 'stateless function, first time' );
+is( stateless(), 43, 'stateless function, second time' );