1 # Created with: ./make_t.pl
9 #6 essential.essential1
10 #7 essential.essential2
20 #17 fabrice_bug.fabrice_bug
25 # To locate test #13 you can search for its name or the string '#13'
37 ###########################################
38 # BEGIN SECTION 1: Parameter combinations #
39 ###########################################
41 'ce_wn' => <<'----------',
45 'colin' => <<'----------',
62 'essential1' => <<'----------',
76 'essential2' => "-extrude",
77 'extrude' => "--extrude",
78 'fabrice_bug' => "-bt=0",
81 ############################
82 # BEGIN SECTION 2: Sources #
83 ############################
86 'ce_wn1' => <<'----------',
90 join( '', ' < B > ', &make_math( $mode, '', '', $_ ), ' < /B>' )
95 &process_math_in_latex( $mode, $math_style, $slevel, "\\mbox{$text}" ),
101 'colin' => <<'----------',
105 Title => 'An example of errb and points',
110 'essential' => <<'----------',
111 # Run with mangle to squeeze out the white space
112 # also run with extrude
114 # never combine two bare words or numbers
121 # do not combine 'overload::' and 'and'
122 if $self->{bareStringify} and ref $_
123 and defined %overload:: and defined &{'overload::StrVal'};
125 # do not combine 'SINK' and 'if'
126 my $size=-s::SINK if $file;
128 # do not combine to make $inputeq"quit"
129 if ($input eq"quit");
131 # do not combine a number with a concatenation dot to get a float '78.'
132 $vt100_compatible ? "\e[0;0H" : ('-' x 78 . "\n");
134 # do not join a minus with a bare word, because you might form
135 # a file test operator. Here "z-i" would be taken as a file test.
136 if (CORE::abs($z - i) < $eps);
138 # '= -' should not become =- or you will get a warning
140 # and something like these could become ambiguous without space
146 # keep a space between a token ending in '$' and any word;
149 # avoid combining tokens to create new meanings. Example:
150 # this must not become $a++$b
153 # another example: do not combine these two &'s:
154 allow_options & &OPT_EXECCGI;
156 # Perl is sensitive to whitespace after the + here:
157 $b = xvals $a + 0.1 * yvals $a;
159 # keep paren separate here:
162 # need space after foreach my; for example, this will fail in
163 # older versions of Perl:
164 foreach my$ft(@filetypes)...
166 # must retain space between grep and left paren; "grep(" may fail
167 my $match = grep (m/^-extrude$/, @list) ? 1 : 0;
169 # don't stick numbers next to left parens, as in:
170 use Mail::Internet 1.28 ();
172 # do not remove space between an '&' and a bare word because
173 # it may turn into a function evaluation, like here
174 # between '&' and 'O_ACCMODE', producing a syntax error [File.pm]
175 $opts{rdonly} = (($opts{mode} & O_ACCMODE) == O_RDONLY);
178 'extrude1' => <<'----------',
179 # do not break before the ++
183 'extrude2' => <<'----------',
184 if (-l pid_filename()) {
185 return readlink(pid_filename());
189 'extrude3' => <<'----------',
190 # Breaking before a ++ can cause perl to guess wrong
191 print( ( $i++ & 1 ) ? $_ : ( $change{$_} || $_ ) );
193 # Space between '&' and 'O_ACCMODE' is essential here
194 $opts{rdonly} = (($opts{mode} & O_ACCMODE) == O_RDONLY);
197 'extrude4' => <<'----------',
198 # From Safe.pm caused trouble with extrude
200 opset opset_to_ops opmask_add
201 empty_opset full_opset invert_opset verify_opset
202 opdesc opcodes opmask define_optag opset_to_hex
206 'fabrice_bug' => <<'----------',
207 # no space around ^variable with -bt=0
208 my $before = ${^PREMATCH};
209 my $after = ${PREMATCH};
212 'format1' => <<'----------',
215 @<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
218 print "Available strips:\n";
219 for ( split ( /\|/, $known_strips ) ) {
220 $val = $defs{$_}{'name'};
226 'given1' => <<'----------',
230 when (1) { ok($count==1) }
231 else { ok($count!=1) }
232 when ([5,6]) { ok(0) } else { ok(1) }
239 'gnu1' => <<'----------',
240 @common_sometimes = (
241 "aclocal.m4", "acconfig.h", "config.h.top", "config.h.bot",
242 "stamp-h.in", 'stamp-vti'
247 ####################################
248 # BEGIN SECTION 3: Expected output #
249 ####################################
255 expect => <<'#1...........',
258 join( '', ' < B > ', &make_math( $mode, '', '', $_ ), ' < /B>' )
260 &process_math_in_latex( $mode, $math_style, $slevel, "\\mbox{$text}" ),
269 expect => <<'#2...........',
273 join( '', ' < B > ', &make_math( $mode, '', '', $_ ), ' < /B>' )
278 &process_math_in_latex( $mode, $math_style, $slevel, "\\mbox{$text}" ),
288 expect => <<'#3...........',
292 Title => 'An example of errb and points',
301 expect => <<'#4...........',
307 Title => 'An example of errb and points',
315 source => "essential",
317 expect => <<'#5...........',
318 # Run with mangle to squeeze out the white space
319 # also run with extrude
321 # never combine two bare words or numbers
328 # do not combine 'overload::' and 'and'
329 if $self->{bareStringify}
331 and defined %overload::
332 and defined &{'overload::StrVal'};
334 # do not combine 'SINK' and 'if'
335 my $size = -s ::SINK if $file;
337 # do not combine to make $inputeq"quit"
338 if ( $input eq "quit" );
340 # do not combine a number with a concatenation dot to get a float '78.'
341 $vt100_compatible ? "\e[0;0H" : ( '-' x 78 . "\n" );
343 # do not join a minus with a bare word, because you might form
344 # a file test operator. Here "z-i" would be taken as a file test.
345 if ( CORE::abs( $z - i ) < $eps );
347 # '= -' should not become =- or you will get a warning
349 # and something like these could become ambiguous without space
351 use constant III => 1;
355 # keep a space between a token ending in '$' and any word;
358 # avoid combining tokens to create new meanings. Example:
359 # this must not become $a++$b
362 # another example: do not combine these two &'s:
363 allow_options & &OPT_EXECCGI;
365 # Perl is sensitive to whitespace after the + here:
366 $b = xvals $a + 0.1 * yvals $a;
368 # keep paren separate here:
371 # need space after foreach my; for example, this will fail in
372 # older versions of Perl:
373 foreach my $ft (@filetypes) ...
375 # must retain space between grep and left paren; "grep(" may fail
376 my $match = grep ( m/^-extrude$/, @list ) ? 1 : 0;
378 # don't stick numbers next to left parens, as in:
379 use Mail::Internet 1.28 ();
381 # do not remove space between an '&' and a bare word because
382 # it may turn into a function evaluation, like here
383 # between '&' and 'O_ACCMODE', producing a syntax error [File.pm]
384 $opts{rdonly} = ( ( $opts{mode} & O_ACCMODE ) == O_RDONLY );
388 'essential.essential1' => {
389 source => "essential",
390 params => "essential1",
391 expect => <<'#6...........',
392 # Run with mangle to squeeze out the white space
393 # also run with extrude
394 # never combine two bare words or numbers
398 # do not combine 'overload::' and 'and'
399 if$self->{bareStringify}and ref$_ and defined%overload:: and defined&{'overload::StrVal'};
400 # do not combine 'SINK' and 'if'
401 my$size=-s::SINK if$file;
402 # do not combine to make $inputeq"quit"
404 # do not combine a number with a concatenation dot to get a float '78.'
405 $vt100_compatible?"\e[0;0H":('-' x 78 ."\n");
406 # do not join a minus with a bare word, because you might form
407 # a file test operator. Here "z-i" would be taken as a file test.
408 if(CORE::abs($z- i)<$eps);
409 # '= -' should not become =- or you will get a warning
410 # and something like these could become ambiguous without space
415 # keep a space between a token ending in '$' and any word;
417 # avoid combining tokens to create new meanings. Example:
418 # this must not become $a++$b
420 # another example: do not combine these two &'s:
421 allow_options& &OPT_EXECCGI;
422 # Perl is sensitive to whitespace after the + here:
423 $b=xvals$a + 0.1*yvals$a;
424 # keep paren separate here:
426 # need space after foreach my; for example, this will fail in
427 # older versions of Perl:
428 foreach my$ft(@filetypes)...
429 # must retain space between grep and left paren; "grep(" may fail
430 my$match=grep (m/^-extrude$/,@list)?1:0;
431 # don't stick numbers next to left parens, as in:
432 use Mail::Internet 1.28 ();
433 # do not remove space between an '&' and a bare word because
434 # it may turn into a function evaluation, like here
435 # between '&' and 'O_ACCMODE', producing a syntax error [File.pm]
436 $opts{rdonly}=(($opts{mode}& O_ACCMODE)==O_RDONLY);
440 'essential.essential2' => {
441 source => "essential",
442 params => "essential2",
443 expect => <<'#7...........',
444 # Run with mangle to squeeze out the white space
445 # also run with extrude
446 # never combine two bare words or numbers
462 # do not combine 'overload::' and 'and'
479 # do not combine 'SINK' and 'if'
486 # do not combine to make $inputeq"quit"
494 # do not combine a number with a concatenation dot to get a float '78.'
506 # do not join a minus with a bare word, because you might form
507 # a file test operator. Here "z-i" would be taken as a file test.
520 # '= -' should not become =- or you will get a warning
521 # and something like these could become ambiguous without space
539 # keep a space between a token ending in '$' and any word;
545 # avoid combining tokens to create new meanings. Example:
546 # this must not become $a++$b
552 # another example: do not combine these two &'s:
557 # Perl is sensitive to whitespace after the + here:
565 # keep paren separate here:
570 # need space after foreach my; for example, this will fail in
571 # older versions of Perl:
578 # must retain space between grep and left paren; "grep(" may fail
592 # don't stick numbers next to left parens, as in:
599 # do not remove space between an '&' and a bare word because
600 # it may turn into a function evaluation, like here
601 # between '&' and 'O_ACCMODE', producing a syntax error [File.pm]
618 source => "extrude1",
620 expect => <<'#8...........',
621 # do not break before the ++
626 'extrude1.extrude' => {
627 source => "extrude1",
629 expect => <<'#9...........',
630 # do not break before the ++
639 source => "extrude2",
641 expect => <<'#10...........',
642 if ( -l pid_filename() ) {
643 return readlink( pid_filename() );
648 'extrude2.extrude' => {
649 source => "extrude2",
651 expect => <<'#11...........',
670 source => "extrude3",
672 expect => <<'#12...........',
673 # Breaking before a ++ can cause perl to guess wrong
674 print( ( $i++ & 1 ) ? $_ : ( $change{$_} || $_ ) );
676 # Space between '&' and 'O_ACCMODE' is essential here
677 $opts{rdonly} = ( ( $opts{mode} & O_ACCMODE ) == O_RDONLY );
681 'extrude3.extrude' => {
682 source => "extrude3",
684 expect => <<'#13...........',
685 # Breaking before a ++ can cause perl to guess wrong
705 # Space between '&' and 'O_ACCMODE' is essential here
722 source => "extrude4",
724 expect => <<'#14...........',
725 # From Safe.pm caused trouble with extrude
727 opset opset_to_ops opmask_add
728 empty_opset full_opset invert_opset verify_opset
729 opdesc opcodes opmask define_optag opset_to_hex
734 'extrude4.extrude' => {
735 source => "extrude4",
737 expect => <<'#15...........',
738 # From Safe.pm caused trouble with extrude
744 opset opset_to_ops opmask_add
745 empty_opset full_opset invert_opset verify_opset
746 opdesc opcodes opmask define_optag opset_to_hex
752 'fabrice_bug.def' => {
753 source => "fabrice_bug",
755 expect => <<'#16...........',
756 # no space around ^variable with -bt=0
757 my $before = ${^PREMATCH};
758 my $after = ${PREMATCH};
762 'fabrice_bug.fabrice_bug' => {
763 source => "fabrice_bug",
764 params => "fabrice_bug",
765 expect => <<'#17...........',
766 # no space around ^variable with -bt=0
767 my $before = ${^PREMATCH};
768 my $after = ${ PREMATCH };
775 expect => <<'#18...........',
778 @<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
781 print "Available strips:\n";
782 for ( split( /\|/, $known_strips ) ) {
783 $val = $defs{$_}{'name'};
793 expect => <<'#19...........',
794 given ( [ 9, "a", 11 ] ) {
797 when (1) { ok( $count == 1 ) }
798 else { ok( $count != 1 ) }
799 when ( [ 5, 6 ] ) { ok(0) }
811 expect => <<'#20...........',
812 @common_sometimes = (
813 "aclocal.m4", "acconfig.h", "config.h.top", "config.h.bot",
814 "stamp-h.in", 'stamp-vti'
820 my $ntests = 0 + keys %{$rtests};
821 plan tests => $ntests;
828 foreach my $key ( sort keys %{$rtests} ) {
830 my $sname = $rtests->{$key}->{source};
831 my $expect = $rtests->{$key}->{expect};
832 my $pname = $rtests->{$key}->{params};
833 my $source = $rsources->{$sname};
834 my $params = defined($pname) ? $rparams->{$pname} : "";
836 my $errorfile_string;
837 my $err = Perl::Tidy::perltidy(
839 destination => \$output,
840 perltidyrc => \$params,
841 argv => '', # for safety; hide any ARGV from perltidy
842 stderr => \$stderr_string,
843 errorfile => \$errorfile_string, # not used when -se flag is set
845 if ( $err || $stderr_string || $errorfile_string ) {
846 print STDERR "Error output received for test '$key'\n";
848 print STDERR "An error flag '$err' was returned\n";
851 if ($stderr_string) {
852 print STDERR "---------------------\n";
853 print STDERR "<<STDERR>>\n$stderr_string\n";
854 print STDERR "---------------------\n";
855 ok( !$stderr_string );
857 if ($errorfile_string) {
858 print STDERR "---------------------\n";
859 print STDERR "<<.ERR file>>\n$errorfile_string\n";
860 print STDERR "---------------------\n";
861 ok( !$errorfile_string );
865 if ( !is( $output, $expect, $key ) ) {
866 my $leno = length($output);
867 my $lene = length($expect);
868 if ( $leno == $lene ) {
870 "#> Test '$key' gave unexpected output. Strings differ but both have length $leno\n";
874 "#> Test '$key' gave unexpected output. String lengths differ: output=$leno, expected=$lene\n";