This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse.t: diag full code that failed to compile
authorDavid Mitchell <davem@iabyn.com>
Wed, 22 Feb 2017 16:53:50 +0000 (16:53 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 5 Jun 2017 11:52:17 +0000 (12:52 +0100)
makes it easier to debug when adding new tests that it doesn't like

lib/B/Deparse.t

index 7eeb4f8..154a6f9 100644 (file)
@@ -63,7 +63,7 @@ while (<DATA>) {
            new B::Deparse split /,/, $meta{options}
        : $deparse;
 
-    my $coderef = eval "$meta{context};\n" . <<'EOC' . "sub {$input\n}";
+    my $code = "$meta{context};\n" . <<'EOC' . "sub {$input\n}";
 # Tell B::Deparse about our ambient pragmas
 my ($hint_bits, $warning_bits, $hinthash);
 BEGIN {
@@ -75,10 +75,14 @@ $deparse->ambient_pragmas (
     '%^H'        => $hinthash,
 );
 EOC
+    my $coderef = eval $code;
 
     local $::TODO = $meta{todo};
     if ($@) {
-       is($@, "", "compilation of $desc");
+       is($@, "", "compilation of $desc")
+            or diag "=============================================\n"
+                  . "CODE:\n--------\n$code\n--------\n"
+                  . "=============================================\n";
     }
     else {
        my $deparsed = $deparse->coderef2text( $coderef );