#16 nib.nib2
#17 scbb-csc.def
#18 scbb-csc.scbb-csc
+#19 here_long.def
# To locate test #13 you can search for its name or the string '#13'
# abbreviation, so skip to the next word.
next WORD;
}
+----------
+
+ 'here_long' => <<'----------',
+# must not break first line regardless of value of maximum-line-length
+$sth= $dbh->prepare (<<"END_OF_SELECT") or die "Couldn't prepare SQL" ;
+ SELECT COUNT(duration),SUM(duration)
+ FROM logins WHERE username='$user'
+END_OF_SELECT
+
----------
'lop' => <<'----------',
#18...........
},
+
+ 'here_long.def' => {
+ source => "here_long",
+ params => "def",
+ expect => <<'#19...........',
+# must not break first line regardless of value of maximum-line-length
+$sth = $dbh->prepare(<<"END_OF_SELECT") or die "Couldn't prepare SQL";
+ SELECT COUNT(duration),SUM(duration)
+ FROM logins WHERE username='$user'
+END_OF_SELECT
+
+#19...........
+ },
};
my $ntests = 0 + keys %{$rtests};
--- /dev/null
+# Created with: ./make_t.pl
+
+# Contents:
+#1 here_long.here_long
+
+# To locate test #13 you can search for its name or the string '#13'
+
+use strict;
+use Test::More;
+use Carp;
+use Perl::Tidy;
+my $rparams;
+my $rsources;
+my $rtests;
+
+BEGIN {
+
+ ###########################################
+ # BEGIN SECTION 1: Parameter combinations #
+ ###########################################
+ $rparams = { 'here_long' => "-l=33", };
+
+ ############################
+ # BEGIN SECTION 2: Sources #
+ ############################
+ $rsources = {
+
+ 'here_long' => <<'----------',
+# must not break first line regardless of value of maximum-line-length
+$sth= $dbh->prepare (<<"END_OF_SELECT") or die "Couldn't prepare SQL" ;
+ SELECT COUNT(duration),SUM(duration)
+ FROM logins WHERE username='$user'
+END_OF_SELECT
+
+----------
+ };
+
+ ####################################
+ # BEGIN SECTION 3: Expected output #
+ ####################################
+ $rtests = {
+
+ 'here_long.here_long' => {
+ source => "here_long",
+ params => "here_long",
+ expect => <<'#1...........',
+# must not break first line regardless of value of maximum-line-length
+$sth = $dbh->prepare(<<"END_OF_SELECT") or die "Couldn't prepare SQL";
+ SELECT COUNT(duration),SUM(duration)
+ FROM logins WHERE username='$user'
+END_OF_SELECT
+
+#1...........
+ },
+ };
+
+ my $ntests = 0 + keys %{$rtests};
+ plan tests => $ntests;
+}
+
+###############
+# EXECUTE TESTS
+###############
+
+foreach my $key ( sort keys %{$rtests} ) {
+ my $output;
+ my $sname = $rtests->{$key}->{source};
+ my $expect = $rtests->{$key}->{expect};
+ my $pname = $rtests->{$key}->{params};
+ my $source = $rsources->{$sname};
+ my $params = defined($pname) ? $rparams->{$pname} : "";
+ my $stderr_string;
+ my $errorfile_string;
+ my $err = Perl::Tidy::perltidy(
+ source => \$source,
+ destination => \$output,
+ perltidyrc => \$params,
+ argv => '', # for safety; hide any ARGV from perltidy
+ stderr => \$stderr_string,
+ 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 "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";
+ ok( !$stderr_string );
+ }
+ if ($errorfile_string) {
+ print STDERR "---------------------\n";
+ print STDERR "<<.ERR file>>\n$errorfile_string\n";
+ print STDERR "---------------------\n";
+ ok( !$errorfile_string );
+ }
+ }
+ else {
+ 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";
+ }
+ }
+ }
+}