1 # Created with: ./make_t.pl
24 # To locate test #13 you can search for its name or the string '#13'
36 ###########################################
37 # BEGIN SECTION 1: Parameter combinations #
38 ###########################################
44 'dwic' => "-wn -dwic",
45 'olbxl1' => "-olbxl=eval",
46 'rt144979' => "-xci -ce -lp",
47 'wtc1' => "-wtc=0 -dtc",
48 'wtc2' => "-wtc=1 -atc",
49 'wtc3' => "-wtc=m -atc",
50 'wtc4' => "-wtc=m -atc -dtc",
51 'wtc5' => "-wtc=b -atc -dtc -vtc=2",
52 'wtc6' => "-wtc=i -atc -dtc -vtc=2",
53 'wtc7' => "-wtc=h -atc -dtc -vtc=2",
56 ############################
57 # BEGIN SECTION 2: Sources #
58 ############################
61 'bfvt' => <<'----------',
62 # combines with -bfvt>0
65 XSLoader::load( 'Sys::Syslog', $VERSION );
70 push @ISA, 'DynaLoader';
71 bootstrap Sys::Syslog $VERSION;
74 # combines with -bfvt=2
76 ( $line, $cond ) = $self->_normalize_if_elif($line);
79 or die sprintf "Error at line %d\nLine %d: %s\n%s",
80 ( $line_info->start_line_num() ) x 2, $line, $@;
82 # stable for bfvt<2; combines for bfvt=2; has ci
86 Net::Domain::hostfqdn();
90 # stays combined for all bfvt; has ci
94 Net::Domain::hostfqdn();
98 'cpb' => <<'----------',
100 '05_lexer', '07_token', '08_regression', '11_util',
101 '13_data', '15_transform'
104 my @perl = find_files( catdir( 't', 'data', $dir ) );
110 'dwic' => <<'----------',
121 'olbxl' => <<'----------',
126 $frm{ ( /@(.*?)>/ ? $1 : $_ ) }++ ? () : ($_);
132 $color_value{$::a} <=> $color_value{$::b};
137 $SortDir * $PageTotal{$a} <=> $SortDir * $PageTotal{$b}
141 'rt144979' => <<'----------',
144 "format|f=s" => sub {
146 if ( ( my $k = $formats{$v} ) ) {
149 die("--format must be 'system' or 'user'\n");
159 ? "for -$op under use filetest 'access' $desc_tail"
160 : "for -$op $desc_tail";
162 local $SIG{__WARN__} = sub {
164 if ($w =~ /^File::stat ignores VMS ACLs/)
168 $w =~ /^File::stat ignores use filetest 'access'/)
176 $rv = eval "$access; -$op \$stat";
182 'rt145706' => <<'----------',
183 # some tests for default setting --use-feature=class, rt145706
184 class Example::Subclass1 : isa(Example::Base) { ... }
185 class Example::Subclass2 : isa(Example::Base 2.345) { ... }
186 class Example::Subclass3 : isa(Example::Base) 1.345 { ... }
187 field $y : param(the_y_value);
201 # these should not produce errors
202 method paint => sub {
210 is( ( method Pack "a", "b", "c" ), "method,a,b,c" );
211 class ExtendsBasicAttributes is BasicAttributes{
214 class BrokenExtendsBasicAttributes
218 class +Night with +Bad {
219 public nine { return 'crazy' }
224 'wtc' => <<'----------',
225 # both single and multiple line lists:
227 [ "fred", "barney", ],
228 [ "george", "jane", "elroy" ],
229 [ "homer", "marge", "bart", ],
233 ( $name, $body ) = ( $2, $3, );
235 # multiline, but not bare
236 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
237 selectbackgroundxxxxx => 'yellow', );
239 # this will pass for 'h'
255 'rectangle', 40, 60, 80, 80,
263 $target_binary = $fs->Show( -popover => 'cursor', -create => 1, );
265 )->pack( -side => 'left', );
269 { ':key' => { name => \&string, list => { value => \&string }, }, }, };
275 ####################################
276 # BEGIN SECTION 3: Expected output #
277 ####################################
283 expect => <<'#1...........',
284 # both single and multiple line lists:
286 [ "fred", "barney" ],
287 [ "george", "jane", "elroy" ],
288 [ "homer", "marge", "bart" ]
292 ( $name, $body ) = ( $2, $3 );
294 # multiline, but not bare
295 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
296 selectbackgroundxxxxx => 'yellow' );
298 # this will pass for 'h'
314 'rectangle', 40, 60, 80, 80,
322 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
324 )->pack( -side => 'left' );
327 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
336 expect => <<'#2...........',
337 # both single and multiple line lists:
339 [ "fred", "barney", ],
340 [ "george", "jane", "elroy", ],
341 [ "homer", "marge", "bart", ],
345 ( $name, $body, ) = ( $2, $3, );
347 # multiline, but not bare
348 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
349 selectbackgroundxxxxx => 'yellow', );
351 # this will pass for 'h'
367 'rectangle', 40, 60, 80, 80,
369 -tags => 'rectangle',
375 $target_binary = $fs->Show( -popover => 'cursor', -create => 1, );
377 )->pack( -side => 'left', );
381 { ':key' => { name => \&string, list => { value => \&string }, }, }, };
389 expect => <<'#3...........',
390 # both single and multiple line lists:
392 [ "fred", "barney", ],
393 [ "george", "jane", "elroy" ],
394 [ "homer", "marge", "bart", ],
398 ( $name, $body ) = ( $2, $3, );
400 # multiline, but not bare
401 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
402 selectbackgroundxxxxx => 'yellow', );
404 # this will pass for 'h'
420 'rectangle', 40, 60, 80, 80,
422 -tags => 'rectangle',
428 $target_binary = $fs->Show( -popover => 'cursor', -create => 1, );
430 )->pack( -side => 'left', );
434 { ':key' => { name => \&string, list => { value => \&string }, }, }, };
442 expect => <<'#4...........',
443 # both single and multiple line lists:
445 [ "fred", "barney" ],
446 [ "george", "jane", "elroy" ],
447 [ "homer", "marge", "bart" ],
451 ( $name, $body ) = ( $2, $3 );
453 # multiline, but not bare
454 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
455 selectbackgroundxxxxx => 'yellow', );
457 # this will pass for 'h'
473 'rectangle', 40, 60, 80, 80,
475 -tags => 'rectangle',
481 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
483 )->pack( -side => 'left' );
486 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } },
495 expect => <<'#5...........',
496 # both single and multiple line lists:
498 [ "fred", "barney" ],
499 [ "george", "jane", "elroy" ],
500 [ "homer", "marge", "bart" ],
504 ( $name, $body ) = ( $2, $3 );
506 # multiline, but not bare
507 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
508 selectbackgroundxxxxx => 'yellow' );
510 # this will pass for 'h'
526 'rectangle', 40, 60, 80, 80,
528 -tags => 'rectangle',
534 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
536 )->pack( -side => 'left' );
539 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
548 expect => <<'#6...........',
549 # both single and multiple line lists:
551 [ "fred", "barney" ],
552 [ "george", "jane", "elroy" ],
553 [ "homer", "marge", "bart" ] );
556 ( $name, $body ) = ( $2, $3 );
558 # multiline, but not bare
559 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
560 selectbackgroundxxxxx => 'yellow' );
562 # this will pass for 'h'
578 'rectangle', 40, 60, 80, 80,
580 -tags => 'rectangle' );
585 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
587 )->pack( -side => 'left' );
590 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
599 expect => <<'#7...........',
616 expect => <<'#8...........',
629 expect => <<'#9...........',
630 # both single and multiple line lists:
632 [ "fred", "barney" ],
633 [ "george", "jane", "elroy" ],
634 [ "homer", "marge", "bart" ] );
637 ( $name, $body ) = ( $2, $3 );
639 # multiline, but not bare
640 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
641 selectbackgroundxxxxx => 'yellow' );
643 # this will pass for 'h'
658 'rectangle', 40, 60, 80, 80,
660 -tags => 'rectangle' );
665 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
667 )->pack( -side => 'left' );
670 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
677 source => "rt144979",
679 expect => <<'#10...........',
682 "format|f=s" => sub {
684 if ( ( my $k = $formats{$v} ) ) {
688 die("--format must be 'system' or 'user'\n");
700 ? "for -$op under use filetest 'access' $desc_tail"
701 : "for -$op $desc_tail";
703 local $SIG{__WARN__} = sub {
705 if ( $w =~ /^File::stat ignores VMS ACLs/ ) {
708 elsif ( $w =~ /^File::stat ignores use filetest 'access'/ )
716 $rv = eval "$access; -$op \$stat";
725 'rt144979.rt144979' => {
726 source => "rt144979",
727 params => "rt144979",
728 expect => <<'#11...........',
731 "format|f=s" => sub {
733 if ( ( my $k = $formats{$v} ) ) {
736 die("--format must be 'system' or 'user'\n");
748 ? "for -$op under use filetest 'access' $desc_tail"
749 : "for -$op $desc_tail";
751 local $SIG{__WARN__} = sub {
753 if ( $w =~ /^File::stat ignores VMS ACLs/ ) {
756 $w =~ /^File::stat ignores use filetest 'access'/ )
763 $rv = eval "$access; -$op \$stat";
775 expect => <<'#12...........',
776 # combines with -bfvt>0
779 XSLoader::load( 'Sys::Syslog', $VERSION );
784 push @ISA, 'DynaLoader';
785 bootstrap Sys::Syslog $VERSION;
788 # combines with -bfvt=2
790 ( $line, $cond ) = $self->_normalize_if_elif($line);
793 or die sprintf "Error at line %d\nLine %d: %s\n%s",
794 ( $line_info->start_line_num() ) x 2, $line, $@;
796 # stable for bfvt<2; combines for bfvt=2; has ci
800 Net::Domain::hostfqdn();
804 # stays combined for all bfvt; has ci
808 Net::Domain::hostfqdn();
816 expect => <<'#13...........',
817 # combines with -bfvt>0
820 XSLoader::load( 'Sys::Syslog', $VERSION );
824 push @ISA, 'DynaLoader';
825 bootstrap Sys::Syslog $VERSION;
828 # combines with -bfvt=2
830 ( $line, $cond ) = $self->_normalize_if_elif($line);
832 } or die sprintf "Error at line %d\nLine %d: %s\n%s",
833 ( $line_info->start_line_num() ) x 2, $line, $@;
835 # stable for bfvt<2; combines for bfvt=2; has ci
839 Net::Domain::hostfqdn();
842 # stays combined for all bfvt; has ci
846 Net::Domain::hostfqdn();
854 expect => <<'#14...........',
855 # combines with -bfvt>0
858 XSLoader::load( 'Sys::Syslog', $VERSION );
862 push @ISA, 'DynaLoader';
863 bootstrap Sys::Syslog $VERSION;
866 # combines with -bfvt=2
868 ( $line, $cond ) = $self->_normalize_if_elif($line);
871 or die sprintf "Error at line %d\nLine %d: %s\n%s",
872 ( $line_info->start_line_num() ) x 2, $line, $@;
874 # stable for bfvt<2; combines for bfvt=2; has ci
878 Net::Domain::hostfqdn();
882 # stays combined for all bfvt; has ci
886 Net::Domain::hostfqdn();
894 expect => <<'#15...........',
896 '05_lexer', '07_token', '08_regression', '11_util',
897 '13_data', '15_transform'
899 my @perl = find_files( catdir( 't', 'data', $dir ) );
909 expect => <<'#16...........',
911 '05_lexer', '07_token', '08_regression', '11_util',
912 '13_data', '15_transform'
915 my @perl = find_files( catdir( 't', 'data', $dir ) );
923 source => "rt145706",
925 expect => <<'#17...........',
926 # some tests for default setting --use-feature=class, rt145706
927 class Example::Subclass1 : isa(Example::Base) { ... }
928 class Example::Subclass2 : isa(Example::Base 2.345) { ... }
929 class Example::Subclass3 : isa(Example::Base) 1.345 { ... }
930 field $y : param(the_y_value);
944 # these should not produce errors
945 method paint => sub {
953 is( ( method Pack "a", "b", "c" ), "method,a,b,c" );
954 class ExtendsBasicAttributes is BasicAttributes {
957 class BrokenExtendsBasicAttributes is BasicAttributes {
960 class +Night with +Bad {
961 public nine { return 'crazy' }
970 expect => <<'#18...........',
971 eval { require Ace };
974 map { $frm{ ( /@(.*?)>/ ? $1 : $_ ) }++ ? () : ($_); } @list;
977 sort { $color_value{$::a} <=> $color_value{$::b}; }
981 sort { $SortDir * $PageTotal{$a} <=> $SortDir * $PageTotal{$b} };
988 expect => <<'#19...........',
994 map { $frm{ ( /@(.*?)>/ ? $1 : $_ ) }++ ? () : ($_); } @list;
997 sort { $color_value{$::a} <=> $color_value{$::b}; }
1001 sort { $SortDir * $PageTotal{$a} <=> $SortDir * $PageTotal{$b} };
1006 my $ntests = 0 + keys %{$rtests};
1007 plan tests => $ntests;
1014 foreach my $key ( sort keys %{$rtests} ) {
1016 my $sname = $rtests->{$key}->{source};
1017 my $expect = $rtests->{$key}->{expect};
1018 my $pname = $rtests->{$key}->{params};
1019 my $source = $rsources->{$sname};
1020 my $params = defined($pname) ? $rparams->{$pname} : "";
1022 my $errorfile_string;
1023 my $err = Perl::Tidy::perltidy(
1025 destination => \$output,
1026 perltidyrc => \$params,
1027 argv => '', # for safety; hide any ARGV from perltidy
1028 stderr => \$stderr_string,
1029 errorfile => \$errorfile_string, # not used when -se flag is set
1031 if ( $err || $stderr_string || $errorfile_string ) {
1032 print STDERR "Error output received for test '$key'\n";
1034 print STDERR "An error flag '$err' was returned\n";
1037 if ($stderr_string) {
1038 print STDERR "---------------------\n";
1039 print STDERR "<<STDERR>>\n$stderr_string\n";
1040 print STDERR "---------------------\n";
1041 ok( !$stderr_string );
1043 if ($errorfile_string) {
1044 print STDERR "---------------------\n";
1045 print STDERR "<<.ERR file>>\n$errorfile_string\n";
1046 print STDERR "---------------------\n";
1047 ok( !$errorfile_string );
1051 if ( !is( $output, $expect, $key ) ) {
1052 my $leno = length($output);
1053 my $lene = length($expect);
1054 if ( $leno == $lene ) {
1056 "#> Test '$key' gave unexpected output. Strings differ but both have length $leno\n";
1060 "#> Test '$key' gave unexpected output. String lengths differ: output=$leno, expected=$lene\n";