1 # Created with: ./make_t.pl
16 # To locate test #13 you can search for its name or the string '#13'
28 ###########################################
29 # BEGIN SECTION 1: Parameter combinations #
30 ###########################################
33 'dwic' => "-wn -dwic",
34 'rt144979' => "-xci -ce -lp",
35 'wtc1' => "-wtc=0 -dtc",
36 'wtc2' => "-wtc=1 -atc",
37 'wtc3' => "-wtc=m -atc",
38 'wtc4' => "-wtc=m -atc -dtc",
39 'wtc5' => "-wtc=b -atc -dtc -vtc=2",
40 'wtc6' => "-wtc=i -atc -dtc -vtc=2",
41 'wtc7' => "-wtc=h -atc -dtc -vtc=2",
44 ############################
45 # BEGIN SECTION 2: Sources #
46 ############################
49 'dwic' => <<'----------',
60 'rt144979' => <<'----------',
65 if ( ( my $k = $formats{$v} ) ) {
68 die("--format must be 'system' or 'user'\n");
78 ? "for -$op under use filetest 'access' $desc_tail"
79 : "for -$op $desc_tail";
81 local $SIG{__WARN__} = sub {
83 if ($w =~ /^File::stat ignores VMS ACLs/)
87 $w =~ /^File::stat ignores use filetest 'access'/)
95 $rv = eval "$access; -$op \$stat";
101 'wtc' => <<'----------',
102 # both single and multiple line lists:
104 [ "fred", "barney", ],
105 [ "george", "jane", "elroy" ],
106 [ "homer", "marge", "bart", ],
110 ( $name, $body ) = ( $2, $3, );
112 # multiline, but not bare
113 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
114 selectbackgroundxxxxx => 'yellow', );
116 # this will pass for 'h'
132 'rectangle', 40, 60, 80, 80,
140 $target_binary = $fs->Show( -popover => 'cursor', -create => 1, );
142 )->pack( -side => 'left', );
146 { ':key' => { name => \&string, list => { value => \&string }, }, }, };
152 ####################################
153 # BEGIN SECTION 3: Expected output #
154 ####################################
160 expect => <<'#1...........',
161 # both single and multiple line lists:
163 [ "fred", "barney" ],
164 [ "george", "jane", "elroy" ],
165 [ "homer", "marge", "bart" ]
169 ( $name, $body ) = ( $2, $3 );
171 # multiline, but not bare
172 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
173 selectbackgroundxxxxx => 'yellow' );
175 # this will pass for 'h'
191 'rectangle', 40, 60, 80, 80,
199 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
201 )->pack( -side => 'left' );
204 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
213 expect => <<'#2...........',
214 # both single and multiple line lists:
216 [ "fred", "barney", ],
217 [ "george", "jane", "elroy", ],
218 [ "homer", "marge", "bart", ],
222 ( $name, $body, ) = ( $2, $3, );
224 # multiline, but not bare
225 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
226 selectbackgroundxxxxx => 'yellow', );
228 # this will pass for 'h'
244 'rectangle', 40, 60, 80, 80,
246 -tags => 'rectangle',
252 $target_binary = $fs->Show( -popover => 'cursor', -create => 1, );
254 )->pack( -side => 'left', );
258 { ':key' => { name => \&string, list => { value => \&string }, }, }, };
266 expect => <<'#3...........',
267 # both single and multiple line lists:
269 [ "fred", "barney", ],
270 [ "george", "jane", "elroy" ],
271 [ "homer", "marge", "bart", ],
275 ( $name, $body ) = ( $2, $3, );
277 # multiline, but not bare
278 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
279 selectbackgroundxxxxx => 'yellow', );
281 # this will pass for 'h'
297 'rectangle', 40, 60, 80, 80,
299 -tags => 'rectangle',
305 $target_binary = $fs->Show( -popover => 'cursor', -create => 1, );
307 )->pack( -side => 'left', );
311 { ':key' => { name => \&string, list => { value => \&string }, }, }, };
319 expect => <<'#4...........',
320 # both single and multiple line lists:
322 [ "fred", "barney" ],
323 [ "george", "jane", "elroy" ],
324 [ "homer", "marge", "bart" ],
328 ( $name, $body ) = ( $2, $3 );
330 # multiline, but not bare
331 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
332 selectbackgroundxxxxx => 'yellow', );
334 # this will pass for 'h'
350 'rectangle', 40, 60, 80, 80,
352 -tags => 'rectangle',
358 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
360 )->pack( -side => 'left' );
363 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } },
372 expect => <<'#5...........',
373 # both single and multiple line lists:
375 [ "fred", "barney" ],
376 [ "george", "jane", "elroy" ],
377 [ "homer", "marge", "bart" ],
381 ( $name, $body ) = ( $2, $3 );
383 # multiline, but not bare
384 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
385 selectbackgroundxxxxx => 'yellow' );
387 # this will pass for 'h'
403 'rectangle', 40, 60, 80, 80,
405 -tags => 'rectangle',
411 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
413 )->pack( -side => 'left' );
416 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
425 expect => <<'#6...........',
426 # both single and multiple line lists:
428 [ "fred", "barney" ],
429 [ "george", "jane", "elroy" ],
430 [ "homer", "marge", "bart" ] );
433 ( $name, $body ) = ( $2, $3 );
435 # multiline, but not bare
436 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
437 selectbackgroundxxxxx => 'yellow' );
439 # this will pass for 'h'
455 'rectangle', 40, 60, 80, 80,
457 -tags => 'rectangle' );
462 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
464 )->pack( -side => 'left' );
467 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
476 expect => <<'#7...........',
493 expect => <<'#8...........',
506 expect => <<'#9...........',
507 # both single and multiple line lists:
509 [ "fred", "barney" ],
510 [ "george", "jane", "elroy" ],
511 [ "homer", "marge", "bart" ] );
514 ( $name, $body ) = ( $2, $3 );
516 # multiline, but not bare
517 $text = $main->Scrolled( TextUndo, $yyy, $zzz, $wwwww,
518 selectbackgroundxxxxx => 'yellow' );
520 # this will pass for 'h'
535 'rectangle', 40, 60, 80, 80,
537 -tags => 'rectangle' );
542 $target_binary = $fs->Show( -popover => 'cursor', -create => 1 );
544 )->pack( -side => 'left' );
547 { 'map' => { ':key' => { name => \&string, list => { value => \&string } } }
554 source => "rt144979",
556 expect => <<'#10...........',
559 "format|f=s" => sub {
561 if ( ( my $k = $formats{$v} ) ) {
565 die("--format must be 'system' or 'user'\n");
577 ? "for -$op under use filetest 'access' $desc_tail"
578 : "for -$op $desc_tail";
580 local $SIG{__WARN__} = sub {
582 if ( $w =~ /^File::stat ignores VMS ACLs/ ) {
585 elsif ( $w =~ /^File::stat ignores use filetest 'access'/ )
593 $rv = eval "$access; -$op \$stat";
602 'rt144979.rt144979' => {
603 source => "rt144979",
604 params => "rt144979",
605 expect => <<'#11...........',
608 "format|f=s" => sub {
610 if ( ( my $k = $formats{$v} ) ) {
613 die("--format must be 'system' or 'user'\n");
625 ? "for -$op under use filetest 'access' $desc_tail"
626 : "for -$op $desc_tail";
628 local $SIG{__WARN__} = sub {
630 if ( $w =~ /^File::stat ignores VMS ACLs/ ) {
633 $w =~ /^File::stat ignores use filetest 'access'/ )
640 $rv = eval "$access; -$op \$stat";
650 my $ntests = 0 + keys %{$rtests};
651 plan tests => $ntests;
658 foreach my $key ( sort keys %{$rtests} ) {
660 my $sname = $rtests->{$key}->{source};
661 my $expect = $rtests->{$key}->{expect};
662 my $pname = $rtests->{$key}->{params};
663 my $source = $rsources->{$sname};
664 my $params = defined($pname) ? $rparams->{$pname} : "";
666 my $errorfile_string;
667 my $err = Perl::Tidy::perltidy(
669 destination => \$output,
670 perltidyrc => \$params,
671 argv => '', # for safety; hide any ARGV from perltidy
672 stderr => \$stderr_string,
673 errorfile => \$errorfile_string, # not used when -se flag is set
675 if ( $err || $stderr_string || $errorfile_string ) {
676 print STDERR "Error output received for test '$key'\n";
678 print STDERR "An error flag '$err' was returned\n";
681 if ($stderr_string) {
682 print STDERR "---------------------\n";
683 print STDERR "<<STDERR>>\n$stderr_string\n";
684 print STDERR "---------------------\n";
685 ok( !$stderr_string );
687 if ($errorfile_string) {
688 print STDERR "---------------------\n";
689 print STDERR "<<.ERR file>>\n$errorfile_string\n";
690 print STDERR "---------------------\n";
691 ok( !$errorfile_string );
695 if ( !is( $output, $expect, $key ) ) {
696 my $leno = length($output);
697 my $lene = length($expect);
698 if ( $leno == $lene ) {
700 "#> Test '$key' gave unexpected output. Strings differ but both have length $leno\n";
704 "#> Test '$key' gave unexpected output. String lengths differ: output=$leno, expected=$lene\n";