diff src/symtab.cc @ 15003:1f5dbfc23fc2

'clear -f' does not work for command line functions (bug #34497) * src/symtab.cc: Added a test case for bug 34497. * src/symtab.h (fcn_info::fcn_info_rep::clear_cmdline_function): Removed method. (fcn_info::fcn_info_rep::clear_user_function): Also clear cmdline function. (fcn_info::fcn_info_rep::clear): Do not call clear_cmdline_function.
author Max Brister <max@2bass.com>
date Mon, 23 Jul 2012 06:53:09 -0500
parents f7afecdd87ef
children
line wrap: on
line diff
--- a/src/symtab.cc	Sun Jul 22 04:16:02 2012 +0200
+++ b/src/symtab.cc	Mon Jul 23 06:53:09 2012 -0500
@@ -1713,3 +1713,32 @@
   return retval;
 }
 #endif
+
+
+/*
+bug #34497: 'clear -f' does not work for command line functions
+
+This test relies on bar being a core function that is implemented in an m-file.
+If the first assert fails, this is no longer the case and the tests need to be
+updated to use some other function.
+
+%!assert (! strcmp (which ("bar"), ""));
+
+%!function x = bar ()
+%!  x = 5;
+%!endfunction
+%!test
+%! assert (bar == 5);
+%! assert (strcmp (which ("bar"), ""));
+%! clear -f bar;
+%! assert (! strcmp (which ("bar"), ""));
+
+%!function x = bar ()
+%!  x = 5;
+%!endfunction
+%!test
+%! assert (bar == 5);
+%! assert (strcmp (which ("bar"), ""));
+%! clear bar;
+%! assert (! strcmp (which ("bar"), ""));
+ */