# HG changeset patch
# User Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
# Date 1638206369 18000
#      Mon Nov 29 12:19:29 2021 -0500
# Node ID a69a42fbdfcdc53eef32b39f85a9d49c3f41a224
# Parent  2f5dd6697ceae9f3370eb802ec6ed7e76047e0af
confusionchart.m: suppress figure windows during function test (patch #10060)

* /inst/confusionchart.m: modifies BISTs to reduce figure pop-ups by temporarily
disabling and re-enabling figure display around each test.

diff -r 2f5dd6697cea -r a69a42fbdfcd inst/confusionchart.m
--- a/inst/confusionchart.m	Wed Nov 24 20:28:20 2021 -0500
+++ b/inst/confusionchart.m	Mon Nov 29 12:19:29 2021 -0500
@@ -157,24 +157,100 @@
 
 
 ## Test input validation
-%!error confusionchart ()
-%!error <.* invalid argument> confusionchart ([1 1; 2 2; 3 3])
-%!error <.* invalid property> confusionchart ([1 2], [0 1], "xxx", 1)
-%!error <.* XLabel .* string> confusionchart ([1 2], [0 1], "XLabel", 1)
-%!error <.* YLabel .* string> confusionchart ([1 2], [0 1], "YLabel", [1 0])
-%!error <.* Title .* string> confusionchart ([1 2], [0 1], "Title", .5)
-%!error <.* FontName .* string> confusionchart ([1 2], [0 1], "FontName", [])
-%!error <.* FontSize .* numeric> confusionchart ([1 2], [0 1], "FontSize", "b")
-%!error <.* DiagonalColor .* color> confusionchart ([1 2], [0 1], "DiagonalColor", "h")
-%!error <.* OffDiagonalColor .* color> confusionchart ([1 2], [0 1], "OffDiagonalColor", [])
-%!error <.* invalid .* Normalization> confusionchart ([1 2], [0 1], "Normalization", "")
-%!error <.* invalid .* ColumnSummary> confusionchart ([1 2], [0 1], "ColumnSummary", [])
-%!error <.* invalid .* RowSummary> confusionchart ([1 2], [0 1], "RowSummary", 1)
-%!error <.* invalid .* GridVisible> confusionchart ([1 2], [0 1], "GridVisible", .1)
-%!error <.* invalid .* HandleVisibility> confusionchart ([1 2], [0 1], "HandleVisibility", .1)
-%!error <.* invalid .* OuterPosition> confusionchart ([1 2], [0 1], "OuterPosition", .1)
-%!error <.* invalid .* Position> confusionchart ([1 2], [0 1], "Position", .1)
-%!error <.* invalid .* Units> confusionchart ([1 2], [0 1], "Units", .1)
+
+## Get current figure visibility so it can be restored after tests
+%!shared visibility_setting
+%! visibility_setting = get (0, "DefaultFigureVisible");
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ()", "Invalid call");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 1; 2 2; 3 3])", "invalid argument");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'xxx', 1)", "invalid property");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'XLabel', 1)", "XLabel .* string");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'YLabel', [1 0])", ".* YLabel .* string");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'Title', .5)", ".* Title .* string");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'FontName', [])", ".* FontName .* string");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'FontSize', 'b')", ".* FontSize .* numeric");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'DiagonalColor', 'h')", ".* DiagonalColor .* color");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'OffDiagonalColor', [])", ".* OffDiagonalColor .* color");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'Normalization', '')", ".* invalid .* Normalization");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'ColumnSummary', [])", ".* invalid .* ColumnSummary");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'RowSummary', 1)", ".* invalid .* RowSummary");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'GridVisible', .1)", ".* invalid .* GridVisible");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'HandleVisibility', .1)", ".* invalid .* HandleVisibility");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'OuterPosition', .1)", ".* invalid .* OuterPosition");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'Position', .1)", ".* invalid .* Position");
+%! set (0, "DefaultFigureVisible", visibility_setting);
+
+%!test
+%! set (0, "DefaultFigureVisible", "off");
+%! fail ("confusionchart ([1 2], [0 1], 'Units', .1)", ".* invalid .* Units");
+%! set (0, "DefaultFigureVisible", visibility_setting);
 
 ## Demonstration using the confusion matrix example from
 ## R.Bonnin, "Machine Learning for Developers", pp. 55-56
