From: Michael G. Schwern Date: Fri, 31 Aug 2001 15:36:28 +0000 (-0400) Subject: Re: [ID 20010831.001] SEGV from ($a, b) = (1, 2) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=949d010fe77e69674beb14306cfc1b92afa3e47c;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20010831.001] SEGV from ($a, b) = (1, 2) Message-ID: <20010831153628.B598@blackrider> Check for things which used to segfault p4raw-id: //depot/perl@11805 --- diff --git a/t/run/segfault.t b/t/run/segfault.t new file mode 100644 index 0000000..e3bd8b6 --- /dev/null +++ b/t/run/segfault.t @@ -0,0 +1,43 @@ +#!./perl +# +# Tests for things which have caused segfaults in the past. + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +# VMS and Windows need -e "...", most everything else works better with ' +my $quote = $^O =~ /^(VMS|MSWin\d+)$/ ? q{"} : q{'}; + +my $IsVMS = $^O eq 'VMS'; + + +BEGIN { + if( $^O =~ /^(VMS|MSWin\d+)$/ ) { + print "1..0 # Skipped: platform temporarily not supported\n"; + exit; + } +} + + +# Run some code, check that it has the expected output and exits +# with the code for a perl syntax error. +sub chk_segfault { + my($code, $expect, $name) = @_; + my $cmd = "$^X -e "; + + # I *think* these are the right exit codes for syntax error. + my $expected_exit = $IsVMS ? 4 : 255; + + my $out = `$cmd$quote$code$quote 2>&1`; + + is( $? >> 8, $expected_exit, "$name - exit as expected" ); + like( $out, qr/$expect at -e line 1/, ' with the right output' ); +} + +use Test::More tests => 2; + +chk_segfault('($a, b) = (1, 2)', + "Can't modify constant item in list assignment", + 'perlbug ID 20010831.001');