changeset 20725:76f67400649e

Use '-local' option to warning to simplify BIST tests. * dos.m, unix.m, savepath.m, kurtosis.m, skewness.m: Use '-local' option to warning instead of unwind/protect block.
author Rik <rik@octave.org>
date Fri, 25 Sep 2015 21:00:29 -0700
parents 71e60880105a
children 79eb0746b21f
files scripts/miscellaneous/dos.m scripts/miscellaneous/unix.m scripts/path/savepath.m scripts/statistics/base/kurtosis.m scripts/statistics/base/skewness.m
diffstat 5 files changed, 15 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/dos.m
+++ b/scripts/miscellaneous/dos.m
@@ -51,13 +51,8 @@
 
 %!test
 %! cmd = ls_command ();
-%! old_wstate = warning ("query");
-%! warning ("off", "Octave:undefined-return-values");
-%! unwind_protect
-%!   [status, output] = dos (cmd);
-%! unwind_protect_cleanup
-%!   warning (old_wstate);
-%! end_unwind_protect
+%! warning ("off", "Octave:undefined-return-values", "local");
+%! [status, output] = dos (cmd);
 %!
 %! if (ispc () && ! isunix ())
 %!   [status, output] = dos (cmd);
--- a/scripts/miscellaneous/unix.m
+++ b/scripts/miscellaneous/unix.m
@@ -51,13 +51,8 @@
 
 %!test
 %! cmd = ls_command ();
-%! old_wstate = warning ("query");
-%! warning ("off", "Octave:undefined-return-values");
-%! unwind_protect
-%!   [status, output] = unix (cmd);
-%! unwind_protect_cleanup
-%!   warning (old_wstate);
-%! end_unwind_protect
+%! warning ("off", "Octave:undefined-return-values", "local");
+%! [status, output] = unix (cmd);
 %!
 %! if (isunix ())
 %!   assert (status, 0);
--- a/scripts/path/savepath.m
+++ b/scripts/path/savepath.m
@@ -202,7 +202,7 @@
 %!   assert (fid >= 0);
 %!   fclose (fid);
 %!   ## Save path into local .octaverc file
-%!   warning ("off", "Octave:savepath-local");
+%!   warning ("off", "Octave:savepath-local", "local");
 %!   status = savepath ();
 %!   assert (status == 0);
 %!   ## Compare old and new versions
--- a/scripts/statistics/base/kurtosis.m
+++ b/scripts/statistics/base/kurtosis.m
@@ -151,15 +151,10 @@
 
 ## Verify no "divide-by-zero" warnings
 %!test
-%! wstate = warning ("query", "Octave:divide-by-zero");
-%! warning ("on", "Octave:divide-by-zero");
-%! unwind_protect
-%!   lastwarn ("");  # clear last warning
-%!   kurtosis (1);
-%!   assert (lastwarn (), "");
-%! unwind_protect_cleanup
-%!   warning (wstate, "Octave:divide-by-zero");
-%! end_unwind_protect
+%! warning ("on", "Octave:divide-by-zero", "local");
+%! lastwarn ("");  # clear last warning
+%! kurtosis (1);
+%! assert (lastwarn (), "");
 
 ## Test input validation
 %!error kurtosis ()
@@ -171,3 +166,4 @@
 %!error <DIM must be an integer> kurtosis (1, [], 1.5)
 %!error <DIM must be .* a valid dimension> kurtosis (1, [], 0)
 %!error <DIM must be .* a valid dimension> kurtosis (1, [], 3)
+
--- a/scripts/statistics/base/skewness.m
+++ b/scripts/statistics/base/skewness.m
@@ -152,15 +152,10 @@
 
 ## Verify no "divide-by-zero" warnings
 %!test
-%! wstate = warning ("query", "Octave:divide-by-zero");
-%! warning ("on", "Octave:divide-by-zero");
-%! unwind_protect
-%!   lastwarn ("");  # clear last warning
-%!   skewness (1);
-%!   assert (lastwarn (), "");
-%! unwind_protect_cleanup
-%!   warning (wstate, "Octave:divide-by-zero");
-%! end_unwind_protect
+%! warning ("on", "Octave:divide-by-zero", "local");
+%! lastwarn ("");  # clear last warning
+%! skewness (1);
+%! assert (lastwarn (), "");
 
 ## Test input validation
 %!error skewness ()
@@ -172,3 +167,4 @@
 %!error <DIM must be an integer> skewness (1, [], 1.5)
 %!error <DIM must be .* a valid dimension> skewness (1, [], 0)
 %!error <DIM must be .* a valid dimension> skewness (1, [], 3)
+