changeset 23167:a2d6b84ce5c5

scripts/general/inputParser.m: refactor two xtest cases to normal test cases. * inputParser.m: The idea of the test function foobar was to validate the parsing process for empty and non-default input. Some minor formatting improvements.
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Wed, 08 Feb 2017 12:24:03 +0100
parents ea4c27f49a62
children 6f2164303aac
files scripts/general/inputParser.m
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/inputParser.m	Wed Feb 08 12:06:01 2017 +0100
+++ b/scripts/general/inputParser.m	Wed Feb 08 12:24:03 2017 +0100
@@ -384,8 +384,8 @@
       endif
       pnargin = numel (varargin);
 
-      this.ParameterNames  = fieldnames (this.Parameter);
-      this.SwitchNames     = fieldnames (this.Switch);
+      this.ParameterNames = fieldnames (this.Parameter);
+      this.SwitchNames    = fieldnames (this.Switch);
 
       ## Evaluate the Required arguments first
       nReq = numel (this.Required);
@@ -462,7 +462,7 @@
             this.Unmatched.(name) = varargin{vidx};
           else
             this.error (sprintf ("argument '%s' is not a valid parameter",
-                                  toupper (name)));
+                                 toupper (name)));
           endif
         endif
       endwhile
@@ -719,15 +719,13 @@
 %! p.parse ("line", "circle");
 %! assert ({p.Results.line, p.Results.color}, {"circle", "red"})
 
-%!function r = foobar (varargin)
-%!  p = inputParser ();
-%!  p.addParameter ("foo", "bar", @ischar);
-%!  p.parse (varargin{2:end});
-%!  r = p.Results;
-%!endfunction
-
-%!xtest assert (foobar (), struct ("foo", "bar"))
-%!xtest assert (foobar ([], "foo", "qux"), struct ("foo", "qux"))
+%!test
+%! p = inputParser;
+%! p.addParameter ("foo", "bar", @ischar);
+%! p.parse ();
+%! assert (p.Results, struct ("foo", "bar"))
+%! p.parse ("foo", "qux");
+%! assert (p.Results, struct ("foo", "qux"))
 
 ## FIXME: This somehow works in Matlab
 %!xtest