Mercurial > octave-nkf
changeset 19701:4b1a43786489
colormap.m: Don't show a figure during 'make check'
* colormap.m: Create an invisible figure in second %!test block to prevent
empty figure from showing during tests. Add unwind_protect blocks to both
test blocks to close temporary figures.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Sat, 07 Feb 2015 10:13:25 -0500 |
parents | e7df12f37f71 |
children | b2fe4dbe5266 |
files | scripts/image/colormap.m |
diffstat | 1 files changed, 34 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/colormap.m Sat Feb 07 15:41:48 2015 +0100 +++ b/scripts/image/colormap.m Sat Feb 07 10:13:25 2015 -0500 @@ -143,34 +143,42 @@ %!test %! hf = figure ("visible", "off"); -%! cmaptst = [0 1 0; 1 0 1; 1 1 1]; -%! cmap = colormap (cmaptst); -%! assert (cmap, cmaptst); -%! cmap = colormap (); -%! assert (cmap, cmaptst); -%! cmap = (get (gcf, "colormap")); -%! assert (cmap, cmaptst); -%! colormap ("default"); -%! assert (colormap (), jet (64)); -%! colormap ("ocean"); -%! assert (colormap, ocean (64)); -%! close (hf); # done with temp. figure +%! unwind_protect +%! cmaptst = [0 1 0; 1 0 1; 1 1 1]; +%! cmap = colormap (cmaptst); +%! assert (cmap, cmaptst); +%! cmap = colormap (); +%! assert (cmap, cmaptst); +%! cmap = (get (gcf, "colormap")); +%! assert (cmap, cmaptst); +%! colormap ("default"); +%! assert (colormap (), jet (64)); +%! colormap ("ocean"); +%! assert (colormap, ocean (64)); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect %!test -%! cmaplst = colormap ("list"); -%! assert (iscell (cmaplst)); -%! colormap ("register", "__mycmap__"); -%! cmaplst2 = colormap ("list"); -%! assert (numel (cmaplst2), numel (cmaplst) + 1); -%! assert (any (strcmp (cmaplst2, "__mycmap__"))); -%! colormap ("unregister", "__mycmap__"); -%! cmaplst2 = colormap ("list"); -%! assert (numel (cmaplst2), numel (cmaplst)); -%! assert (! any (strcmp (cmaplst2, "__mycmap__"))); -%! ## Unregister again and verify that nothing has happened -%! colormap ("unregister", "__mycmap__"); -%! cmaplst3 = colormap ("list"); -%! assert (isequal (cmaplst2, cmaplst3)); +%! hf = figure ("visible", "off"); +%! unwind_protect +%! cmaplst = colormap ("list"); +%! assert (iscell (cmaplst)); +%! colormap ("register", "__mycmap__"); +%! cmaplst2 = colormap ("list"); +%! assert (numel (cmaplst2), numel (cmaplst) + 1); +%! assert (any (strcmp (cmaplst2, "__mycmap__"))); +%! colormap ("unregister", "__mycmap__"); +%! cmaplst2 = colormap ("list"); +%! assert (numel (cmaplst2), numel (cmaplst)); +%! assert (! any (strcmp (cmaplst2, "__mycmap__"))); +%! ## Unregister again and verify that nothing has happened +%! colormap ("unregister", "__mycmap__"); +%! cmaplst3 = colormap ("list"); +%! assert (isequal (cmaplst2, cmaplst3)); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect ## Test input validation %!error colormap (1,2,3)