1 # Created with: ./make_t.pl
10 # To locate test #13 you can search for its name or the string '#13'
22 ###########################################
23 # BEGIN SECTION 1: Parameter combinations #
24 ###########################################
27 'olbxl2' => <<'----------',
32 ############################
33 # BEGIN SECTION 2: Sources #
34 ############################
37 'olbxl' => <<'----------',
42 $frm{ ( /@(.*?)>/ ? $1 : $_ ) }++ ? () : ($_);
48 $color_value{$::a} <=> $color_value{$::b};
53 $SortDir * $PageTotal{$a} <=> $SortDir * $PageTotal{$b}
57 'recombine5' => <<'----------',
58 # recombine uses reverse optimization
59 $rotate = Math::MatrixReal->new_from_string( "[ " . cos($theta) . " " . -sin($theta) . " ]\n" . "[ " . sin($theta) . " " . cos($theta) . " ]\n" );
62 'recombine6' => <<'----------',
63 # recombine operation uses forward optimization
66 (s/^\+//) ? $filecol + $_ :
67 (s/^\-//) ? $filecol - $_ :
68 (s/^>//) ? ($filecol + $_) % $pages :
69 (s/^]//) ? (($filecol + $_ >= $pages) ? 0 : $filecol + $_) :
70 (s/^<//) ? ($filecol - $_) % $pages :
71 (s/^\[//) ? (($filecol == 0) ? $pages - ($pages % $_ || $_) :
72 ($filecol - $_ < 0) ? 0 : $filecol - $_) :
74 (s/^\\?//) ? (($col{$_}, $row{$_}) = &pageto($_))[0] : 0;
77 'recombine7' => <<'----------',
78 # recombine uses forward optimization, must recombine at =
79 my $J = int( 365.25 * ( $y + 4712 ) ) +
80 int( ( 30.6 * $m ) + 0.5 ) + 59 + $d - 0.5;
83 'recombine8' => <<'----------',
84 # recombine uses normal forward mode
85 $v_gb = -1*(eval($pmt_gb))*(-1+((((-1+(1/((eval($i_gb)/100)+1))** ((eval($n_gb)-1)))))/(eval($i_gb)/100)));
89 ####################################
90 # BEGIN SECTION 3: Expected output #
91 ####################################
97 expect => <<'#1...........',
103 $frm{ ( /@(.*?)>/ ? $1 : $_ ) }++ ? () : ($_);
109 $color_value{$::a} <=> $color_value{$::b};
114 $SortDir * $PageTotal{$a} <=> $SortDir * $PageTotal{$b}
119 'recombine5.def' => {
120 source => "recombine5",
122 expect => <<'#2...........',
123 # recombine uses reverse optimization
125 Math::MatrixReal->new_from_string( "[ "
127 . -sin($theta) . " ]\n" . "[ "
134 'recombine6.def' => {
135 source => "recombine6",
137 expect => <<'#3...........',
138 # recombine operation uses forward optimization
141 : (s/^\+//) ? $filecol + $_
142 : (s/^\-//) ? $filecol - $_
143 : (s/^>//) ? ( $filecol + $_ ) % $pages
144 : (s/^]//) ? ( ( $filecol + $_ >= $pages ) ? 0 : $filecol + $_ )
145 : (s/^<//) ? ( $filecol - $_ ) % $pages
147 ( $filecol == 0 ) ? $pages - ( $pages % $_ || $_ )
148 : ( $filecol - $_ < 0 ) ? 0
152 : (s/^\\?//) ? ( ( $col{$_}, $row{$_} ) = &pageto($_) )[0]
157 'recombine7.def' => {
158 source => "recombine7",
160 expect => <<'#4...........',
161 # recombine uses forward optimization, must recombine at =
162 my $J = int( 365.25 * ( $y + 4712 ) ) +
163 int( ( 30.6 * $m ) + 0.5 ) + 59 + $d - 0.5;
167 'recombine8.def' => {
168 source => "recombine8",
170 expect => <<'#5...........',
171 # recombine uses normal forward mode
172 $v_gb = -1 * ( eval($pmt_gb) ) * (
177 -1 + ( 1 / ( ( eval($i_gb) / 100 ) + 1 ) )
178 **( ( eval($n_gb) - 1 ) )
181 ) / ( eval($i_gb) / 100 )
188 my $ntests = 0 + keys %{$rtests};
189 plan tests => $ntests;
196 foreach my $key ( sort keys %{$rtests} ) {
198 my $sname = $rtests->{$key}->{source};
199 my $expect = $rtests->{$key}->{expect};
200 my $pname = $rtests->{$key}->{params};
201 my $source = $rsources->{$sname};
202 my $params = defined($pname) ? $rparams->{$pname} : "";
204 my $errorfile_string;
205 my $err = Perl::Tidy::perltidy(
207 destination => \$output,
208 perltidyrc => \$params,
209 argv => '', # for safety; hide any ARGV from perltidy
210 stderr => \$stderr_string,
211 errorfile => \$errorfile_string, # not used when -se flag is set
213 if ( $err || $stderr_string || $errorfile_string ) {
214 print STDERR "Error output received for test '$key'\n";
216 print STDERR "An error flag '$err' was returned\n";
219 if ($stderr_string) {
220 print STDERR "---------------------\n";
221 print STDERR "<<STDERR>>\n$stderr_string\n";
222 print STDERR "---------------------\n";
223 ok( !$stderr_string );
225 if ($errorfile_string) {
226 print STDERR "---------------------\n";
227 print STDERR "<<.ERR file>>\n$errorfile_string\n";
228 print STDERR "---------------------\n";
229 ok( !$errorfile_string );
233 if ( !is( $output, $expect, $key ) ) {
234 my $leno = length($output);
235 my $lene = length($expect);
236 if ( $leno == $lene ) {
238 "#> Test '$key' gave unexpected output. Strings differ but both have length $leno\n";
242 "#> Test '$key' gave unexpected output. String lengths differ: output=$leno, expected=$lene\n";