diff libinterp/corefcn/pr-output.cc @ 27477:b470734a025e

Return an empty string from rats when input is empty (bug #57004). * pr-output.cc (Frats): Use isempty() to detect special case of input early and immediately return an empty string. Add BIST test for bug #57004.
author Rik <rik@octave.org>
date Sat, 05 Oct 2019 14:04:36 -0700
parents b8b1bf5b2bbf
children 94d278b130d1
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc	Sat Oct 05 13:52:40 2019 -0700
+++ b/libinterp/corefcn/pr-output.cc	Sat Oct 05 14:04:36 2019 -0700
@@ -3219,6 +3219,9 @@
   if (! arg.isnumeric ())
     error ("rats: X must be numeric");
 
+  if (arg.isempty ())
+    return ovl (octave_value (""));
+
   // Convert to N-D arrays to 2-D arrays for Matlab compatibility
   if (arg.ndims () > 2)
     {
@@ -3290,7 +3293,9 @@
 %! s = rats (x,4);
 %! assert (ndims (s) == 2);
 %! assert (rows (s) == 2);
-%! assert (columns (s) == 3);
+%! assert (columns (s) == 3 * 6);
+
+%!assert <57004> (rats ([]), '')
 
 */