lexsub.t: To-do tests for citing lex subs after errors
authorFather Chrysostomos <sprout@cpan.org>
Sat, 1 Jun 2013 13:28:12 +0000 (06:28 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 2 Jun 2013 18:54:55 +0000 (11:54 -0700)
This currently causes assertion failures on debugging builds.  On
non-debugging builds (untested), it probably crashes:

my sub a { foo ref } # foo must not exist
a();

t/op/lexsub.t

index 86c7e26..8d768cc 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
     *bar::like = *like;
 }
 no warnings 'deprecated';
-plan 128;
+plan 130;
 
 # -------------------- Errors with feature disabled -------------------- #
 
@@ -318,6 +318,15 @@ sub make_anon_with_state_sub{
   }
   r(1);
 }
+$::TODO = ' ';
+like runperl(
+      switches => [ '-Mfeature=:all' ],
+      prog     => 'state sub a { foo ref } a()',
+      stderr   => 1
+     ),
+     qr/syntax error/,
+    'referencing a state sub after a syntax error does not crash';
+undef $::TODO;
 
 # -------------------- my -------------------- #
 
@@ -607,6 +616,15 @@ not_lexical11();
   eval q{ my sub george () { 2 } };
   is $w, undef, 'no double free from constant my subs';
 }
+$::TODO = ' ';
+like runperl(
+      switches => [ '-Mfeature=:all' ],
+      prog     => 'my sub a { foo ref } a()',
+      stderr   => 1
+     ),
+     qr/syntax error/,
+    'referencing a my sub after a syntax error does not crash';
+undef $::TODO;
 
 # -------------------- Interactions (and misc tests) -------------------- #