Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
at-grandpa committed Dec 25, 2018
1 parent fcab3fd commit 56314ec
Show file tree
Hide file tree
Showing 14 changed files with 2,056 additions and 2,014 deletions.
171 changes: 171 additions & 0 deletions spec/clim/dsl_spec/string_1_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
require "../dsl_spec"

{% begin %}
{%
main_help_message = <<-HELP_MESSAGE
Command Line Interface Tool.
Usage:
main_command_of_clim_library [options] [arguments]
Options:
-s ARG, --string=ARG Option description. [type:String]
--help Show this help.
HELP_MESSAGE
%}

spec(
spec_class_name: MainCommandWithString,
spec_dsl_lines: [
"option \"-s ARG\", \"--string=ARG\", type: String",
],
spec_desc: "main command with String options,",
spec_cases: [
{
argv: [] of String,
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => nil,
},
expect_args: [] of String,
},
{
argv: ["arg1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => nil,
},
expect_args: ["arg1"],
},
{
argv: ["-s", "string1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "string1",
},
expect_args: [] of String,
},
{
argv: ["-sstring1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "string1",
},
expect_args: [] of String,
},
{
argv: ["--string", "string1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "string1",
},
expect_args: [] of String,
},
{
argv: ["--string=string1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "string1",
},
expect_args: [] of String,
},
{
argv: ["-s", "string1", "arg1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "string1",
},
expect_args: ["arg1"],
},
{
argv: ["arg1", "-s", "string1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "string1",
},
expect_args: ["arg1"],
},
{
argv: ["-string"], # Unintended case.
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "tring",
},
expect_args: [] of String,
},
{
argv: ["-s=string1"], # Unintended case.
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "string",
"expect_value" => "=string1",
},
expect_args: [] of String,
},
{
argv: ["-h"],
exception_message: "Undefined option. \"-h\"",
},
{
argv: ["--help", "-ignore-option"],
exception_message: "Undefined option. \"-ignore-option\"",
},
{
argv: ["-ignore-option", "--help"],
exception_message: "Undefined option. \"-ignore-option\"",
},
{
argv: ["-s"],
exception_message: "Option that requires an argument. \"-s\"",
},
{
argv: ["--string"],
exception_message: "Option that requires an argument. \"--string\"",
},
{
argv: ["arg1", "-s"],
exception_message: "Option that requires an argument. \"-s\"",
},
{
argv: ["arg1", "--string"],
exception_message: "Option that requires an argument. \"--string\"",
},
{
argv: ["--help"],
expect_help: {{main_help_message}},
},
{
argv: ["--help", "ignore-arg"],
expect_help: {{main_help_message}},
},
{
argv: ["ignore-arg", "--help"],
expect_help: {{main_help_message}},
},
]
)
{% end %}
159 changes: 159 additions & 0 deletions spec/clim/dsl_spec/string_2_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
require "../dsl_spec"

{% begin %}
{%
main_help_message = <<-HELP_MESSAGE
Command Line Interface Tool.
Usage:
main_command_of_clim_library [options] [arguments]
Options:
-s ARG Option description. [type:String]
--help Show this help.
HELP_MESSAGE
%}

spec(
spec_class_name: MainCommandWithStringOnlyShortOption,
spec_dsl_lines: [
"option \"-s ARG\", type: String",
],
spec_desc: "main command with String options,",
spec_cases: [
{
argv: [] of String,
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => nil,
},
expect_args: [] of String,
},
{
argv: ["arg1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => nil,
},
expect_args: ["arg1"],
},
{
argv: ["-s", "string1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => "string1",
},
expect_args: [] of String,
},
{
argv: ["-sstring1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => "string1",
},
expect_args: [] of String,
},
{
argv: ["-s", "string1", "arg1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => "string1",
},
expect_args: ["arg1"],
},
{
argv: ["arg1", "-s", "string1"],
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => "string1",
},
expect_args: ["arg1"],
},
{
argv: ["-string"], # Unintended case.
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => "tring",
},
expect_args: [] of String,
},
{
argv: ["-s=string1"], # Unintended case.
expect_help: {{main_help_message}},
expect_opts: {
"type" => String?,
"method" => "s",
"expect_value" => "=string1",
},
expect_args: [] of String,
},
{
argv: ["-h"],
exception_message: "Undefined option. \"-h\"",
},
{
argv: ["--help", "-ignore-option"],
exception_message: "Undefined option. \"-ignore-option\"",
},
{
argv: ["-ignore-option", "--help"],
exception_message: "Undefined option. \"-ignore-option\"",
},
{
argv: ["-s"],
exception_message: "Option that requires an argument. \"-s\"",
},
{
argv: ["--string"],
exception_message: "Undefined option. \"--string\"",
},
{
argv: ["--string", "string1"],
exception_message: "Undefined option. \"--string\"",
},
{
argv: ["--string=string1"],
exception_message: "Undefined option. \"--string=string1\"",
},
{
argv: ["arg1", "-s"],
exception_message: "Option that requires an argument. \"-s\"",
},
{
argv: ["arg1", "--string"],
exception_message: "Undefined option. \"--string\"",
},
{
argv: ["--help"],
expect_help: {{main_help_message}},
},
{
argv: ["--help", "ignore-arg"],
expect_help: {{main_help_message}},
},
{
argv: ["ignore-arg", "--help"],
expect_help: {{main_help_message}},
},
]
)
{% end %}
Loading

0 comments on commit 56314ec

Please sign in to comment.