Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[CommandLine] Delete old tests from ProgramMode.t and replace with a …

…few new tests (mostly stubs)
  • Loading branch information...
commit 982ce53517179f6d0c710eb328908f4ce7154d7b 1 parent 8665de0
awhitworth authored
Showing with 20 additions and 66 deletions.
  1. +2 −1  src/commandline/ProgramMode.winxed
  2. +18 −65 t/commandline/ProgramMode.t
View
3  src/commandline/ProgramMode.winxed
@@ -41,7 +41,7 @@ class Rosella.CommandLine.ProgramMode
// Get the complete usage message, as a combination of the Program usage
// message, usage messages for the different modes, and usage messages
// for all argument definitions.
- function get_usage(string program_name, var sb)
+ function get_usage(string program_name, var sb = new 'StringBuilder')
{
var usage = self.usage;
if (usage != null) {
@@ -58,6 +58,7 @@ class Rosella.CommandLine.ProgramMode
condition.get_description(sb);
push(sb, " <OPTIONS>\n");
}
+ return sb;
}
// Called by the Program class internally. This function determines if the
View
83 t/commandline/ProgramMode.t
@@ -17,51 +17,19 @@ class Test_Rosella_CommandLine_ProgramMode
var result = obj.set_function(arg_0);
}
- function set_flag_1()
+ function set_usage()
{
- self.status.verify("Test Rosella.CommandLine.ProgramMode.set_flag()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- string arg_0 = "";
- var result = obj.set_flag(arg_0);
- }
-
- function set_flag_2()
- {
- self.status.verify("Test Rosella.CommandLine.ProgramMode.set_flag()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- string arg_0 = "";
- string arg_1 = "";
- var result = obj.set_flag(arg_0, arg_1);
- }
-
- function require_positional()
- {
- self.status.verify("Test Rosella.CommandLine.ProgramMode.require_positional()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- string arg_0 = "";
- int arg_1 = 0;
- var result = obj.require_positional(arg_0, arg_1);
- }
-
- function require_args()
- {
- self.status.verify("Test Rosella.CommandLine.ProgramMode.require_args()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- var arg_0 = null;
- var result = obj.require_args(arg_0);
+ // TODO: This is very fragile, I don't like matching exact strings, especially
+ // when there's whitespace involved.
+ var obj = new Rosella.CommandLine.ProgramMode("foo");
+ obj.set_usage("This is a test");
+ string usage = obj.get_usage("foo");
+ self.assert.str_equal(usage, " foo This is a test\n");
}
- function optional_args()
+ function get_usage()
{
- self.status.verify("Test Rosella.CommandLine.ProgramMode.optional_args()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- var arg_0 = null;
- var result = obj.optional_args(arg_0);
+ self.status.unimplemented("Need to set up some conditions to test with");
}
function can_accept()
@@ -73,42 +41,27 @@ class Test_Rosella_CommandLine_ProgramMode
var result = obj.can_accept(arg_0);
}
- function match_positionals()
+ function main_function()
{
- self.status.verify("Test Rosella.CommandLine.ProgramMode.match_positionals()");
+ self.status.verify("Test Rosella.CommandLine.ProgramMode.main_function()");
var obj = new Rosella.CommandLine.ProgramMode("");
- var arg_0 = null;
- int arg_1 = 0;
- var result = obj.match_positionals(arg_0, arg_1);
+ var result = obj.main_function();
}
- function match_args()
+ function require_flag()
{
- self.status.verify("Test Rosella.CommandLine.ProgramMode.match_args()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- var arg_0 = null;
- var arg_1 = null;
- int arg_2 = 0;
- var result = obj.match_args(arg_0, arg_1, arg_2);
+ self.status.unimplemented("This");
}
- function fetch_all_args()
+ function require_value()
{
- self.status.verify("Test Rosella.CommandLine.ProgramMode.fetch_all_args()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- var arg_0 = null;
- var result = obj.fetch_all_args(arg_0);
+ self.status.unimplemented("This");
}
- function main_function()
+ function require_condition()
{
- self.status.verify("Test Rosella.CommandLine.ProgramMode.main_function()");
- var obj = new Rosella.CommandLine.ProgramMode("");
-
- var result = obj.main_function();
+ self.status.unimplemented("This");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.