diff options
Diffstat (limited to 'tests/wordsplit.at')
-rw-r--r-- | tests/wordsplit.at | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/tests/wordsplit.at b/tests/wordsplit.at index 1f2e80d..ebd168b 100644 --- a/tests/wordsplit.at +++ b/tests/wordsplit.at @@ -107,9 +107,9 @@ WSPGROUP() dnl ------------------------------------------------------------ dnl Test worsplit-specific behavior dnl ------------------------------------------------------------ -TESTWSP([append],[wsp-append],[append], +TESTWSP([append],[wsp-append],[-append], [jeden dwa trzy cztery piec szesc], [NF: 3 @@ -132,9 +132,9 @@ NF: 6 5: szesc TOTAL: 2 ]) -TESTWSP([dooffs],[wsp-doofs ],[dooffs 3 jeden dwa trzy], +TESTWSP([dooffs],[wsp-doofs ],[-dooffs jeden dwa trzy], [cztery piec], [NF: 2 (3) (0): jeden (1): dwa @@ -213,9 +213,9 @@ TOTAL: 3 ], [], [unset FOO;]) -TESTWSP([undefined variables 2],[],[keepundef], +TESTWSP([undefined variables 2],[],[-keepundef], [a $FOO test a${FOO}b], [NF: 4 0: a 1: $FOO @@ -225,25 +225,25 @@ TOTAL: 4 ], [], [unset FOO;]) -TESTWSP([warn about undefined variables],[],[warnundef], +TESTWSP([warn about undefined variables],[],[-warnundef], [$FOO], [NF: 0 TOTAL: 0 ], [warning: undefined variable `FOO' ], [unset FOO;]) -TESTWSP([bail out on undefined variables],[],[undef], +TESTWSP([bail out on undefined variables],[],[-undef], [$FOO], [], [undefined variable ], [unset FOO;]) -TESTWSP([disable variable expansion],[],[novar], +TESTWSP([disable variable expansion],[],[-novar], [$FOO], [NF: 1 0: $FOO TOTAL: 1 @@ -251,9 +251,9 @@ TOTAL: 1 [], [FOO=bar]) TESTWSP([K/V environment],[wsp-env-kv wsp-env_kv], -[env_kv], +[-env_kv], [$FOO a$BAZ], [NF: 2 0: bar 1: aqux @@ -261,44 +261,35 @@ TOTAL: 2 ], [], [FOO=bar BAZ=qux]) -TESTWSP([nosplit with variable expansion],[wsp-var-nosplit],[nosplit], +TESTWSP([nosplit with variable expansion],[wsp-var-nosplit],[-nosplit], [a $FOO test], [NF: 1 0: "a variable expansion test\n" TOTAL: 1 ], [], [FOO="variable expansion"]) -TESTWSP([nosplit without variable expansion],[],[nosplit novar], +TESTWSP([nosplit without variable expansion],[],[-nosplit -novar], [a $FOO test], [NF: 1 0: "a $FOO test\n" TOTAL: 1 ], [], [FOO="variable expansion"]) -TESTWSP([nosplit: empty expansion],[],[nosplit trimnl], +TESTWSP([nosplit: empty expansion],[],[-nosplit -trimnl], [$FOO], [NF: 1 0: "" TOTAL: 1 ], [], [FOO=""]) -TESTWSP([default value (defined)],[],[], -[${FOO:-bar}], -[NF: 1 -0: qux -TOTAL: 1 -], -[], -[FOO=qux]) - TESTWSP([default value],[],[], [${FOO:-bar}], [NF: 1 0: bar @@ -450,9 +441,9 @@ TOTAL: 2 ]) WSPGROUP() -TESTWSP([ignore quotes],[wsp-ignore-quotes ],[-quote], +TESTWSP([ignore quotes],[wsp-ignore-quotes ],[-noquote], ["a text"], [NF: 2 0: "\"a" 1: "text\"" @@ -461,9 +452,9 @@ TOTAL: 2 WSPGROUP(wsp-delim) TESTWSP([custom delimiters (squeeze)],[], -[delim : -ws trimnl], +[-delim : -nows -trimnl], [semicolon: separated::list: of :words], [NF: 5 0: semicolon 1: " separated" @@ -473,9 +464,9 @@ TESTWSP([custom delimiters (squeeze)],[], TOTAL: 5 ]) TESTWSP([custom delimiters (no squeeze)],[], -[delim : -ws -squeeze_delims trimnl], +[-delim : -nows -nosqueeze_delims -trimnl], [semicolon: separated::list: of :words], [NF: 6 0: semicolon 1: " separated" @@ -486,9 +477,9 @@ TESTWSP([custom delimiters (no squeeze)],[], TOTAL: 6 ]) TESTWSP([custom, with returned delimiters],[], -[delim : -ws trimnl return_delims], +[-delim : -nows -trimnl -return_delims], [semicolon: separated::list: of :words], [NF: 9 0: semicolon 1: : @@ -502,9 +493,9 @@ TESTWSP([custom, with returned delimiters],[], TOTAL: 9 ]) TESTWSP([custom, with returned & squeezed delimiters],[], -[delim : -ws trimnl return_delims -squeeze_delims], +[-delim : -nows -trimnl -return_delims -nosqueeze_delims], [semicolon: separated::list: of :words], [NF: 10 0: semicolon 1: : @@ -520,9 +511,9 @@ TOTAL: 10 ]) WSPGROUP(wsp-sed) -TESTWSP([sed expressions],[],[sed], +TESTWSP([sed expressions],[],[-sed], [arg1 s/foo/bar/g;s/bar baz/quz quux/ arg2], [NF: 3 0: arg1 1: "s/foo/bar/g;s/bar baz/quz quux/" @@ -531,9 +522,9 @@ TOTAL: 3 ]) WSPGROUP() -TESTWSP([C escapes on],[wcp-c-escape],[cescapes], +TESTWSP([C escapes on],[wcp-c-escape],[-cescapes], [a\ttab form\ffeed and new\nline], [NF: 4 0: a\ttab 1: form\ffeed @@ -541,9 +532,9 @@ TESTWSP([C escapes on],[wcp-c-escape],[cescapes], 3: new\nline TOTAL: 4 ]) -TESTWSP([C escapes off],[wcp-c-escape-off],[-cescapes], +TESTWSP([C escapes off],[wcp-c-escape-off],[-nocescapes], [a\ttab form\ffeed and new\nline], [NF: 4 0: attab 1: formffeed @@ -551,9 +542,9 @@ TESTWSP([C escapes off],[wcp-c-escape-off],[-cescapes], 3: newnline TOTAL: 4 ]) -TESTWSP([ws elimination],[wsp-ws-elim],[delim ' ()' ws return_delims], +TESTWSP([ws elimination],[wsp-ws-elim],[-delim ' ()' -ws -return_delims], [( list items )], [NF: 4 0: ( 1: list @@ -562,9 +553,9 @@ TESTWSP([ws elimination],[wsp-ws-elim],[delim ' ()' ws return_delims], TOTAL: 4 ]) TESTWSP([ws elimination + return delim],[wsp-ws-elim-ret], -[-default novar nocmd delim ":," return_delims ws dquote], +[-nodefault -novar -nocmd -delim ":," -return_delims -ws -dquote], ["foo" : "bar", "quux" : "baaz" ], [NF: 7 0: foo 1: : @@ -575,17 +566,17 @@ TESTWSP([ws elimination + return delim],[wsp-ws-elim-ret], 6: baaz TOTAL: 7 ]) -TESTWSP([empty quotes],[wsp-empty-quotes],[delim : ws return_delims], +TESTWSP([empty quotes],[wsp-empty-quotes],[-delim : -ws -return_delims], [t=""], [NF: 1 0: t= TOTAL: 1 ]) TESTWSP([delimiter following empty quotes], -[],[delim : ws return_delims], +[],[-delim : -ws -return_delims], [t="":r], [NF: 3 0: t= 1: : @@ -594,9 +585,9 @@ TOTAL: 3 ]) TESTWSP([suppress ws trimming within quotes], [], -[default delim , ws return_delims], +[-default -delim , -ws -return_delims], [nocomponent,nonewline, formatfield="In message %{text}, "], [NF: 5 0: nocomponent 1: , @@ -607,9 +598,9 @@ TOTAL: 5 ]) TESTWSP([unescape], [wsp-unescape wsp-unescape-simple], -[-default novar nocmd quote escape ':+:\\""'], +[-nodefault -novar -nocmd -quote -escape ':+:\\""'], [\Seen "quote \"" "bs \\"], [NF: 3 0: \\Seen 1: "quote \"" @@ -618,9 +609,9 @@ TOTAL: 3 ]) TESTWSP([unescape: word/quote], [wsp-unescape wsp-unescape-word], -[-default novar nocmd quote escape-word '\\""' escape-quote ':+0x:\\""'], +[-nodefault -novar -nocmd -quote -escape-word '\\""' -escape-quote ':+0x:\\""'], [\Seen "quote \"" "bs \\" "3\x31 \101" 3\x31 \101], [NF: 6 0: Seen 1: "quote \"" @@ -630,9 +621,9 @@ TESTWSP([unescape: word/quote], 5: 101 TOTAL: 6 ]) -TESTWSP([dquote],[],[-default novar nocmd dquote], +TESTWSP([dquote],[],[-nodefault -novar -nocmd -dquote], [a "quoted example" isn't it], [NF: 4 0: a 1: "quoted example" @@ -640,9 +631,9 @@ TESTWSP([dquote],[],[-default novar nocmd dquote], 3: it TOTAL: 4 ]) -TESTWSP([squote],[],[-default novar nocmd squote], +TESTWSP([squote],[],[-nodefault -novar -nocmd -squote], [a 'quoted example' isn"t it], [NF: 4 0: a 1: "quoted example" @@ -652,9 +643,9 @@ TOTAL: 4 ]) WSPGROUP(wsp-incr) -TESTWSP([incremental],[],[incremental], +TESTWSP([incremental],[],[-incremental], [incremental "input test" line ], @@ -670,9 +661,9 @@ TOTAL: 3 ], [input exhausted ]) -TESTWSP([incremental append],[],[incremental append], +TESTWSP([incremental append],[],[-incremental -append], [incremental "input test" line ], @@ -692,9 +683,9 @@ TOTAL: 3 [input exhausted ]) TESTWSP([incremental ws], -[],[return_delims -squeeze_delims incremental ws], +[],[-return_delims -nosqueeze_delims -incremental -ws], [a list test ], @@ -710,9 +701,9 @@ TOTAL: 3 ], [input exhausted ]) -TESTWSP([incremental nosplit],[],[incremental nosplit], +TESTWSP([incremental nosplit],[],[-incremental -nosplit], [incremental "input test" line ], [NF: 1 0: "incremental input test line" @@ -720,9 +711,9 @@ TOTAL: 1 ], [input exhausted ]) -TESTWSP([simple command substitution],[],[-nocmd], +TESTWSP([simple command substitution],[],[-cmd], [begin $(words a b) end], [NF: 4 0: begin 1: a @@ -730,33 +721,33 @@ TESTWSP([simple command substitution],[],[-nocmd], 3: end TOTAL: 4 ]) -TESTWSP([quoted command substitution],[],[-nocmd], +TESTWSP([quoted command substitution],[],[-cmd], [begin "$(words a b)" end], [NF: 3 0: begin 1: "a b" 2: end TOTAL: 3 ]) -TESTWSP([coalesced command substitution],[],[-nocmd], +TESTWSP([coalesced command substitution],[],[-cmd], [begin($(words a b))end], [NF: 2 0: begin(a 1: b)end TOTAL: 2 ]) -TESTWSP([quoted coalesced command substitution],[],[-nocmd], +TESTWSP([quoted coalesced command substitution],[],[-cmd], ["begin($(words a b))end"], [NF: 1 0: "begin(a b)end" TOTAL: 1 ]) -TESTWSP([variable and command substitution],[],[-nocmd -novar], +TESTWSP([variable and command substitution],[],[-cmd -var], [begin $X $(words $X $Y) end], [NF: 5 0: begin 1: a @@ -765,16 +756,16 @@ TESTWSP([variable and command substitution],[],[-nocmd -novar], 4: end TOTAL: 5 ],[],[X=a Y=b]) -TESTWSP([variable expansion and command substitution in quotes],[],[-nocmd -novar], +TESTWSP([variable expansion and command substitution in quotes],[],[-cmd -var], ["${BEGIN}($(words $X $Y))end"], [NF: 1 0: "begin(a b)end" TOTAL: 1 ],[],[X=a Y=b BEGIN=begin]) -TESTWSP([nested commands],[],[-nocmd -novar], +TESTWSP([nested commands],[],[-cmd -var], [$(words output $(words in$SUFFIX text) end)], [NF: 4 0: output 1: input @@ -791,9 +782,9 @@ mkdir dir > dir/1.c > dir/2.c > dir/3.b -wsp pathexpand<<'EOT' +wsp -pathexpand<<'EOT' begin dir/*.c end EOT ], [0], @@ -812,9 +803,9 @@ AT_CHECK([ mkdir dir > dir/1.c > dir/2.b -wsp pathexpand<<'EOT' +wsp -pathexpand<<'EOT' begin dir/*.d end EOT ], [0], @@ -832,9 +823,9 @@ AT_CHECK([ mkdir dir > dir/1.c > dir/2.b -wsp pathexpand nullglob<<'EOT' +wsp -pathexpand -nullglob<<'EOT' begin dir/*.d end EOT ], [0], @@ -851,9 +842,9 @@ AT_CHECK([ mkdir dir > dir/1.c > dir/2.b -wsp pathexpand failglob<<'EOT' +wsp -pathexpand -failglob<<'EOT' begin dir/*.d end EOT ], [0], @@ -861,9 +852,9 @@ EOT [no files match pattern dir/*.d ]) AT_CLEANUP -TESTWSP([append],[],[-- extra arguments follow], +TESTWSP([append],[],[-append-args extra arguments follow], [some words and], [NF: 6 0: some 1: words @@ -874,9 +865,9 @@ TESTWSP([append],[],[-- extra arguments follow], TOTAL: 3 ]) TESTWSP([append + dooffs + env],[], -[-env dooffs 2 preface words V=2 -- extra arguments follow], +[-env none -dooffs preface words -- V=2 -append-args extra arguments follow], [some words and var=$V], [NF: 7 (2) (0): preface (1): words @@ -891,9 +882,9 @@ TOTAL: 4 ]) # Maxwords TESTWSP([maxwords],[], -[trimnl maxwords 3], +[-trimnl -maxwords 3], [ws_maxwords limits the number of returned words], [NF: 3 0: ws_maxwords 1: limits @@ -901,9 +892,9 @@ TESTWSP([maxwords],[], TOTAL: 3 ]) TESTWSP([maxwords return_delims],[], -[trimnl maxwords 8 return_delims delim :-], +[-trimnl -maxwords 8 -return_delims -delim :-], [foo:::bar-:baz-quux:ux:zu], [NF: 8 0: foo 1: : @@ -916,9 +907,9 @@ TESTWSP([maxwords return_delims],[], TOTAL: 8 ]) TESTWSP([maxwords return_delims -squeeze_delims],[], -[trimnl maxwords 8 return_delims -squeeze_delims delim :-], +[-trimnl -maxwords 8 -return_delims -nosqueeze_delims -delim :-], [foo:::bar-:baz:qux-], [NF: 8 0: foo 1: : @@ -931,9 +922,9 @@ TESTWSP([maxwords return_delims -squeeze_delims],[], TOTAL: 8 ]) TESTWSP([maxwords incremental],[], -[trimnl maxwords 3 incremental], +[-trimnl -maxwords 3 -incremental], [foo bar baz qux uz ], @@ -949,26 +940,39 @@ TOTAL: 3 ], [input exhausted ])) -TESTWSP([variable nosplit],[],[novar novarsplit], +TESTWSP([variable nosplit],[],[-novar -novarsplit], [begin ${VAR:- a b} end], [NF: 3 0: begin 1: "${VAR:- a b}" 2: end TOTAL: 3 ]) -TESTWSP([command nosplit],[],[nocmd nocmdsplit], +TESTWSP([command nosplit],[],[-nocmd -nocmdsplit], [begin $(words a b) end], [NF: 3 0: begin 1: "$(words a b)" 2: end TOTAL: 3 ]) +TESTWSP([positional parameters],[],[one two three four five six seven eight nine ten eleven twelve], +[$0 $5 ${10} +$#], +[NF: 3 +0: one +1: six +2: eleven +TOTAL: 3 +NF: 1 +0: 12 +TOTAL: 1 +]) + m4_popdef([TESTWSP]) m4_popdef([wspnum]) m4_popdef([wspid]) m4_popdef([genkw]) |