]> git.donarmstrong.com Git - perltidy.git/blobdiff - t/snippets15.t
New upstream version 20210717
[perltidy.git] / t / snippets15.t
index affba1b78b73abdf7d0d1b32cd0904a7a7000ed8..f79abe8dbf34506e1b4cae6962bc68ab2620520c 100644 (file)
@@ -24,7 +24,7 @@
 # To locate test #13 you can search for its name or the string '#13'
 
 use strict;
-use Test;
+use Test::More;
 use Carp;
 use Perl::Tidy;
 my $rparams;
@@ -171,6 +171,8 @@ sub get_val() { }
 sub get_Val  () { }
 
 sub Get_val            () { }
+my $sub1=sub                     () { };
+my $sub2=sub () { };
 ----------
 
         'wngnu1' => <<'----------',
@@ -205,9 +207,9 @@ sub Get_val         () { }
             expect => <<'#1...........',
         # side comments limit gnu type formatting with l=80; note extra comma
         push @tests, [
-            "Lowest code point requiring 13 bytes to represent",      # 2**36
-            "\xff\x80\x80\x80\x80\x80\x81\x80\x80\x80\x80\x80\x80",
-            ($::is64bit) ? 0x1000000000 : -1,    # overflows on 32bit
+                 "Lowest code point requiring 13 bytes to represent",    # 2**36
+                 "\xff\x80\x80\x80\x80\x80\x81\x80\x80\x80\x80\x80\x80",
+                 ($::is64bit) ? 0x1000000000 : -1,    # overflows on 32bit
                      ],
           ;
 #1...........
@@ -242,7 +244,7 @@ sub Get_val         () { }
             params => "def",
             expect => <<'#3...........',
 for $x ( 1, 2 ) { s/(.*)/+$1/ }
-for $x ( 1, 2 ) { s/(.*)/+$1/ }    # side comment
+for $x ( 1, 2 ) { s/(.*)/+$1/ }     # side comment
 if ( $editlblk eq 1 ) { $editlblk = "on"; $editlblkchecked = "checked" }
 for $x ( 1, 2 ) { s/(.*)/+$1/; }
 for $x ( 1, 2 ) { s/(.*)/+$1/; }    # side comment
@@ -470,6 +472,8 @@ sub get_val() { }
 sub get_Val () { }
 
 sub Get_val () { }
+my $sub1 = sub () { };
+my $sub2 = sub () { };
 #18...........
         },
 
@@ -482,6 +486,8 @@ sub get_val() { }
 sub get_Val() { }
 
 sub Get_val() { }
+my $sub1 = sub() { };
+my $sub2 = sub() { };
 #19...........
         },
     };
@@ -509,32 +515,39 @@ foreach my $key ( sort keys %{$rtests} ) {
         perltidyrc  => \$params,
         argv        => '',             # for safety; hide any ARGV from perltidy
         stderr      => \$stderr_string,
-        errorfile => \$errorfile_string,    # not used when -se flag is set
+        errorfile   => \$errorfile_string,    # not used when -se flag is set
     );
     if ( $err || $stderr_string || $errorfile_string ) {
+        print STDERR "Error output received for test '$key'\n";
         if ($err) {
-            print STDERR
-"This error received calling Perl::Tidy with '$sname' + '$pname'\n";
+            print STDERR "An error flag '$err' was returned\n";
             ok( !$err );
         }
         if ($stderr_string) {
             print STDERR "---------------------\n";
             print STDERR "<<STDERR>>\n$stderr_string\n";
             print STDERR "---------------------\n";
-            print STDERR
-"This error received calling Perl::Tidy with '$sname' + '$pname'\n";
             ok( !$stderr_string );
         }
         if ($errorfile_string) {
             print STDERR "---------------------\n";
             print STDERR "<<.ERR file>>\n$errorfile_string\n";
             print STDERR "---------------------\n";
-            print STDERR
-"This error received calling Perl::Tidy with '$sname' + '$pname'\n";
             ok( !$errorfile_string );
         }
     }
     else {
-        ok( $output, $expect );
+        if ( !is( $output, $expect, $key ) ) {
+            my $leno = length($output);
+            my $lene = length($expect);
+            if ( $leno == $lene ) {
+                print STDERR
+"#> Test '$key' gave unexpected output.  Strings differ but both have length $leno\n";
+            }
+            else {
+                print STDERR
+"#> Test '$key' gave unexpected output.  String lengths differ: output=$leno, expected=$lene\n";
+            }
+        }
     }
 }