]> git.donarmstrong.com Git - perltidy.git/blobdiff - t/snippets5.t
New upstream version 20210717
[perltidy.git] / t / snippets5.t
index f65be6ecc051b28d70b3d762c915b7dd3d3be732..3ada90170da587d13eac1a6392d05e952fbc178c 100644 (file)
@@ -25,7 +25,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;
@@ -572,10 +572,10 @@ push @contents,
                      )
              ),
              $c->Tr(
-                  { -valign => 'top' },
-                  $c->td(
-                          $c->table(
-                                     $c->Tr(
+                     { -valign => 'top' },
+                     $c->td(
+                             $c->table(
+                                        $c->Tr(
                                             $c->td(
                                                    { -valign => 'top' },
                                                    $c->strong(" Document Type ")
@@ -590,31 +590,33 @@ push @contents,
                                                     -default => "$doc_type"
                                                 )
                                             )
-                                     )
-                          )
-                  ),
-                  $c->td(
-                      $c->table(
-                          $c->Tr(
-                              $c->td(
-                                  { -valign => 'top' },
-                                  $c->strong(
-                                      " Relevant Discipline ", $c->br(), "Area "
-                                  )
-                              ),
-                              $c->td(
-                                      { -valign => 'top' },
-                                      $c->scrolling_list(
+                                        )
+                             )
+                     ),
+                     $c->td(
+                             $c->table(
+                                        $c->Tr(
+                                             $c->td(
+                                                    { -valign => 'top' },
+                                                    $c->strong(
+                                                        " Relevant Discipline ",
+                                                        $c->br(),
+                                                        "Area "
+                                                    )
+                                             ),
+                                             $c->td(
+                                                 { -valign => 'top' },
+                                                 $c->scrolling_list(
                                                      -tabindex => "5",
                                                      -name     => "discipline",
                                                      -values => [@discipValues],
                                                      -labels => \%discipLabels,
                                                      -default => "$discipline"
-                                      ),
-                              )
-                          )
-                      )
-                  )
+                                                 ),
+                                             )
+                                        )
+                             )
+                     )
              ),
              $c->Tr(
                      { -valign => 'top' },
@@ -665,7 +667,8 @@ push @contents,
                                        $c->Tr(
                                            $c->td(
                                                { -valign => 'top' },
-                                               "Description", $c->br(),
+                                               "Description",
+                                               $c->br(),
                                                $c->small("Maximum 750 letters.")
                                            ),
                                            $c->td(
@@ -906,9 +909,9 @@ return $pdl->slice(
     join ',',
     (
         map {
-                $_ eq "X" ? ":"
+                $_ eq "X"         ? ":"
               : ref $_ eq "ARRAY" ? join ':', @$_
-              : !ref $_ ? $_
+              : !ref $_           ? $_
               : die "INVALID SLICE DEF $_"
         } @_
     )
@@ -940,32 +943,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";
+            }
+        }
     }
 }