diff options
Diffstat (limited to 'test/unit/_parse_help.exp')
-rw-r--r-- | test/unit/_parse_help.exp | 74 |
1 files changed, 67 insertions, 7 deletions
diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp index 4beb28d2..a6d58d5a 100644 --- a/test/unit/_parse_help.exp +++ b/test/unit/_parse_help.exp @@ -38,11 +38,11 @@ assert_bash_list "-space" $cmd "one dash after space" sync_after_int set cmd {fn() { printf '%s\n' "-one -two dashes"; }; _parse_help fn} -assert_bash_list "-one\n-two" $cmd "two dashes, space-separated" +assert_bash_list "-one" $cmd "two dashes, space-separated" sync_after_int set cmd {fn() { printf '%s\n' "-one,-t dashes"; }; _parse_help fn} -assert_bash_list "-one\n-t" $cmd "two dashes, comma-separated" +assert_bash_list "-one" $cmd "two dashes, comma-separated" sync_after_int set cmd {fn() { printf '%s\n' "-one dash-inside"; }; _parse_help fn} @@ -50,23 +50,83 @@ assert_bash_list "-one" $cmd "internal dash 2" sync_after_int set cmd {fn() { printf '%s\n' "--long-arg=value"; }; _parse_help fn} -assert_bash_list "--long-arg" $cmd "value stripped" +assert_bash_list "--long-arg=" $cmd "value stripped" sync_after_int set cmd {fn() { printf '%s\n' "--long-arg=-value"; }; _parse_help fn} -assert_bash_list "--long-arg" $cmd "value not seen as option" +assert_bash_list "--long-arg=" $cmd "value not seen as option" sync_after_int set cmd {fn() { printf '%s\n' "--long-arg=-value,--opt2=val"; }; _parse_help fn} -assert_bash_list "--long-arg\n--opt2" $cmd "two options with values" +assert_bash_list "--long-arg=" $cmd "two options with values" sync_after_int set cmd {fn() { printf '%s\n' "-m,--mirror"; }; _parse_help fn} -assert_bash_list "-m\n--mirror" $cmd "short + long" +assert_bash_list "--mirror" $cmd "short + long" sync_after_int set cmd {fn() { printf '%s\n' "-T/--upload-file"; }; _parse_help fn} -assert_bash_list "-T\n--upload-file" $cmd "short + long, slash separated" +assert_bash_list "--upload-file" $cmd "short + long, slash separated" +sync_after_int + +set cmd {fn() { printf '%s\n' "-T|--upload-file"; }; _parse_help fn} +assert_bash_list "--upload-file" $cmd "pipe separated" +sync_after_int + +set cmd {fn() { printf '%s\n' "-f, -F, --foo"; }; _parse_help fn} +assert_bash_list "--foo" $cmd "short + short + long" +sync_after_int + +set cmd {fn() { printf '%s\n' "--foo[=bar]"; }; _parse_help fn} +assert_bash_list "--foo" $cmd "long with value and eq sign in brackets" +sync_after_int + +set cmd {fn() { printf '%s\n' "--foo=<bar>"; }; _parse_help fn} +assert_bash_list "--foo=" $cmd "long with value in angle brackets" +sync_after_int + +set cmd {fn() { printf '%s\n' "--foo={bar,quux}"; }; _parse_help fn} +assert_bash_list "--foo=" $cmd "long with value in curly brackets" +sync_after_int + +set cmd {fn() { printf '%s\n' "--[no]foo"; }; _parse_help fn} +assert_bash_list "--foo\n--nofoo" $cmd "long with \[no\]" +sync_after_int + +set cmd {fn() { printf '%s\n' "--[no-]bar[=quux]"; }; _parse_help fn} +assert_bash_list "--bar\n--no-bar" $cmd "long with \[no-\] + optional arg" +sync_after_int + +set cmd {fn() { printf '%s\n' "--[no-]bar=quux"; }; _parse_help fn} +assert_bash_list "--bar=\n--no-bar=" $cmd "long with \[no-\] + required arg" +sync_after_int + +set cmd {fn() { printf '%s\n' "--[dont-]foo"; }; _parse_help fn} +assert_bash_list "--foo\n--dont-foo" $cmd "long with \[dont-\]" +sync_after_int + +set cmd {fn() { printf '%s\n' "-[dont]x, --[dont]yy"; }; _parse_help fn} +assert_bash_list "--yy\n--dontyy" $cmd "short and long with \[dont\]" +sync_after_int + +set cmd {fn() { printf '%s\n' "----\n---foo\n----- bar"; }; _parse_help fn} +assert_bash_list "" $cmd "more than two dashes" +sync_after_int + +set cmd {fn() { printf '%s\n' "-f FOO, --foo=FOO"; }; _parse_help fn} +assert_bash_list "--foo=" $cmd "-f FOO, --foo=FOO" +sync_after_int + +set cmd {fn() { printf '%s\n' "-f [FOO], --foo[=FOO]"; }; _parse_help fn} +assert_bash_list "--foo" $cmd "-f \[FOO\], --foo\[=FOO\]" +sync_after_int + +set cmd {fn() { printf '%s\n' "--foo."; }; _parse_help fn} +assert_bash_list "--foo" $cmd "--foo." +sync_after_int + +set cmd {fn() { printf '%s\n' "-f or --foo"; }; _parse_help fn} +assert_bash_list "--foo" $cmd "-f or --foo" sync_after_int |