changeset 22541:4b7ab10b5c38

inputParser clear previous results before new parse (bug #49198) * scripts/general/inputParser.m(parse) : reset Results before doing a new parse.
author Carlo de Falco <carlo.defalco@polimi.it>
date Tue, 27 Sep 2016 17:56:34 +0200
parents 6574e90e8e27
children e0a1e8803d8c
files scripts/general/inputParser.m
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/inputParser.m	Tue Sep 27 13:22:22 2016 +0200
+++ b/scripts/general/inputParser.m	Tue Sep 27 17:56:34 2016 +0200
@@ -372,6 +372,7 @@
     endfunction
 
     function parse (this, varargin)
+      this.Results = struct ();
       if (numel (varargin) < numel (this.Required))
         if (this.FunctionName)
           print_usage (this.FunctionName);
@@ -731,3 +732,12 @@
 %! p.addParameter ("line", "tree");
 %! p.parse ("line", "circle");
 %! assert (p.Results, struct ("op1", "val", "line", "circle"));
+
+%!test
+%! p = inputParser;
+%! p.addParameter ("a", []);
+%! p.addParameter ("b", []);
+%! p.parse ("a", 1);
+%! p.parse ("b", 1);
+%! assert (p.Results, struct ("a", [], "b", 1));
+