From: Rafael Garcia-Suarez Date: Wed, 3 May 2006 22:49:14 +0000 (+0000) Subject: Ensure that C<(state $x) = $y> is not a state assignment X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa2c63737286632915551d619f384bdece155a3f;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/t/op/state.t b/t/op/state.t index 260fa8b..6da2478 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' );