summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-09-08 22:34:29 +0000
committerNicholas Clark <nick@ccl4.org>2007-09-08 22:34:29 +0000
commit6dbe9451abb7e30d650de45d484c69e6c34bbd36 (patch)
tree9ffa248394ec7c0919a7a814e2e1b1a461f0f674 /t
parentaab6a793686b4f073e16b436e1705cd0e9106ced (diff)
downloadperl-6dbe9451abb7e30d650de45d484c69e6c34bbd36.tar.gz
For now, forbid all list assignment initialisation of state variables,
as the precise semantics in Perl 6 are not clear. Better to make it a syntax error, than to have one behaviour now, but change it later. [I believe that this is the consensus. If not, it will be backed out] p4raw-id: //depot/perl@31824
Diffstat (limited to 't')
-rw-r--r--t/op/state.t38
1 files changed, 26 insertions, 12 deletions
diff --git a/t/op/state.t b/t/op/state.t
index 7be16667d3..6d835c466d 100644
--- a/t/op/state.t
+++ b/t/op/state.t
@@ -10,7 +10,7 @@ BEGIN {
use strict;
use feature ":5.10";
-plan tests => 108;
+plan tests => 117;
ok( ! defined state $uninit, q(state vars are undef by default) );
@@ -301,17 +301,6 @@ foreach my $x (0 .. 4) {
#
-# List context reassigns, but scalar doesn't.
-#
-my @swords = qw [Stormbringer Szczerbiec Grimtooth Corrougue];
-foreach my $sword (@swords) {
- state ($s1) = state $s2 = $sword;
- is $s1, $swords [0], 'mixed context';
- is $s2, $swords [0], 'mixed context';
-}
-
-
-#
# Use with given.
#
my @spam = qw [spam ham bacon beans];
@@ -331,3 +320,28 @@ foreach my $spam (@spam) {
state $x = "two";
is $x, "two", "masked"
}
+
+foreach my $forbidden (<DATA>) {
+ chomp $forbidden;
+ no strict 'vars';
+ eval $forbidden;
+ like $@, qr/Initialization of state variables in list context currently forbidden/, "Currently forbidden: $forbidden";
+}
+__DATA__
+state ($a) = 1;
+(state $a) = 1;
+state @a = 1;
+state (@a) = 1;
+(state @a) = 1;
+state %a = ();
+state (%a) = ();
+(state %a) = ();
+state ($a, $b) = ();
+state ($a, @b) = ();
+(state $a, state $b) = ();
+(state $a, $b) = ();
+(state $a, my $b) = ();
+(state $a, state @b) = ();
+(state $a, local @b) = ();
+(state $a, undef, state $b) = ();
+state ($a, undef, $b) = ();