changeset 22016:d4ce10f57918

Clean up localfunctions BIST test * help.cc: Delete the right file when test is finished. Use unwind_protect block to delete temporary .m file after test completes.
author Mike Miller <mtmiller@octave.org>
date Thu, 30 Jun 2016 17:28:09 -0700
parents cb25e0da9541
children 4eafa2cc599f
files libinterp/corefcn/help.cc
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc	Thu Jun 30 17:11:38 2016 -0700
+++ b/libinterp/corefcn/help.cc	Thu Jun 30 17:28:09 2016 -0700
@@ -1254,16 +1254,20 @@
 %!test
 %! f = tempname (".", "oct_");
 %! fcn_name = f(3:end);
-%! fid = fopen ([f ".m"], "w+");
-%! fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name);
-%! fprintf (fid, "function z = b(x)\n z = x+1; end\n");
-%! fprintf (fid, "function z = c(x)\n z = 2*x; end\n");
-%! fclose (fid);
-%! d = eval (fcn_name);
-%! unlink (f);
-%! assert (size (d), [2, 1]);
-%! assert (d{1}(3), 4);
-%! assert (d{2}(3), 6);
+%! f = [f ".m"];
+%! unwind_protect
+%!   fid = fopen (f, "w+");
+%!   fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name);
+%!   fprintf (fid, "function z = b(x)\n z = x+1; end\n");
+%!   fprintf (fid, "function z = c(x)\n z = 2*x; end\n");
+%!   fclose (fid);
+%!   d = eval (fcn_name);
+%!   assert (size (d), [2, 1]);
+%!   assert (d{1}(3), 4);
+%!   assert (d{2}(3), 6);
+%! unwind_protect_cleanup
+%!   unlink (f);
+%! end_unwind_protect
 */
 
 static std::string