This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
test that code within /(?{})/ etc is optimised
authorDavid Mitchell <davem@iabyn.com>
Wed, 6 Jun 2012 10:28:40 +0000 (11:28 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:32:56 +0000 (13:32 +0100)
t/re/pat_re_eval.t

index 1d724c2..ddc53f7 100644 (file)
@@ -23,7 +23,7 @@ BEGIN {
 }
 
 
-plan tests => 454;  # Update this when adding/deleting tests.
+plan tests => 459;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -986,6 +986,26 @@ sub run_tests {
        ok("ABBCA" =~ /^(.)(??{$code2})\1$/, '(?{}) BEGIN and $1 mark 2');
     }
 
+    # check that the optimiser is applied to code blocks: see if aelem has
+    # been converted to aelemfast
+
+    {
+       my $out;
+       for my $prog (
+           '/(?{$a[0]})/',
+           'q() =~ qr/(?{$a[0]})/',
+           'use re q(eval); q() =~ q{(?{$a[0]})}',
+           'use re q(eval); $c = q{(?{$a[0]})}; /$c/',
+           'use re q(eval); $c = q{(?{$a[0]})}; /(?{1;})$c/',
+       ) {
+           $out = runperl(switches => ["-Dt"], prog => $prog, stderr => 1);
+           like($out, qr/aelemfast|Recompile perl with -DDEBUGGING/,
+               "optimise: '$prog'");
+       }
+    }
+
+
+
 
 } # End of sub run_tests