Mercurial > octave
diff libinterp/corefcn/data.cc @ 32060:1203a2d81a42
Add BIST tests for Matlab compatibility for functions which accept negative dimensions.
* data.cc (Fones, Finf, Feps, Feye): Add BIST test for negative dimensions.
* rand.cc (Frand): Add BIST test for negative dimensions.
* ov-cell.cc (Fcell): Add BIST test for negative dimensions.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 26 Apr 2023 16:26:32 -0700 |
parents | 39700c1ea93e |
children | 1de97b475564 |
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc Wed Apr 26 14:40:37 2023 -0700 +++ b/libinterp/corefcn/data.cc Wed Apr 26 16:26:32 2023 -0700 @@ -4639,6 +4639,7 @@ %!assert (ones (2, "like", speye (2)), sparse ([1, 1; 1, 1])) %!assert (ones (2, "like", sparse (1i)), sparse (complex ([1, 1; 1, 1]))) +## Note: Matlab compatibility requires using 0 for negative dimensions. %!assert (size (ones (1, -2, 2)), [1, 0, 2]) ## Test input validation @@ -4794,6 +4795,9 @@ %!assert (Inf (3, 2, "single"), single ([Inf, Inf; Inf, Inf; Inf, Inf])) %!assert (size (inf (3, 4, 5, "single")), [3, 4, 5]) +## Note: Matlab compatibility requires using 0 for negative dimensions. +%!assert (size (Inf (2, -3, 2)), [2, 0, 2]) + %!assert (Inf (2, 2, "like", speye (2)), sparse ([Inf, Inf; Inf, Inf])) %!assert (Inf (2, 2, "like", complex (ones (2, 2))), [Inf, Inf; Inf, Inf]) %!assert (Inf (2, 2, "like", double (1)), double ([Inf, Inf; Inf, Inf])) @@ -5049,6 +5053,10 @@ %!assert (eps (single (NaN)), single (NaN)) %!assert (eps (single ([1/2 1 2 realmax("single") 0 realmin("single")/2 realmin("single")/16 Inf NaN])), %! single ([2^-24 2^-23 2^-22 2^104 2^-149 2^-149 2^-149 NaN NaN])) + +## Note: Matlab compatibility requires using 0 for negative dimensions. +%!assert (size (eps (2, -3, 2)), [2, 0, 2]) + %!error <X must be of a floating point type> eps (uint8 ([0 1 2])) %!error <must be scalar> eps (1:3, 1) %!error <must be scalar> eps (1, 1:3) @@ -5538,12 +5546,15 @@ %!assert (full (eye (3)), [1, 0, 0; 0, 1, 0; 0, 0, 1]) %!assert (full (eye (2, 3)), [1, 0, 0; 0, 1, 0]) -%!assert (full (eye (3,"single")), single ([1, 0, 0; 0, 1, 0; 0, 0, 1])) -%!assert (full (eye (2, 3,"single")), single ([1, 0, 0; 0, 1, 0])) +%!assert (full (eye (3, "single")), single ([1, 0, 0; 0, 1, 0; 0, 0, 1])) +%!assert (full (eye (2, 3, "single")), single ([1, 0, 0; 0, 1, 0])) %!assert (eye (3, "int8"), int8 ([1, 0, 0; 0, 1, 0; 0, 0, 1])) %!assert (eye (2, 3, "int8"), int8 ([1, 0, 0; 0, 1, 0])) +## Note: Matlab compatibility requires using 0 for negative dimensions. +%!assert (size (eye (2, -3)), [2, 0]) + ## Test input validation %!error eye (1, 2, 3) %!error <conversion of 1.1 .*failed> eye (1.1)