Re: [ID 20010831.001] SEGV from ($a, b) = (1, 2)
authorMichael G. Schwern <schwern@pobox.com>
Fri, 31 Aug 2001 15:36:28 +0000 (11:36 -0400)
committerArtur Bergman <sky@nanisky.com>
Fri, 31 Aug 2001 21:35:10 +0000 (21:35 +0000)
Message-ID: <20010831153628.B598@blackrider>
Check for things which used to segfault

p4raw-id: //depot/perl@11805

t/run/segfault.t [new file with mode: 0644]

diff --git a/t/run/segfault.t b/t/run/segfault.t
new file mode 100644 (file)
index 0000000..e3bd8b6
--- /dev/null
@@ -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');