diff options
author | josh <twists@gmail.com> | 2007-10-14 14:37:08 -0700 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-10-17 08:17:29 +0000 |
commit | 1e1d4b91957a9f66bbb14b2c7f1bbf88c1f89cdf (patch) | |
tree | ab06c1b94ecf038d0bb7b80ad7e53a8ece4b28a3 /t | |
parent | a5a709ec819bfe84b1af6f781d5d87ef68e00c3a (diff) | |
download | perl-1e1d4b91957a9f66bbb14b2c7f1bbf88c1f89cdf.tar.gz |
Fix a few segfaults and a when() bug
From: "josh" <twists@gmail.com>
Message-ID: <20071015043708.GA10981@grenekatz.org>
p4raw-id: //depot/perl@32120
Diffstat (limited to 't')
-rwxr-xr-x | t/io/argv.t | 13 | ||||
-rw-r--r-- | t/op/reg_nc_tie.t | 7 | ||||
-rw-r--r-- | t/op/switch.t | 20 |
3 files changed, 31 insertions, 9 deletions
diff --git a/t/io/argv.t b/t/io/argv.t index c24dad5d4a..d6c895d6cc 100755 --- a/t/io/argv.t +++ b/t/io/argv.t @@ -7,7 +7,7 @@ BEGIN { BEGIN { require "./test.pl"; } -plan(tests => 22); +plan(tests => 23); use File::Spec; @@ -38,6 +38,13 @@ is($x, "1a line\n2a line\n", '<> from two files'); is($x, "foo\n", ' from just STDIN'); } +{ + # 5.10 stopped autovivifying scalars in globs leading to a + # segfault when $ARGV is written to. + runperl( prog => 'eof()', stdin => "nothing\n" ); + is( 0+$?, 0, q(eof() doesn't segfault) ); +} + @ARGV = ('Io_argv1.tmp', 'Io_argv1.tmp', $devnull, 'Io_argv1.tmp'); while (<>) { $y .= $. . $_; @@ -56,7 +63,7 @@ close TRY or die "Could not close: $!"; @ARGV = ('Io_argv1.tmp', 'Io_argv2.tmp'); $^I = '_bak'; # not .bak which confuses VMS $/ = undef; -my $i = 6; +my $i = 7; while (<>) { s/^/ok $i\n/; ++$i; @@ -81,7 +88,7 @@ open STDIN, 'Io_argv1.tmp' or die $!; @ARGV = (); ok( !eof(), 'STDIN has something' ); -is( <>, "ok 6\n" ); +is( <>, "ok 7\n" ); open STDIN, $devnull or die $!; @ARGV = (); diff --git a/t/op/reg_nc_tie.t b/t/op/reg_nc_tie.t index f72970ed1e..7a79a8e6da 100644 --- a/t/op/reg_nc_tie.t +++ b/t/op/reg_nc_tie.t @@ -8,7 +8,12 @@ BEGIN { # Do a basic test on all the tied methods of Tie::Hash::NamedCapture -print "1..12\n"; +print "1..13\n"; + +# PL_curpm->paren_names can be a null pointer. See that this succeeds anyway. +'x' =~ /(.)/; +() = %+; +pass( 'still alive' ); "hlagh" =~ / (?<a>.) diff --git a/t/op/switch.t b/t/op/switch.t index 98e10f6b44..d897157946 100644 --- a/t/op/switch.t +++ b/t/op/switch.t @@ -8,7 +8,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 107; +use Test::More tests => 108; # The behaviour of the feature pragma should be tested by lib/switch.t # using the tests in t/lib/switch/*. This file tests the behaviour of @@ -457,6 +457,16 @@ sub bar {"bar"} # Other things that should not be smart matched { my $ok = 0; + given(12) { + when( /(\d+)/ and ( 1 <= $1 and $1 <= 12 ) ) { + $ok = 1; + } + } + ok($ok, "bool not smartmatches"); +} + +{ + my $ok = 0; given(0) { when(eof(DATA)) { $ok = 1; @@ -500,13 +510,13 @@ sub bar {"bar"} } { - my $ok = 1; - given(0) { + my $ok = 0; + given("foo") { when((1 == $ok) || "foo") { - $ok = 0; + $ok = 1; } } - ok($ok, '((1 == $ok) || "foo") not smartmatched'); + ok($ok, '((1 == $ok) || "foo") smartmatched'); } |