# 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;
----------
'align20' => <<'----------',
-# marginal two-line match; differnt lhs patterns; do not align
+# marginal two-line match; different lhs patterns; do not align
$w[$i] = $t;
$t = 1000000;
----------
# two lines with large gap but same lhs pattern so align equals
local (@pieces) = split( /\./, $filename, 2 );
local ($just_dir_and_base) = $pieces[0];
+
+# two lines with 3 alignment tokens
+$expect = "1$expect" if $expect =~ /^e/i;
+$p = "1$p" if defined $p and $p =~ /^e/i;
+
+# two lines where alignment causes a large gap
+is( eval { sysopen( my $ro, $foo, &O_RDONLY | $TAINT0 ) }, undef );
+is( $@, '' );
----------
'align22' => <<'----------',
----------
'align24' => <<'----------',
-# Do not align interior fat commas here; differnt container types
+# Do not align interior fat commas here; different container types
my $p = TAP::Parser::SubclassTest->new(
{
exec => [ $cat => $file ],
----------
'align25' => <<'----------',
-# do not align commas here; different container types
+# do not align internal commas here; different container types
is_deeply( [ $a, $a ], [ $b, $c ] );
is_deeply( { foo => $a, bar => $a }, { foo => $b, bar => $c } );
is_deeply( [ \$a, \$a ], [ \$b, \$c ] );
'align26' => <<'----------',
# align first of multiple equals
-$SIG{PIPE}=sub{die"writingtoaclosedpipe"};#1=
-$SIG{HUP}=$SIG{BREAK}=$SIG{INT}=$SIG{TERM};#3=
+$SIG{PIPE}=sub{die"writingtoaclosedpipe"};
+$SIG{BREAK}=$SIG{INT}=$SIG{TERM};
+$SIG{HUP}=\&some_handler;
----------
'align27' => <<'----------',
params => "def",
expect => <<'#3...........',
my $type = shift || "o";
- my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
- my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
+ my $fname = ( $type eq 'oo' ? 'orte_city' : 'orte' );
+ my $suffix = ( $coord_system eq 'standard' ? '' : '-orig' );
#3...........
},
source => "align20",
params => "def",
expect => <<'#12...........',
-# marginal two-line match; differnt lhs patterns; do not align
+# marginal two-line match; different lhs patterns; do not align
$w[$i] = $t;
$t = 1000000;
#12...........
# two lines with large gap but same lhs pattern so align equals
local (@pieces) = split( /\./, $filename, 2 );
local ($just_dir_and_base) = $pieces[0];
+
+# two lines with 3 alignment tokens
+$expect = "1$expect" if $expect =~ /^e/i;
+$p = "1$p" if defined $p and $p =~ /^e/i;
+
+# two lines where alignment causes a large gap
+is( eval { sysopen( my $ro, $foo, &O_RDONLY | $TAINT0 ) }, undef );
+is( $@, '' );
#13...........
},
source => "align24",
params => "def",
expect => <<'#16...........',
-# Do not align interior fat commas here; differnt container types
+# Do not align interior fat commas here; different container types
my $p = TAP::Parser::SubclassTest->new(
{
exec => [ $cat => $file ],
source => "align25",
params => "def",
expect => <<'#17...........',
-# do not align commas here; different container types
-is_deeply( [ $a, $a ], [ $b, $c ] );
+# do not align internal commas here; different container types
+is_deeply( [ $a, $a ], [ $b, $c ] );
is_deeply( { foo => $a, bar => $a }, { foo => $b, bar => $c } );
-is_deeply( [ \$a, \$a ], [ \$b, \$c ] );
+is_deeply( [ \$a, \$a ], [ \$b, \$c ] );
#17...........
},
params => "def",
expect => <<'#18...........',
# align first of multiple equals
-$SIG{PIPE} = sub { die "writingtoaclosedpipe" }; #1=
-$SIG{HUP} = $SIG{BREAK} = $SIG{INT} = $SIG{TERM}; #3=
+$SIG{PIPE} = sub { die "writingtoaclosedpipe" };
+$SIG{BREAK} = $SIG{INT} = $SIG{TERM};
+$SIG{HUP} = \&some_handler;
#18...........
},
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";
+ }
+ }
}
}