Test perl #112312, crash on syntax error
authorFather Chrysostomos <sprout@cpan.org>
Sun, 24 Jun 2012 06:34:13 +0000 (23:34 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 29 Jun 2012 07:20:59 +0000 (00:20 -0700)
I am having difficulty getting these tests to fail.  They crash when
run standalone, but always pass when run via fresh_perl.t.  Hopefully,
they will fail somewhere. :-)

Yes, fresh_perl.t does begin with this:

# ** DO NOT ADD ANY MORE TESTS HERE **

But t/comp/parser.t does not (and should not) use test.pl, so it is
very hard to test something like this.

Putting it here seemed slightly better than putting it in
its own file.

t/run/fresh_perl.t

index 3e56a09..d12c9d6 100644 (file)
@@ -822,3 +822,55 @@ eval {
 print "If you get here, you didn't crash\n";
 EXPECT
 If you get here, you didn't crash
+######## [perl #112312] crash on syntax error
+#!/usr/bin/perl
+use strict;
+use warnings;
+sub meow (&);
+my %h;
+my $k;
+
+meow {
+       my $t : need_this;
+       $t = {
+               size =>  $h{$k}{size};
+               used =>  $h{$k}(used}
+       };
+};
+EXPECT
+syntax error at - line 12, near "used"
+syntax error at - line 12, near "used}"
+Unmatched right curly bracket at - line 14, at end of line
+Execution of - aborted due to compilation errors.
+######## [perl #112312] crash on syntax error - another test
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+sub meow (&);
+
+my %h;
+my $k;
+
+meow {
+        my $t : need_this;
+        $t = {
+                size => $h{$k}{size};
+                used => $h{$k}(used}
+        };
+};
+
+sub testo {
+        my $value = shift;
+        print;
+        print;
+        print;
+        1;
+}
+
+EXPECT
+syntax error at - line 15, near "used"
+syntax error at - line 15, near "used}"
+Unmatched right curly bracket at - line 17, at end of line
+Execution of - aborted due to compilation errors.