# 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;
# remove unwanted spaces after $ and -> here
&{ $ _ -> [1] }( delete $ _ [$#_ ]{ $_ -> [0] } );
+
+ # this has both tabs and spaces to remove
+ $ setup = $ labels -> labelsetup( Output_Width => 2.625) ;
----------
'space2' => <<'----------',
params => "def",
expect => <<'#8...........',
\&foo !~~ \&foo;
-\&foo ~~ \&foo;
-\&foo ~~ \&foo;
-\&foo ~~ sub { };
-sub { } ~~ \&foo;
-\&foo ~~ \&bar;
-\&bar ~~ \&foo;
-1 ~~ sub { shift };
-sub { shift } ~~ 1;
-0 ~~ sub { shift };
-sub { shift } ~~ 0;
-1 ~~ sub { scalar @_ };
+\&foo ~~ \&foo;
+\&foo ~~ \&foo;
+\&foo ~~ sub { };
+sub { } ~~ \&foo;
+\&foo ~~ \&bar;
+\&bar ~~ \&foo;
+1 ~~ sub { shift };
+sub { shift } ~~ 1;
+0 ~~ sub { shift };
+sub { shift } ~~ 0;
+1 ~~ sub { scalar @_ };
sub { scalar @_ } ~~ 1;
-[] ~~ \&bar;
-\&bar ~~ [];
-{} ~~ \&bar;
-\&bar ~~ {};
-qr// ~~ \&bar;
-\&bar ~~ qr//;
-a_const ~~ "a constant";
-"a constant" ~~ a_const;
-a_const ~~ a_const;
-a_const ~~ a_const;
-a_const ~~ b_const;
-b_const ~~ a_const;
-{} ~~ {};
-{} ~~ {};
-{} ~~ { 1 => 2 };
-{ 1 => 2 } ~~ {};
+[] ~~ \&bar;
+\&bar ~~ [];
+{} ~~ \&bar;
+\&bar ~~ {};
+qr// ~~ \&bar;
+\&bar ~~ qr//;
+a_const ~~ "a constant";
+"a constant" ~~ a_const;
+a_const ~~ a_const;
+a_const ~~ a_const;
+a_const ~~ b_const;
+b_const ~~ a_const;
+{} ~~ {};
+{} ~~ {};
+{} ~~ { 1 => 2 };
+{ 1 => 2 } ~~ {};
{ 1 => 2 } ~~ { 1 => 2 };
{ 1 => 2 } ~~ { 1 => 2 };
{ 1 => 2 } ~~ { 1 => 3 };
[] ~~ [];
[] ~~ [1];
[1] ~~ [];
-[ ["foo"], ["bar"] ] ~~ [ qr/o/, qr/a/ ];
-[ qr/o/, qr/a/ ] ~~ [ ["foo"], ["bar"] ];
-[ "foo", "bar" ] ~~ [ qr/o/, qr/a/ ];
-[ qr/o/, qr/a/ ] ~~ [ "foo", "bar" ];
-$deep1 ~~ $deep1;
-$deep1 ~~ $deep1;
-$deep1 ~~ $deep2;
-$deep2 ~~ $deep1;
-\@nums ~~ \@tied_nums;
-\@tied_nums ~~ \@nums;
-[qw(foo bar baz quux)] ~~ qr/x/;
-qr/x/ ~~ [qw(foo bar baz quux)];
-[qw(foo bar baz quux)] ~~ qr/y/;
-qr/y/ ~~ [qw(foo bar baz quux)];
-[qw(1foo 2bar)] ~~ 2;
-2 ~~ [qw(1foo 2bar)];
-[qw(1foo 2bar)] ~~ "2";
-"2" ~~ [qw(1foo 2bar)];
-2 ~~ 2;
-2 ~~ 2;
-2 ~~ 3;
-3 ~~ 2;
-2 ~~ "2";
-"2" ~~ 2;
-2 ~~ "2.0";
-"2.0" ~~ 2;
-2 ~~ "2bananas";
-"2bananas" ~~ 2;
-2_3 ~~ "2_3";
-"2_3" ~~ 2_3;
-qr/x/ ~~ "x";
-"x" ~~ qr/x/;
-qr/y/ ~~ "x";
-"x" ~~ qr/y/;
-12345 ~~ qr/3/;
-qr/3/ ~~ 12345;
-@nums ~~ 7;
-7 ~~ @nums;
-@nums ~~ \@nums;
-\@nums ~~ @nums;
-@nums ~~ \\@nums;
-\\@nums ~~ @nums;
-@nums ~~ [ 1 .. 10 ];
-[ 1 .. 10 ] ~~ @nums;
-@nums ~~ [ 0 .. 9 ];
-[ 0 .. 9 ] ~~ @nums;
-%hash ~~ "foo";
-"foo" ~~ %hash;
-%hash ~~ /bar/;
-/bar/ ~~ %hash;
+[ ["foo"], ["bar"] ] ~~ [ qr/o/, qr/a/ ];
+[ qr/o/, qr/a/ ] ~~ [ ["foo"], ["bar"] ];
+[ "foo", "bar" ] ~~ [ qr/o/, qr/a/ ];
+[ qr/o/, qr/a/ ] ~~ [ "foo", "bar" ];
+$deep1 ~~ $deep1;
+$deep1 ~~ $deep1;
+$deep1 ~~ $deep2;
+$deep2 ~~ $deep1;
+\@nums ~~ \@tied_nums;
+\@tied_nums ~~ \@nums;
+[qw(foo bar baz quux)] ~~ qr/x/;
+qr/x/ ~~ [qw(foo bar baz quux)];
+[qw(foo bar baz quux)] ~~ qr/y/;
+qr/y/ ~~ [qw(foo bar baz quux)];
+[qw(1foo 2bar)] ~~ 2;
+2 ~~ [qw(1foo 2bar)];
+[qw(1foo 2bar)] ~~ "2";
+"2" ~~ [qw(1foo 2bar)];
+2 ~~ 2;
+2 ~~ 2;
+2 ~~ 3;
+3 ~~ 2;
+2 ~~ "2";
+"2" ~~ 2;
+2 ~~ "2.0";
+"2.0" ~~ 2;
+2 ~~ "2bananas";
+"2bananas" ~~ 2;
+2_3 ~~ "2_3";
+"2_3" ~~ 2_3;
+qr/x/ ~~ "x";
+"x" ~~ qr/x/;
+qr/y/ ~~ "x";
+"x" ~~ qr/y/;
+12345 ~~ qr/3/;
+qr/3/ ~~ 12345;
+@nums ~~ 7;
+7 ~~ @nums;
+@nums ~~ \@nums;
+\@nums ~~ @nums;
+@nums ~~ \\@nums;
+\\@nums ~~ @nums;
+@nums ~~ [ 1 .. 10 ];
+[ 1 .. 10 ] ~~ @nums;
+@nums ~~ [ 0 .. 9 ];
+[ 0 .. 9 ] ~~ @nums;
+%hash ~~ "foo";
+"foo" ~~ %hash;
+%hash ~~ /bar/;
+/bar/ ~~ %hash;
#8...........
},
# remove unwanted spaces after $ and -> here
&{ $_->[1] }( delete $_[$#_]{ $_->[0] } );
+
+ # this has both tabs and spaces to remove
+ $setup = $labels->labelsetup( Output_Width => 2.625 );
#9...........
},
# This test snippet is from package bbbike v3.214 by Slaven Rezic; GPL 2.0 licence
sub arrange_topframe {
my (@order) = (
- $hslabel_frame, $km_frame, $speed_frame[0],
+ $hslabel_frame, $km_frame, $speed_frame[0],
$power_frame[0], $wind_frame, $percent_frame, $temp_frame,
@speed_frame[1 .. $#speed_frame],
@power_frame[1 .. $#power_frame],
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";
+ }
+ }
}
}