changeset 22877:3c0e70e2f51c

maint: Periodic merge of stable to default.
author John W. Eaton <jwe@octave.org>
date Fri, 09 Dec 2016 15:34:48 -0500
parents 763ec7cbee9e (current diff) 233fb529184b (diff)
children a13e9853b678
files libinterp/corefcn/interpreter.cc scripts/general/display.m test/publish/publish.tst
diffstat 3 files changed, 49 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Fri Dec 09 12:29:27 2016 -0800
+++ b/libinterp/corefcn/interpreter.cc	Fri Dec 09 15:34:48 2016 -0500
@@ -801,8 +801,7 @@
       {
         recover_from_exception ();
 
-        std::cerr << "error: unhandled execution exception -- eval failed"
-                  << std::endl;
+        parse_status = 1;
       }
 
     return parse_status;
--- a/scripts/general/display.m	Fri Dec 09 12:29:27 2016 -0800
+++ b/scripts/general/display.m	Fri Dec 09 15:34:48 2016 -0500
@@ -49,13 +49,30 @@
   endif
 
   ## Only reason we got here is that there was no overloaded display function.
-  ## This may mean it is a built-in class.
-  str = disp (obj);
-  if (isempty (strfind (str, "<class ")))
-    disp (str);
+  ## If obj is truly an instance of a class then there is nothing to be done.
+  ## However, if obj is really a built-in like 'double' then we can display it.
+  if (isobject (obj))
+    error ('display: not defined for class "%s"', class (obj));
+  endif
+
+  varname = inputname (1);
+  if (! isempty (varname))
+    evalin ("caller", varname);
   else
-    error ('display: not defined for class "%s"', class (obj));
+    disp (obj);
   endif
 
 endfunction
 
+
+%!test
+%! str = evalc ("x = 1.1; display (x)");
+%! assert (str, "x =  1.1000\n");
+
+%!test
+%! str = evalc ("display (1.1)");
+%! assert (str, " 1.1000\n"); 
+
+## Test input validation
+%!error display ()
+%!error display (1,2)
--- a/test/publish/publish.tst	Fri Dec 09 12:29:27 2016 -0800
+++ b/test/publish/publish.tst	Fri Dec 09 15:34:48 2016 -0500
@@ -16,20 +16,26 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-## publish
+## test for publish
 
 %!test
 %! visibility = get (0, "defaultfigurevisible");
 %! toolkit = graphics_toolkit ();
 %! unwind_protect
-%!   set (0, "defaultfigurevisible", "off");
-%!   if (ispc ())
-%!     graphics_toolkit ("gnuplot");
+%!   if (ispc () || ! __have_feature__ ("OSMESA"))
+%!     try
+%!       graphics_toolkit ("gnuplot");
+%!     catch
+%!       ## The system doesn't support OSMESA or gnuplot for drawing hidden
+%!       ## figures.  Just return and have test marked as passing.
+%!       return;
+%!     end_try_catch
 %!   endif
-%!   cases = dir ("test_script*.m");
-%!   cases = strsplit (strrep ([cases.name], ".m", ".m\n"));
-%!   for i = 1:length(cases)-1
-%!     publish (cases{i});
+%!   set (0, "defaultfigurevisible", "off");
+%!
+%!   scripts = dir ("test_script*.m");
+%!   for fname = {scripts.name}
+%!     publish (fname{1});
 %!   endfor
 %!   confirm_recursive_rmdir (false, "local");
 %!   rmdir ("html", "s");
@@ -38,22 +44,29 @@
 %!   graphics_toolkit (toolkit);
 %! end_unwind_protect
 
-## grabcode
+## test for grabcode
 
 %!test
 %! visibility = get (0, "defaultfigurevisible");
 %! toolkit = graphics_toolkit ();
 %! unwind_protect
+%!   if (ispc () || ! __have_feature__ ("OSMESA"))
+%!     try
+%!       graphics_toolkit ("gnuplot");
+%!     catch
+%!       ## The system doesn't support OSMESA or gnuplot for drawing hidden
+%!       ## figures.  Just return and have test marked as passing.
+%!       return;
+%!     end_try_catch
+%!   endif
 %!   set (0, "defaultfigurevisible", "off");
-%!   if (ispc ())
-%!     graphics_toolkit ("gnuplot");
-%!   endif
+%!
 %!   publish ("test_script.m");
 %!   str1 = fileread ("test_script.m");
 %!   str2 = grabcode ("html/test_script.html");
 %!   confirm_recursive_rmdir (false, "local");
 %!   rmdir ("html", "s");
-%!   # Canonicalize strings
+%!   ## Canonicalize strings
 %!   str1 = strjoin (deblank (strsplit (str1, "\n")), "\n");
 %!   str2 = strjoin (deblank (strsplit (str2, "\n")), "\n");
 %!   assert (hash ("md5", str1), hash ("md5", str2));