aboutsummaryrefslogtreecommitdiff
path: root/tests/wordsplit.at
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wordsplit.at')
-rw-r--r--tests/wordsplit.at142
1 files changed, 140 insertions, 2 deletions
diff --git a/tests/wordsplit.at b/tests/wordsplit.at
index 49d47e9..d4328e3 100644
--- a/tests/wordsplit.at
+++ b/tests/wordsplit.at
@@ -1,5 +1,5 @@
# This file is part of grecs -*- Autotest -*-
-# Copyright (C) 2014-2016 Sergey Poznyakoff
+# Copyright (C) 2014-2018 Sergey Poznyakoff
#
# Grecs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -61,12 +61,14 @@ TESTWSP([simple input],[wsp-simple],[],
0: 1
1: 2
2: 3
+TOTAL: 3
])
TESTWSP([quoted space],[wsp-quoted],[],
[quoted\ space],
[NF: 1
0: "quoted space"
+TOTAL: 1
])
TESTWSP([tab character],[wsp-tab],[],
@@ -74,6 +76,7 @@ TESTWSP([tab character],[wsp-tab],[],
[NF: 2
0: a
1: tab\tcharacter
+TOTAL: 2
])
WSPGROUP(wsp-escape)
@@ -81,6 +84,7 @@ TESTWSP([octal and hex escapes],[],[],
[\157\143\164\141\154\40and\x20\x68\x65\x78],
[NF: 1
0: "octal and hex"
+TOTAL: 1
])
TESTWSP([octal and hex escapes 2],[],[],
@@ -89,12 +93,14 @@ TESTWSP([octal and hex escapes 2],[],[],
0: "octal "
1: and
2: " hex"
+TOTAL: 3
])
TESTWSP([escape representation],[],[],
[A\x3-\48\39],
[NF: 1
0: A\003-\0048\0039
+TOTAL: 1
])
WSPGROUP()
@@ -110,11 +116,13 @@ piec szesc],
0: jeden
1: dwa
2: trzy
+TOTAL: 3
NF: 4
0: jeden
1: dwa
2: trzy
3: cztery
+TOTAL: 1
NF: 6
0: jeden
1: dwa
@@ -122,6 +130,7 @@ NF: 6
3: cztery
4: piec
5: szesc
+TOTAL: 2
])
TESTWSP([dooffs],[wsp-doofs ],[dooffs 3 jeden dwa trzy],
@@ -132,6 +141,7 @@ TESTWSP([dooffs],[wsp-doofs ],[dooffs 3 jeden dwa trzy],
(2): trzy
3: cztery
4: piec
+TOTAL: 2
])
WSPGROUP(wsp-var)
@@ -142,6 +152,7 @@ TESTWSP([variable substitutions: single var],[],[],
0: a
1: bar
2: test
+TOTAL: 3
],
[],
[FOO=bar])
@@ -153,6 +164,7 @@ TESTWSP([variable substitutions: concatenated vars],[],
0: a
1: stringent
2: test
+TOTAL: 3
],
[],
[FOO=str BAR=ing])
@@ -164,6 +176,7 @@ TESTWSP([variable substitutions: field splitting],[],[],
1: variable
2: substitution
3: test
+TOTAL: 4
],
[],
[FOO="variable substitution"])
@@ -174,6 +187,7 @@ TESTWSP([variable substitutions: double-quoted variable],[],[],
0: a
1: "variable substitution"
2: test
+TOTAL: 3
],
[],
[FOO="variable substitution"])
@@ -184,6 +198,7 @@ TESTWSP([variable substitutions: single-quoted variable],[],[],
0: a
1: $FOO
2: test
+TOTAL: 3
],
[],
[FOO="variable substitution"])
@@ -194,6 +209,7 @@ TESTWSP([undefined variables 1],[],[],
0: a
1: test
2: ab
+TOTAL: 3
],
[],
[unset FOO;])
@@ -205,6 +221,7 @@ TESTWSP([undefined variables 2],[],[keepundef],
1: $FOO
2: test
3: a${FOO}b
+TOTAL: 4
],
[],
[unset FOO;])
@@ -212,6 +229,7 @@ TESTWSP([undefined variables 2],[],[keepundef],
TESTWSP([warn about undefined variables],[],[warnundef],
[$FOO],
[NF: 0
+TOTAL: 0
],
[warning: undefined variable `FOO'
],
@@ -228,6 +246,7 @@ TESTWSP([disable variable expansion],[],[novar],
[$FOO],
[NF: 1
0: $FOO
+TOTAL: 1
],
[],
[FOO=bar])
@@ -238,6 +257,7 @@ TESTWSP([K/V environment],[wsp-env-kv wsp-env_kv],
[NF: 2
0: bar
1: aqux
+TOTAL: 2
],
[],
[FOO=bar BAZ=qux])
@@ -246,6 +266,7 @@ TESTWSP([nosplit with expansion],[wsp-var-nosplit],[nosplit],
[a $FOO test],
[NF: 1
0: "a variable expansion test\n"
+TOTAL: 1
],
[],
[FOO="variable expansion"])
@@ -254,6 +275,7 @@ TESTWSP([nosplit without expansion],[],[nosplit novar],
[a $FOO test],
[NF: 1
0: "a $FOO test\n"
+TOTAL: 1
],
[],
[FOO="variable expansion"])
@@ -262,6 +284,7 @@ TESTWSP([default value (defined)],[],[],
[${FOO:-bar}],
[NF: 1
0: qux
+TOTAL: 1
],
[],
[FOO=qux])
@@ -270,12 +293,14 @@ TESTWSP([default value],[],[],
[${FOO:-bar}],
[NF: 1
0: bar
+TOTAL: 1
])
TESTWSP([default value (defined)],[],[],
[${FOO:-bar}],
[NF: 1
0: qux
+TOTAL: 1
],
[],
[FOO=qux])
@@ -284,6 +309,7 @@ TESTWSP([default value (:- null)],[],[],
[${FOO:-bar}],
[NF: 1
0: bar
+TOTAL: 1
],
[],
[FOO=])
@@ -291,6 +317,7 @@ TESTWSP([default value (:- null)],[],[],
TESTWSP([default value (- null)],[],[],
[${FOO-bar}],
[NF: 0
+TOTAL: 0
],
[],
[FOO=])
@@ -299,6 +326,7 @@ TESTWSP([default value (- null, unset)],[],[],
[${FOO-bar}],
[NF: 1
0: bar
+TOTAL: 1
])
TESTWSP([assign default values],[],[],
@@ -306,8 +334,10 @@ TESTWSP([assign default values],[],[],
$FOO],
[NF: 1
0: bar
+TOTAL: 1
NF: 1
0: bar
+TOTAL: 1
])
TESTWSP([default error message (var defined)],[],[],
@@ -316,6 +346,7 @@ TESTWSP([default error message (var defined)],[],[],
0: a
1: bar
2: test
+TOTAL: 3
],
[],
[FOO=bar])
@@ -323,6 +354,7 @@ TESTWSP([default error message (var defined)],[],[],
TESTWSP([default error message],[],[],
[${FOO:?}],
[NF: 0
+TOTAL: 0
],
[FOO: variable null or not set
])
@@ -333,6 +365,7 @@ TESTWSP([custom error message (defined)],[wsp-custom-err wsp-custom-err00],[],
0: a
1: bar
2: test
+TOTAL: 3
],
[],
[FOO=bar])
@@ -342,6 +375,7 @@ TESTWSP([custom error message],[wsp-custom-err wsp-custom-err01],[],
[NF: 2
0: a
1: test
+TOTAL: 2
],
[FOO: please define it
])
@@ -352,6 +386,7 @@ TESTWSP([alternate value (defined)],[wsp-alt wsp-alt00],[],
0: a
1: isset
2: test
+TOTAL: 3
],
[],
[FOO=bar])
@@ -361,6 +396,7 @@ TESTWSP([alternate value],[wsp-alt wsp-alt01],[],
[NF: 2
0: a
1: test
+TOTAL: 2
],
[],
[unset FOO;])
@@ -373,6 +409,7 @@ TESTWSP([getvar],[wsp-getvar],
1: bar
2: quux
3: end
+TOTAL: 4
],
[],
[],
@@ -388,6 +425,7 @@ TESTWSP([getvar and env],[wsp-getvar],
3: quux
4: zwar
5: end
+TOTAL: 6
],
[],
[TVAR=12 y=zwar],
@@ -399,6 +437,7 @@ TESTWSP([getvar, alternate value],[wsp-getvar],
[NF: 2
0: a
1: isset
+TOTAL: 2
])
WSPGROUP()
@@ -408,6 +447,7 @@ TESTWSP([ignore quotes],[wsp-ignore-quotes ],[-quote],
[NF: 2
0: "\"a"
1: "text\""
+TOTAL: 2
])
WSPGROUP(wsp-delim)
@@ -421,6 +461,7 @@ TESTWSP([custom delimiters (squeeze)],[],
2: list
3: " of "
4: words
+TOTAL: 5
])
TESTWSP([custom delimiters (no squeeze)],[],
@@ -433,6 +474,7 @@ TESTWSP([custom delimiters (no squeeze)],[],
3: list
4: " of "
5: words
+TOTAL: 6
])
TESTWSP([custom, with returned delimiters],[],
@@ -448,6 +490,7 @@ TESTWSP([custom, with returned delimiters],[],
6: " of "
7: :
8: words
+TOTAL: 9
])
TESTWSP([custom, with returned & squeezed delimiters],[],
@@ -464,6 +507,7 @@ TESTWSP([custom, with returned & squeezed delimiters],[],
7: " of "
8: :
9: words
+TOTAL: 10
])
WSPGROUP(wsp-sed)
@@ -474,6 +518,7 @@ TESTWSP([sed expressions],[],[sed],
0: arg1
1: "s/foo/bar/g;s/bar baz/quz quux/"
2: arg2
+TOTAL: 3
])
WSPGROUP()
@@ -485,6 +530,7 @@ TESTWSP([C escapes on],[wcp-c-escape],[cescapes],
1: form\ffeed
2: and
3: new\nline
+TOTAL: 4
])
TESTWSP([C escapes off],[wcp-c-escape-off],[-cescapes],
@@ -494,6 +540,7 @@ TESTWSP([C escapes off],[wcp-c-escape-off],[-cescapes],
1: formffeed
2: and
3: newnline
+TOTAL: 4
])
TESTWSP([ws elimination],[wsp-ws-elim],[delim ' ()' ws return_delims],
@@ -503,6 +550,7 @@ TESTWSP([ws elimination],[wsp-ws-elim],[delim ' ()' ws return_delims],
1: list
2: items
3: )
+TOTAL: 4
])
TESTWSP([ws elimination + return delim],[wsp-ws-elim-ret],
@@ -516,12 +564,14 @@ TESTWSP([ws elimination + return delim],[wsp-ws-elim-ret],
4: quux
5: :
6: baaz
+TOTAL: 7
])
TESTWSP([empty quotes],[wsp-empty-quotes],[delim : ws return_delims],
[t=""],
[NF: 1
0: t=
+TOTAL: 1
])
TESTWSP([delimiter following empty quotes],
@@ -531,6 +581,7 @@ TESTWSP([delimiter following empty quotes],
0: t=
1: :
2: r
+TOTAL: 3
])
TESTWSP([suppress ws trimming within quotes],
@@ -543,6 +594,7 @@ TESTWSP([suppress ws trimming within quotes],
2: nonewline
3: ,
4: "formatfield=In message %{text}, "
+TOTAL: 5
])
TESTWSP([unescape],
@@ -553,6 +605,7 @@ TESTWSP([unescape],
0: \\Seen
1: "quote \""
2: "bs \\"
+TOTAL: 3
])
TESTWSP([unescape: word/quote],
@@ -566,6 +619,7 @@ TESTWSP([unescape: word/quote],
3: "31 A"
4: 3x31
5: 101
+TOTAL: 6
])
TESTWSP([dquote],[],[-default novar nocmd dquote],
@@ -575,6 +629,7 @@ TESTWSP([dquote],[],[-default novar nocmd dquote],
1: "quoted example"
2: isn't
3: it
+TOTAL: 4
])
TESTWSP([squote],[],[-default novar nocmd squote],
@@ -584,6 +639,7 @@ TESTWSP([squote],[],[-default novar nocmd squote],
1: "quoted example"
2: "isn\"t"
3: it
+TOTAL: 4
])
WSPGROUP(wsp-incr)
@@ -595,10 +651,13 @@ TESTWSP([incremental],[],[incremental],
],
[NF: 1
0: incremental
+TOTAL: 1
NF: 1
0: "input test"
+TOTAL: 2
NF: 1
0: line
+TOTAL: 3
],
[input exhausted
])
@@ -610,13 +669,16 @@ TESTWSP([incremental append],[],[incremental append],
],
[NF: 1
0: incremental
+TOTAL: 1
NF: 2
0: incremental
1: "input test"
+TOTAL: 2
NF: 3
0: incremental
1: "input test"
2: line
+TOTAL: 3
],
[input exhausted
])
@@ -629,10 +691,13 @@ TESTWSP([incremental ws],
],
[NF: 1
0: a
+TOTAL: 1
NF: 1
0: list
+TOTAL: 2
NF: 1
0: test
+TOTAL: 3
],
[input exhausted
])
@@ -641,7 +706,8 @@ TESTWSP([incremental nosplit],[],[incremental nosplit],
[incremental "input test" line
],
[NF: 1
-0: "incremental \"input test\" line"
+0: "incremental input test line"
+TOTAL: 1
],
[input exhausted
])
@@ -664,6 +730,7 @@ EOT
1: dir
2: dir/file
3: end
+TOTAL: 4
])
AT_CLEANUP
@@ -682,6 +749,7 @@ EOT
0: begin
1: "dir dir/file"
2: end
+TOTAL: 3
])
AT_CLEANUP
@@ -699,6 +767,7 @@ EOT
[NF: 2
0: begin(dir
1: dir/file)end
+TOTAL: 2
])
AT_CLEANUP
@@ -715,6 +784,7 @@ EOT
[0],
[NF: 1
0: "begin(dir dir/file)end"
+TOTAL: 1
])
AT_CLEANUP
@@ -735,6 +805,7 @@ EOT
2: dir
3: dir/file
4: end
+TOTAL: 5
])
AT_CLEANUP
@@ -751,6 +822,7 @@ EOT
[0],
[NF: 1
0: "begin(dir dir/file)end"
+TOTAL: 1
])
AT_CLEANUP
@@ -771,6 +843,7 @@ EOT
1: foo
2: bar
3: baz
+TOTAL: 4
])
AT_CLEANUP
@@ -792,6 +865,7 @@ EOT
1: dir/1.c
2: dir/2.c
3: end
+TOTAL: 4
])
AT_CLEANUP
@@ -811,6 +885,7 @@ EOT
0: begin
1: dir/*.d
2: end
+TOTAL: 3
])
AT_CLEANUP
@@ -829,6 +904,7 @@ EOT
[NF: 2
0: begin
1: end
+TOTAL: 2
])
AT_CLEANUP
@@ -858,6 +934,7 @@ TESTWSP([append],[],[-- extra arguments follow],
3: extra
4: arguments
5: follow
+TOTAL: 3
])
TESTWSP([append + dooffs + env],[],
@@ -873,8 +950,69 @@ TESTWSP([append + dooffs + env],[],
6: extra
7: arguments
8: follow
+TOTAL: 4
])
+# Maxwords
+TESTWSP([maxwords],[],
+[trimnl maxwords 3],
+[ws_maxwords limits the number of returned words],
+[NF: 3
+0: ws_maxwords
+1: limits
+2: "the number of returned words"
+TOTAL: 3
+])
+
+TESTWSP([maxwords return_delims],[],
+[trimnl maxwords 8 return_delims delim :-],
+[foo:::bar-:baz-quux:ux:zu],
+[NF: 8
+0: foo
+1: :
+2: bar
+3: -
+4: :
+5: baz
+6: -
+7: quux:ux:zu
+TOTAL: 8
+])
+
+TESTWSP([maxwords return_delims -squeeze_delims],[],
+[trimnl maxwords 8 return_delims -squeeze_delims delim :-],
+[foo:::bar-:baz:qux-],
+[NF: 8
+0: foo
+1: :
+2: :
+3: :
+4: bar
+5: -
+6: :
+7: baz:qux-
+TOTAL: 8
+])
+
+TESTWSP([maxwords incremental],[],
+[trimnl maxwords 3 incremental],
+[foo bar baz qux uz
+
+
+],
+[NF: 1
+0: foo
+TOTAL: 1
+NF: 1
+0: bar
+TOTAL: 2
+NF: 1
+0: "baz qux uz"
+TOTAL: 3
+],
+[input exhausted
+]))
+
m4_popdef([TESTWSP])
m4_popdef([wspnum])
m4_popdef([wspid])

Return to:

Send suggestions and report system problems to the System administrator.