Mercurial > octave
changeset 31000:f69dbed63186 stable
Emit more informative error message on empty input (bug #62541)
* __axis_limits__.m: Fix input validation conditional test which used "&&" when
"||" was required.
* xlim.m: Add BIST tests for input validation in __axis_limit__.m.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 15 May 2022 12:35:59 -0700 |
parents | 63710f3bd981 |
children | d2c09591eb11 c05aa021e971 |
files | scripts/plot/appearance/private/__axis_limits__.m scripts/plot/appearance/xlim.m |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/appearance/private/__axis_limits__.m Wed May 11 09:44:55 2022 -0700 +++ b/scripts/plot/appearance/private/__axis_limits__.m Sun May 15 12:35:59 2022 -0700 @@ -49,7 +49,7 @@ set (hax, fcnmode, arg); endif else - if (! isnumeric (arg) && any (size (arg(:)) != [2, 1])) + if (! isnumeric (arg) || any (size (arg(:)) != [2, 1])) error ("%s: LIMITS must be a 2-element vector", fcn); elseif (arg(1) >= arg(2)) error ("%s: axis limits must be increasing", fcn);
--- a/scripts/plot/appearance/xlim.m Wed May 11 09:44:55 2022 -0700 +++ b/scripts/plot/appearance/xlim.m Sun May 15 12:35:59 2022 -0700 @@ -110,3 +110,17 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect + +%!test +%! ## Test input validation, done only in xlim since it is common to ylim,zlim. +%! hf = figure ("visible", "off"); +%! unwind_protect +%! h = plot3 ([0,1.1], [0,1], [0, 1]); +%! fail ("xlim ({1, 2})", "LIMITS must be a 2-element vector"); +%! fail ("xlim ([1, 2, 3])", "LIMITS must be a 2-element vector"); +%! fail ("xlim ([2, 1])", "axis limits must be increasing"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +