diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-10-13 14:33:38 +0100 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2009-10-16 12:30:14 -0400 |
commit | 24d0fc42f3cde6d97ff49e299caa014144e156ef (patch) | |
tree | 04f138f8a98e3822b16083d851f149c6eae6abee /t | |
parent | 065f14eb9d944e9b3262cfef1909b7c914642623 (diff) | |
download | perl-24d0fc42f3cde6d97ff49e299caa014144e156ef.tar.gz |
Move tests for $[ from comp/parser.t to op/array_base.t
Tests in t/comp/ are too early to rely on pragmata working.
Diffstat (limited to 't')
-rw-r--r-- | t/comp/parser.t | 36 | ||||
-rw-r--r-- | t/op/array_base.t | 38 |
2 files changed, 39 insertions, 35 deletions
diff --git a/t/comp/parser.t b/t/comp/parser.t index d0e7f5d62e..eed0f1873c 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 0000000000..98047901af --- /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 $['); +} |