Permalink
Browse files

[CommandLine] Add tests to Argument.t for combination args and unknow…

…n args
1 parent 11eb38f commit f8a619f1247e79b95ea6175d4feb652945090612 @Whiteknight committed Aug 29, 2012
Showing with 53 additions and 16 deletions.
  1. +53 −16 t/commandline/Arguments.t
View
@@ -58,22 +58,6 @@ class Test_Rosella_CommandLine_Arguments
});
}
- function get_argument_definitions()
- {
- self.status.verify("Test Rosella.CommandLine.Arguments.get_argument_definitions()");
- var obj = create_new();
- var arg_defs = create_arg_defs();
-
- string raw_args[] = [
- "-A",
- "--",
- "Aye", "Bee", "Cee"
- ];
-
- obj.parse(raw_args, arg_defs);
- self.assert.same(arg_defs, obj.get_argument_definitions());
- }
-
function remainder()
{
self.status.verify("Test Rosella.CommandLine.Arguments.remainder()");
@@ -311,6 +295,59 @@ class Test_Rosella_CommandLine_Arguments
self.assert.equal(obj[0], "foo");
self.assert.equal(obj[1], "bar");
}
+
+ function combination_args()
+ {
+ var obj = create_new();
+ var arg_defs = new Rosella.CommandLine.ArgumentDef({
+ "A" : "A",
+ "B" : "B",
+ "C" : "C",
+ "D" : "D"
+ });
+
+ obj.parse(["-A", "-BC"], arg_defs);
+ self.assert.equal(int(obj["-A"]), true);
+ self.assert.equal(int(obj["-B"]), true);
+ self.assert.equal(int(obj["-C"]), true);
+ self.assert.equal(int(obj["-D"]), false);
+
+ obj = create_new();
+ obj.parse(["-ABCD"], arg_defs);
+ self.assert.equal(int(obj["-A"]), true);
+ self.assert.equal(int(obj["-B"]), true);
+ self.assert.equal(int(obj["-C"]), true);
+ self.assert.equal(int(obj["-D"]), true);
+
+ obj = create_new();
+ obj.parse(["-AD"], arg_defs);
+ self.assert.equal(int(obj["-A"]), true);
+ self.assert.equal(int(obj["-B"]), false);
+ self.assert.equal(int(obj["-C"]), false);
+ self.assert.equal(int(obj["-D"]), true);
+
+ obj = create_new();
+ obj.parse(["-BCD"], arg_defs);
+ self.assert.equal(int(obj["-A"]), false);
+ self.assert.equal(int(obj["-B"]), true);
+ self.assert.equal(int(obj["-C"]), true);
+ self.assert.equal(int(obj["-D"]), true);
+ }
+
+ function unknown_args()
+ {
+ var obj = create_new();
+ var arg_defs = new Rosella.CommandLine.ArgumentDef({
+ "A" : "A",
+ "B" : "B",
+ "C" : "C",
+ "D" : "D"
+ });
+
+ self.assert.throws(function() {
+ obj.parse(["-A", "-BC", "-X"], arg_defs);
+ });
+ }
}
function main[main]()

0 comments on commit f8a619f

Please sign in to comment.