Mercurial > hg > octave-nkf
changeset 17587:a13ff4521538
skewness.m: Simplify %!test for division-by-zero.
* scripts/statistics/base/skewness.m: Use "local" option to warning()
rather than unwind_protect block to simplify code.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 07 Oct 2013 08:07:55 -0700 |
parents | 8334144458a4 |
children | 9ff04de067ce |
files | scripts/statistics/base/skewness.m |
diffstat | 1 files changed, 5 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/statistics/base/skewness.m +++ b/scripts/statistics/base/skewness.m @@ -148,16 +148,12 @@ %!assert (skewness (single ([1:5 10])), single (1.0513283), eps ("single")) %!assert (skewness (single ([1 2]), 0), single (NaN)) -## Verify no "division-by-zero" warnings %!test -%! wstate = warning ("query", "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 +%! ## Verify no "division-by-zero" warnings +%! warning ("on", "Octave:divide-by-zero", "local"); +%! lastwarn (""); # clear last warning +%! skewness (1); +%! assert (lastwarn (), ""); ## Test input validation %!error skewness ()