changeset 31001:d2c09591eb11

maint: merge stable to default
author Rik <rik@octave.org>
date Sun, 15 May 2022 12:36:35 -0700
parents fef2957c38ec (current diff) f69dbed63186 (diff)
children 01bdfc4bb12e
files 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	Sat May 14 19:06:56 2022 -0700
+++ b/scripts/plot/appearance/private/__axis_limits__.m	Sun May 15 12:36:35 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	Sat May 14 19:06:56 2022 -0700
+++ b/scripts/plot/appearance/xlim.m	Sun May 15 12:36:35 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
+
+