# HG changeset patch # User Kai Habel # Date 1315489420 -7200 # Node ID cd808de114c18882ca26befbd4cb664db1b5168d # Parent 7600200a54c890d31c13255511c53aff41ea5a25 Allow surface and patch to be called w/o arguments. Adding and fixing tests. plot/line.m: Style fixes and test added. plot/patch.m: Tests added. plot/surface.m: Allow surface to be called w/o arguments. Tests added. plot/private/__patch__.m: Allow patch to be called w/o arguments. diff -r 7600200a54c8 -r cd808de114c1 scripts/plot/line.m --- a/scripts/plot/line.m Wed Sep 07 18:48:00 2011 -0500 +++ b/scripts/plot/line.m Thu Sep 08 15:43:40 2011 +0200 @@ -47,12 +47,13 @@ %! hf = figure (1232, "visible", "off"); %! unwind_protect %! h = line; +%! assert (findobj (hf, "type", "line"), h); %! assert (get (h, "xdata"), [0 1], eps); %! assert (get (h, "ydata"), [0 1], eps); %! assert (get (h, "type"), "line"); -%! assert (get (h, "color"), get(0,'defaultlinecolor')); -%! assert (get (h, "linestyle"), get(0,'defaultlinelinestyle')); -%! assert (get (h, "linewidth"), get(0,'defaultlinelinewidth'), eps); +%! assert (get (h, "color"), get (0, "defaultlinecolor")); +%! assert (get (h, "linestyle"), get (0, "defaultlinelinestyle")); +%! assert (get (h, "linewidth"), get (0, "defaultlinelinewidth"), eps); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect diff -r 7600200a54c8 -r cd808de114c1 scripts/plot/patch.m --- a/scripts/plot/patch.m Wed Sep 07 18:48:00 2011 -0500 +++ b/scripts/plot/patch.m Thu Sep 08 15:43:40 2011 +0200 @@ -152,3 +152,23 @@ %! 'FaceVertexCData', jet(5), 'FaceColor', 'interp') %! view (-37.5, 30) +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = patch; +%! assert (findobj (hf, "type", "patch"), h); +%! assert (get (h, "xdata"), [0; 1; 1], eps); +%! assert (get (h, "ydata"), [0; 0; 1], eps); +%! assert (isempty(get (h, "zdata"))); +%! assert (isempty(get (h, "cdata"))); +%! assert (get (h, "faces"), [1, 2, 3], eps); +%! assert (get (h, "vertices"), [0 0; 1 0; 1 1], eps); +%! assert (get (h, "type"), "patch"); +%! assert (get (h, "facecolor"), [0 0 1]); +%! assert (get (h, "linestyle"), get (0, "defaultpatchlinestyle")); +%! assert (get (h, "linewidth"), get (0, "defaultpatchlinewidth"), eps); +%! assert (get (h, "marker"), get (0, "defaultpatchmarker")); +%! assert (get (h, "markersize"), get (0, "defaultpatchmarkersize")); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect diff -r 7600200a54c8 -r cd808de114c1 scripts/plot/private/__patch__.m --- a/scripts/plot/private/__patch__.m Wed Sep 07 18:48:00 2011 -0500 +++ b/scripts/plot/private/__patch__.m Thu Sep 08 15:43:40 2011 +0200 @@ -31,7 +31,10 @@ failed = false; - if (isstruct (varargin{1})) + if (isempty (varargin)) + args = {"xdata", [0; 1; 1], "ydata", [0; 0; 1], "facecolor", "blue"}; + args = setvertexdata (args); + elseif (isstruct (varargin{1})) if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces")) args{1} = "faces"; args{2} = getfield(varargin{1}, "faces"); diff -r 7600200a54c8 -r cd808de114c1 scripts/plot/surface.m --- a/scripts/plot/surface.m Wed Sep 07 18:48:00 2011 -0500 +++ b/scripts/plot/surface.m Thu Sep 08 15:43:40 2011 +0200 @@ -136,6 +136,10 @@ else error ("surface: Z argument must be a matrix"); endif + elseif (firststring == 1) + x = 1:3; + y = (x).'; + c = z = eye(3); else bad_usage = true; endif @@ -158,4 +162,21 @@ ## Mark file as being tested. Tests for surface are in ## surf.m, surfc.m, surfl.m, and pcolor.m -%!assert(1) + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = surface; +%! assert (findobj (hf, "type", "surface"), h); +%! assert (get (h, "xdata"), 1:3, eps); +%! assert (get (h, "ydata"), (1:3)', eps); +%! assert (get (h, "zdata"), eye(3)); +%! assert (get (h, "cdata"), eye(3)); +%! assert (get (h, "type"), "surface"); +%! assert (get (h, "linestyle"), get (0, "defaultsurfacelinestyle")); +%! assert (get (h, "linewidth"), get (0, "defaultsurfacelinewidth"), eps); +%! assert (get (h, "marker"), get (0, "defaultsurfacemarker")); +%! assert (get (h, "markersize"), get (0, "defaultsurfacemarkersize")); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect