This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Devel-PPPort Include line numbers in ppphtest.t debug output
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Thu, 19 Apr 2018 17:04:49 +0000 (19:04 +0200)
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Thu, 19 Apr 2018 17:04:49 +0000 (19:04 +0200)
dist/Devel-PPPort/parts/inc/ppphtest
dist/Devel-PPPort/t/ppphtest.t

index 925929d..2be4331 100644 (file)
@@ -75,7 +75,8 @@ ok(Devel::PPPort::GetFileContents(), $data);
 sub comment
 {
   my $c = shift;
-  $c =~ s/^/# | /mg;
+  my $x = 0;
+  $c =~ s/^/sprintf("# %2d| ", ++$x)/meg;
   $c .= "\n" unless $c =~ /[\r\n]$/;
   print $c;
 }
@@ -154,14 +155,12 @@ for $t (@tests) {
     open F, ">$f" or die "open $f: $!\n";
     print F "$txt\n";
     close F;
-    $txt =~ s/^/# | /mg;
-    print "# *** writing $f ***\n$txt\n";
+    print "# *** writing $f ***\n";
+    comment($txt);
   }
 
-  my $code = $t->{code};
-  $code =~ s/^/# | /mg;
-
-  print "# *** evaluating test code ***\n$code\n";
+  print "# *** evaluating test code ***\n";
+  comment($t->{code});
 
   eval $t->{code};
   if ($@) {
index 90d7d24..af2db3f 100644 (file)
@@ -112,7 +112,8 @@ ok(Devel::PPPort::GetFileContents(), $data);
 sub comment
 {
   my $c = shift;
-  $c =~ s/^/# | /mg;
+  my $x = 0;
+  $c =~ s/^/sprintf("# %2d| ", ++$x)/meg;
   $c .= "\n" unless $c =~ /[\r\n]$/;
   print $c;
 }
@@ -191,14 +192,12 @@ for $t (@tests) {
     open F, ">$f" or die "open $f: $!\n";
     print F "$txt\n";
     close F;
-    $txt =~ s/^/# | /mg;
-    print "# *** writing $f ***\n$txt\n";
+    print "# *** writing $f ***\n";
+    comment($txt);
   }
 
-  my $code = $t->{code};
-  $code =~ s/^/# | /mg;
-
-  print "# *** evaluating test code ***\n$code\n";
+  print "# *** evaluating test code ***\n";
+  comment($t->{code});
 
   eval $t->{code};
   if ($@) {