From: Steve Hancock Date: Wed, 15 Feb 2023 15:49:12 +0000 (-0800) Subject: add some tests for recombine operations X-Git-Tag: 20230309~22 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=736573627e494a082955e085d646a4a53952cee2;p=perltidy.git add some tests for recombine operations --- diff --git a/t/snippets/expect/recombine5.def b/t/snippets/expect/recombine5.def new file mode 100644 index 00000000..a83d6468 --- /dev/null +++ b/t/snippets/expect/recombine5.def @@ -0,0 +1,8 @@ +# recombine uses reverse optimization +$rotate = + Math::MatrixReal->new_from_string( "[ " + . cos($theta) . " " + . -sin($theta) . " ]\n" . "[ " + . sin($theta) . " " + . cos($theta) + . " ]\n" ); diff --git a/t/snippets/expect/recombine6.def b/t/snippets/expect/recombine6.def new file mode 100644 index 00000000..2125c782 --- /dev/null +++ b/t/snippets/expect/recombine6.def @@ -0,0 +1,16 @@ + # recombine operation uses forward optimization + $filecol = + (/^$/) ? $filecol + : (s/^\+//) ? $filecol + $_ + : (s/^\-//) ? $filecol - $_ + : (s/^>//) ? ( $filecol + $_ ) % $pages + : (s/^]//) ? ( ( $filecol + $_ >= $pages ) ? 0 : $filecol + $_ ) + : (s/^new_from_string( "[ " . cos($theta) . " " . -sin($theta) . " ]\n" . "[ " . sin($theta) . " " . cos($theta) . " ]\n" ); diff --git a/t/snippets/recombine6.in b/t/snippets/recombine6.in new file mode 100644 index 00000000..2500aad6 --- /dev/null +++ b/t/snippets/recombine6.in @@ -0,0 +1,12 @@ +# recombine operation uses forward optimization + $filecol = + (/^$/) ? $filecol : + (s/^\+//) ? $filecol + $_ : + (s/^\-//) ? $filecol - $_ : + (s/^>//) ? ($filecol + $_) % $pages : + (s/^]//) ? (($filecol + $_ >= $pages) ? 0 : $filecol + $_) : + (s/^ "", 'olbxl2' => <<'----------', -olbxl='*' ---------- @@ -47,6 +52,37 @@ BEGIN { @sorted = sort { $SortDir * $PageTotal{$a} <=> $SortDir * $PageTotal{$b} }; +---------- + + 'recombine5' => <<'----------', +# recombine uses reverse optimization +$rotate = Math::MatrixReal->new_from_string( "[ " . cos($theta) . " " . -sin($theta) . " ]\n" . "[ " . sin($theta) . " " . cos($theta) . " ]\n" ); +---------- + + 'recombine6' => <<'----------', +# recombine operation uses forward optimization + $filecol = + (/^$/) ? $filecol : + (s/^\+//) ? $filecol + $_ : + (s/^\-//) ? $filecol - $_ : + (s/^>//) ? ($filecol + $_) % $pages : + (s/^]//) ? (($filecol + $_ >= $pages) ? 0 : $filecol + $_) : + (s/^ <<'----------', + # recombine uses forward optimization, must recombine at = + my $J = int( 365.25 * ( $y + 4712 ) ) + + int( ( 30.6 * $m ) + 0.5 ) + 59 + $d - 0.5; +---------- + + 'recombine8' => <<'----------', +# recombine uses normal forward mode +$v_gb = -1*(eval($pmt_gb))*(-1+((((-1+(1/((eval($i_gb)/100)+1))** ((eval($n_gb)-1)))))/(eval($i_gb)/100))); ---------- }; @@ -79,6 +115,74 @@ BEGIN { }; #1........... }, + + 'recombine5.def' => { + source => "recombine5", + params => "def", + expect => <<'#2...........', +# recombine uses reverse optimization +$rotate = + Math::MatrixReal->new_from_string( "[ " + . cos($theta) . " " + . -sin($theta) . " ]\n" . "[ " + . sin($theta) . " " + . cos($theta) + . " ]\n" ); +#2........... + }, + + 'recombine6.def' => { + source => "recombine6", + params => "def", + expect => <<'#3...........', + # recombine operation uses forward optimization + $filecol = + (/^$/) ? $filecol + : (s/^\+//) ? $filecol + $_ + : (s/^\-//) ? $filecol - $_ + : (s/^>//) ? ( $filecol + $_ ) % $pages + : (s/^]//) ? ( ( $filecol + $_ >= $pages ) ? 0 : $filecol + $_ ) + : (s/^ { + source => "recombine7", + params => "def", + expect => <<'#4...........', + # recombine uses forward optimization, must recombine at = + my $J = int( 365.25 * ( $y + 4712 ) ) + + int( ( 30.6 * $m ) + 0.5 ) + 59 + $d - 0.5; +#4........... + }, + + 'recombine8.def' => { + source => "recombine8", + params => "def", + expect => <<'#5...........', +# recombine uses normal forward mode +$v_gb = -1 * ( eval($pmt_gb) ) * ( + -1 + ( + ( + ( + ( + -1 + ( 1 / ( ( eval($i_gb) / 100 ) + 1 ) ) + **( ( eval($n_gb) - 1 ) ) + ) + ) + ) / ( eval($i_gb) / 100 ) + ) +); +#5........... + }, }; my $ntests = 0 + keys %{$rtests};