From: Nicholas Clark Date: Tue, 13 Oct 2009 13:33:38 +0000 (+0100) Subject: Move tests for $[ from comp/parser.t to op/array_base.t X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24d0fc42f3cde6d97ff49e299caa014144e156ef;p=p5sagit%2Fp5-mst-13.2.git Move tests for $[ from comp/parser.t to op/array_base.t Tests in t/comp/ are too early to rely on pragmata working. --- diff --git a/MANIFEST b/MANIFEST index 12f267e..4052510 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4311,6 +4311,7 @@ t/op/anonsub.t See if anonymous subroutines work t/op/append.t See if . works t/op/args.t See if operations on @_ work t/op/arith.t See if arithmetic works +t/op/array_base.t Tests for the $[, which is deprecated t/op/array.t See if array operations work t/op/assignwarn.t See if OP= operators warn correctly for undef targets t/op/attrhand.t See if attribute handlers work diff --git a/t/comp/parser.t b/t/comp/parser.t index d0e7f5d..eed0f18 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -3,7 +3,7 @@ # Checks if the parser behaves correctly in edge cases # (including weird syntax errors) -print "1..112\n"; +print "1..104\n"; sub failed { my ($got, $expected, $name) = @_; @@ -195,16 +195,6 @@ EOF like( $@, qr/syntax error/, "use without body" ); } -# Bug #27024 -{ - # this used to segfault (because $[=1 is optimized away to a null block) - my $x; - $[ = 1 while $x; - $test = $test + 1; - print "ok $test\n"; - $[ = 0; # restore the original value for less side-effects -} - # [perl #2738] perl segfautls on input { eval q{ sub _ <> {} }; @@ -217,30 +207,6 @@ EOF like($@, qr/Illegal declaration of subroutine main::_/, "__FILE__ as prototype"); } -# [perl #36313] perl -e "1for$[=0" crash -{ - my $x; - $x = 1 for ($[) = 0; - $test = $test + 1; - print "ok $test - optimized assignment to \$[ used to segfault in list context\n"; - if ($[ = 0) { $x = 1 } - $test = $test + 1; - print "ok $test - optimized assignment to \$[ used to segfault in scalar context\n"; - $x = ($[=2.4); - is($x, 2, 'scalar assignment to $[ behaves like other variables'); - $x = (($[) = 0); - is($x, 1, 'list assignment to $[ behaves like other variables'); - $x = eval q{ ($[, $x) = (0) }; - like($@, qr/That use of \$\[ is unsupported/, - 'cannot assign to $[ in a list'); - eval q{ ($[) = (0, 1) }; - like($@, qr/That use of \$\[ is unsupported/, - 'cannot assign list of >1 elements to $['); - eval q{ ($[) = () }; - like($@, qr/That use of \$\[ is unsupported/, - 'cannot assign list of <1 elements to $['); -} - # tests for "Bad name" eval q{ foo::$bar }; like( $@, qr/Bad name after foo::/, 'Bad name after foo::' ); diff --git a/t/op/array_base.t b/t/op/array_base.t new file mode 100644 index 0000000..9804790 --- /dev/null +++ b/t/op/array_base.t @@ -0,0 +1,38 @@ +#!perl -w +use strict; + +require './test.pl'; + +plan (tests => 8); +no warnings 'deprecated'; + +# Bug #27024 +{ + # this used to segfault (because $[=1 is optimized away to a null block) + my $x; + $[ = 1 while $x; + pass('#27204'); + $[ = 0; # restore the original value for less side-effects +} + +# [perl #36313] perl -e "1for$[=0" crash +{ + my $x; + $x = 1 for ($[) = 0; + pass('optimized assignment to $[ used to segfault in list context'); + if ($[ = 0) { $x = 1 } + pass('optimized assignment to $[ used to segfault in scalar context'); + $x = ($[=2.4); + is($x, 2, 'scalar assignment to $[ behaves like other variables'); + $x = (($[) = 0); + is($x, 1, 'list assignment to $[ behaves like other variables'); + $x = eval q{ ($[, $x) = (0) }; + like($@, qr/That use of \$\[ is unsupported/, + 'cannot assign to $[ in a list'); + eval q{ ($[) = (0, 1) }; + like($@, qr/That use of \$\[ is unsupported/, + 'cannot assign list of >1 elements to $['); + eval q{ ($[) = () }; + like($@, qr/That use of \$\[ is unsupported/, + 'cannot assign list of <1 elements to $['); +}