From octave-maintainers-request at bevo dot che dot wisc dot edu Sun Sep 3 23:32:51 2000 Subject: [PATCH] Add min/max tests. (4/4) From: Edward Jason Riedy To: octave-maintainers at bevo dot che dot wisc dot edu Date: Sun, 03 Sep 2000 21:32:50 -0700 This adds a bunch of regression test cases for the previous code. It also adds one more that checks that the same comparison is used throughout a complex matrix. Previously, Octave would magically revert back to the real comparison (directed rather than magnitude) if a column contained only real numbers. That's surprising. Jason test/ChangeLog * octave.test/arith/arith.exp: Add tests max-5.m through max-9.m, min-5.m through min-9.m. All tests succeed with "ans = 1" * octave.test/arith/max-5.m: Test (CMatrix, 'ignore-nan') parameters. * octave.test/arith/max-6.m: Test (dMatrix, 'prefer-nan') parameters. * octave.test/arith/max-7.m: Test (scalar, scalar, opt) parameters. * octave.test/arith/max-8.m: Test (CMatrix, CMatrix, opt) parameters. * octave.test/arith/max-9.m: Test that the same comparison criteria are used across an entire complex matrix. * octave.test/arith/min-5.m: Equivalent to max-5.m. * octave.test/arith/min-6.m: Equivalent to max-6.m. * octave.test/arith/min-7.m: Equivalent to max-7.m. * octave.test/arith/min-8.m: Equivalent to max-8.m. * octave.test/arith/min-9.m: Equivalent to max-9.m. --- octave.orig/test/octave.test/arith/arith.exp Fri Oct 23 19:56:25 1998 +++ octave.2/test/octave.test/arith/arith.exp Sat Sep 2 20:09:46 2000 at @ -172,6 +172,26 @@ set prog_output "\n... max:.*" do_test max-4.m +set test max-5 +set prog_output "ans = 1" +do_test max-5.m + +set test max-6 +set prog_output "ans = 1" +do_test max-6.m + +set test max-7 +set prog_output "ans = 1" +do_test max-7.m + +set test max-8 +set prog_output "ans = 1" +do_test max-8.m + +set test max-9 +set prog_output "ans = 1" +do_test max-9.m + set test min-1 set prog_output "ans = 1" do_test min-1.m at @ -187,6 +207,26 @@ set test min-4 set prog_output "\n... min:.*" do_test min-4.m + +set test min-5 +set prog_output "ans = 1" +do_test min-5.m + +set test min-6 +set prog_output "ans = 1" +do_test min-6.m + +set test min-7 +set prog_output "ans = 1" +do_test min-7.m + +set test min-8 +set prog_output "ans = 1" +do_test min-8.m + +set test min-9 +set prog_output "ans = 1" +do_test min-9.m set test pow2-1 set prog_output "ans = 1" diff --new-file -r -u octave.orig/test/octave.test/arith/max-5.m octave.2/test/octave.test/arith/max-5.m --- octave.orig/test/octave.test/arith/max-5.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/max-5.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,3 @@ +# test complex matrix max for ignore-nan +# see comments in min-5.m +all(max ([1, NaN; -2i, 3], 'ignore-nan') == [-2i, 3]) diff --new-file -r -u octave.orig/test/octave.test/arith/max-6.m octave.2/test/octave.test/arith/max-6.m --- octave.orig/test/octave.test/arith/max-6.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/max-6.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,3 @@ +# test double matrix max for prefer-nan +a = max ([1, NaN; 2, 3], 'prefer-nan'); +a(1) == 2 && isnan(a(2)) diff --new-file -r -u octave.orig/test/octave.test/arith/max-7.m octave.2/test/octave.test/arith/max-7.m --- octave.orig/test/octave.test/arith/max-7.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/max-7.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,2 @@ +# test double scalar max +isnan(max (1, NaN, 'prefer-nan')) && !isnan(max (1, NaN, 'ignore-nan')) diff --new-file -r -u octave.orig/test/octave.test/arith/max-8.m octave.2/test/octave.test/arith/max-8.m --- octave.orig/test/octave.test/arith/max-8.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/max-8.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,5 @@ +# test matrix-matrix max, complex +all(all(isnan(max([1, -1; 0, 3i], [NaN, NaN; NaN, NaN], \ + 'prefer-nan')))) && \ +all(all(!isnan(max([1, -1; 0, 3i], [NaN, NaN; NaN, NaN], \ + 'ignore-nan')))) diff --new-file -r -u octave.orig/test/octave.test/arith/max-9.m octave.2/test/octave.test/arith/max-9.m --- octave.orig/test/octave.test/arith/max-9.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/max-9.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,2 @@ +# check that the definition of max is consistent across a complex matrix +all(max([i, 1; 0, -5]) == [i, -5]) \ No newline at end of file diff --new-file -r -u octave.orig/test/octave.test/arith/min-5.m octave.2/test/octave.test/arith/min-5.m --- octave.orig/test/octave.test/arith/min-5.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/min-5.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,6 @@ +# test complex matrix min for ignore-nan +# (If this fails, check liboctave/mx-reductions.h::PredReducer. Ensure +# either tmp_val is initialized to an identity for the predicate in +# begin() or that apply() has appropriate isnan checks to catch the +# case where tmp_val is initialized to NaN.) +all(min ([1, NaN; 2i, 3], 'ignore-nan') == [1, 3]) diff --new-file -r -u octave.orig/test/octave.test/arith/min-6.m octave.2/test/octave.test/arith/min-6.m --- octave.orig/test/octave.test/arith/min-6.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/min-6.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,3 @@ +# test double matrix min for prefer-nan +a = min ([1, NaN; 2, 3], 'prefer-nan'); +a(1) == 1 && isnan(a(2)) diff --new-file -r -u octave.orig/test/octave.test/arith/min-7.m octave.2/test/octave.test/arith/min-7.m --- octave.orig/test/octave.test/arith/min-7.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/min-7.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,2 @@ +# test double scalar min +isnan(min (1, NaN, 'prefer-nan')) && !isnan(min (1, NaN, 'ignore-nan')) diff --new-file -r -u octave.orig/test/octave.test/arith/min-8.m octave.2/test/octave.test/arith/min-8.m --- octave.orig/test/octave.test/arith/min-8.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/min-8.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,5 @@ +# test matrix-matrix min, complex +all(all(isnan(min([1, -1; 0, 3i], [NaN, NaN; NaN, NaN], \ + 'prefer-nan')))) && \ +all(all(!isnan(min([1, -1; 0, 3i], [NaN, NaN; NaN, NaN], \ + 'ignore-nan')))) diff --new-file -r -u octave.orig/test/octave.test/arith/min-9.m octave.2/test/octave.test/arith/min-9.m --- octave.orig/test/octave.test/arith/min-9.m Wed Dec 31 16:00:00 1969 +++ octave.2/test/octave.test/arith/min-9.m Sat Sep 2 20:09:08 2000 at @ -0,0 +1,2 @@ +# check that the definition of min is consistent across a complex matrix +all(min([i, 1; 3, -5]) == [i, 1]) \ No newline at end of file