# HG changeset patch # User Mike Miller # Date 1423322005 18000 # Node ID 4b1a43786489f8c29dcaf7ab9535bd2cf91f350a # Parent e7df12f37f7166c827faa2d64f2b2373dc54774e 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. diff -r e7df12f37f71 -r 4b1a43786489 scripts/image/colormap.m --- 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)