]> git.donarmstrong.com Git - perltidy.git/commitdiff
add some tests for recombine operations
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 15 Feb 2023 15:49:12 +0000 (07:49 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 15 Feb 2023 15:49:12 +0000 (07:49 -0800)
t/snippets/expect/recombine5.def [new file with mode: 0644]
t/snippets/expect/recombine6.def [new file with mode: 0644]
t/snippets/expect/recombine7.def [new file with mode: 0644]
t/snippets/expect/recombine8.def [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets/recombine5.in [new file with mode: 0644]
t/snippets/recombine6.in [new file with mode: 0644]
t/snippets/recombine7.in [new file with mode: 0644]
t/snippets/recombine8.in [new file with mode: 0644]
t/snippets28.t

diff --git a/t/snippets/expect/recombine5.def b/t/snippets/expect/recombine5.def
new file mode 100644 (file)
index 0000000..a83d646
--- /dev/null
@@ -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 (file)
index 0000000..2125c78
--- /dev/null
@@ -0,0 +1,16 @@
+        # recombine operation uses forward optimization
+        $filecol =
+            (/^$/)    ? $filecol
+          : (s/^\+//) ? $filecol + $_
+          : (s/^\-//) ? $filecol - $_
+          : (s/^>//)  ? ( $filecol + $_ ) % $pages
+          : (s/^]//)  ? ( ( $filecol + $_ >= $pages ) ? 0 : $filecol + $_ )
+          : (s/^<//)  ? ( $filecol - $_ ) % $pages
+          : (s/^\[//) ? (
+              ( $filecol == 0 )     ? $pages - ( $pages % $_ || $_ )
+            : ( $filecol - $_ < 0 ) ? 0
+            :                         $filecol - $_
+          )
+          : (/^\d/)    ? $_ - 1
+          : (s/^\\?//) ? ( ( $col{$_}, $row{$_} ) = &pageto($_) )[0]
+          :              0;
diff --git a/t/snippets/expect/recombine7.def b/t/snippets/expect/recombine7.def
new file mode 100644 (file)
index 0000000..057beb6
--- /dev/null
@@ -0,0 +1,3 @@
+    # recombine uses forward optimization, must recombine at =
+    my $J = int( 365.25 * ( $y + 4712 ) ) +
+      int( ( 30.6 * $m ) + 0.5 ) + 59 + $d - 0.5;
diff --git a/t/snippets/expect/recombine8.def b/t/snippets/expect/recombine8.def
new file mode 100644 (file)
index 0000000..091aa73
--- /dev/null
@@ -0,0 +1,13 @@
+# 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 )
+    )
+);
index a2203c37738ff826a1c3abeab71a869614116695..f53aef688a6640ee5675b30c4a24710f12d32359 100644 (file)
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
+../snippets28.t        recombine5.def
+../snippets28.t        recombine6.def
+../snippets28.t        recombine7.def
+../snippets28.t        recombine8.def
diff --git a/t/snippets/recombine5.in b/t/snippets/recombine5.in
new file mode 100644 (file)
index 0000000..0249520
--- /dev/null
@@ -0,0 +1,2 @@
+# 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/recombine6.in b/t/snippets/recombine6.in
new file mode 100644 (file)
index 0000000..2500aad
--- /dev/null
@@ -0,0 +1,12 @@
+# recombine operation uses forward optimization
+       $filecol =
+           (/^$/)     ? $filecol                                        :
+           (s/^\+//)  ? $filecol  + $_                                  :
+           (s/^\-//)  ? $filecol  - $_                                  :
+           (s/^>//)   ? ($filecol + $_) % $pages                        :
+           (s/^]//)   ? (($filecol + $_ >= $pages) ? 0 : $filecol + $_) :
+           (s/^<//)   ? ($filecol - $_) % $pages                        :
+           (s/^\[//)  ? (($filecol == 0) ? $pages - ($pages % $_ || $_) :
+                         ($filecol - $_ < 0) ? 0 : $filecol - $_)       :
+           (/^\d/)    ? $_ - 1                                          :
+           (s/^\\?//) ? (($col{$_}, $row{$_}) = &pageto($_))[0]         : 0;
diff --git a/t/snippets/recombine7.in b/t/snippets/recombine7.in
new file mode 100644 (file)
index 0000000..057beb6
--- /dev/null
@@ -0,0 +1,3 @@
+    # recombine uses forward optimization, must recombine at =
+    my $J = int( 365.25 * ( $y + 4712 ) ) +
+      int( ( 30.6 * $m ) + 0.5 ) + 59 + $d - 0.5;
diff --git a/t/snippets/recombine8.in b/t/snippets/recombine8.in
new file mode 100644 (file)
index 0000000..3f6a66b
--- /dev/null
@@ -0,0 +1,2 @@
+# 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)));
index 958a8b5387e618e0f42da8c5cfe6cacfe36e3ba6..ae680597b7055400a454bfce607b27ec82f20038 100644 (file)
@@ -2,6 +2,10 @@
 
 # Contents:
 #1 olbxl.olbxl2
+#2 recombine5.def
+#3 recombine6.def
+#4 recombine7.def
+#5 recombine8.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -19,6 +23,7 @@ BEGIN {
     # BEGIN SECTION 1: Parameter combinations #
     ###########################################
     $rparams = {
+        'def'    => "",
         '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/^<//)   ? ($filecol - $_) % $pages                        :
+           (s/^\[//)  ? (($filecol == 0) ? $pages - ($pages % $_ || $_) :
+                         ($filecol - $_ < 0) ? 0 : $filecol - $_)       :
+           (/^\d/)    ? $_ - 1                                          :
+           (s/^\\?//) ? (($col{$_}, $row{$_}) = &pageto($_))[0]         : 0;
+----------
+
+        'recombine7' => <<'----------',
+    # 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/^<//)  ? ( $filecol - $_ ) % $pages
+          : (s/^\[//) ? (
+              ( $filecol == 0 )     ? $pages - ( $pages % $_ || $_ )
+            : ( $filecol - $_ < 0 ) ? 0
+            :                         $filecol - $_
+          )
+          : (/^\d/)    ? $_ - 1
+          : (s/^\\?//) ? ( ( $col{$_}, $row{$_} ) = &pageto($_) )[0]
+          :              0;
+#3...........
+        },
+
+        'recombine7.def' => {
+            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};