Lines Matching refs:testing
37 [ -f testing.sh ] && . testing.sh
64 testing '-c "" exit status 0' '$SH -c "" && echo $?' '0\n' '' ''
65 testing '-c args' "\$SH -c 'echo \$0,\$1,\$2,\$3' one two three four five" \
67 testing '-c args2' "\$SH -c 'echo \${10}' a b c d e f g h i j k l" "k\n" "" ""
68 testing '-c arg split' \
71 testing '-c arg split2' \
74 testing '-c arg count' "$SH -c 'echo \$#' 9 8 7 6 1 2 3 4" "7\n" "" ""
75 testing "exec3" '$C -c "{ exec readlink /proc/self/fd/0;} < /proc/self/exe"' \
77 testing 'arg shift' "$SH -c '"'for i in "" 2 1 1 1; do echo $? $1; shift $i; done'"' one two three …
79 testing '(subshell)' '$SH -c "(echo hello)"' 'hello\n' '' ''
80 testing 'syntax' '$SH -c "if true; then echo hello | fi" 2>/dev/null || echo x'\
85 testing 'non-absolute $_' "./bash -c 'echo \$_'" './bash\n' '' ''
95 testing '$_ literal after exec' 'env >/dev/null; echo $_' 'env\n' '' ''
97 testing 'prefix is local for builtins' 'abc=123; abc=def unset abc; echo $abc' \
99 testing 'prefix localizes magic vars' \
102 testing '$NOTHING clears $_' 'true; $NOTHING; echo $_' '\n' '' ''
104 testing 'exec exitval' "$SH -c 'exec echo hello' && echo \$?" "hello\n0\n" "" ""
105 testing 'simple script' '$SH input' 'input\n' 'echo $0' ''
106 testing 'simple script2' '$SH ./input two;echo $?' './input+two\n42\n' \
109 toyonly testing 'recursion guard' \
112 testing '$LINENO 1' "$SH input" "1\n" 'echo $LINENO' ''
116 testing 'simple script in $PATH' "PATH='$PWD/sub:$PATH' $SH script" \
120 testing "script file" "chmod +x input; ./input" "hello\n" "#!$C\necho hello" ""
121 testing 'IFS $*' "$SH -c 'IFS=xy; echo \"\$*\"' one two tyree" "twoxtyree\n" \
123 testing 'default exports' \
129 testing "lineno" "$SH input" "5 one\n6 one\n5 two\n6 two\n" \
131 testing "eval0" "sh -c 'eval echo \$*' one two three" "two three\n" "" ""
137 testing "smoketest" "echo hello" "hello\n" "" ""
138 testing "line break" $'ec\\\nho hello' 'hello\n' '' ''
139 testing "eval" "eval echo hello" "hello\n" "" ""
140 testing "eval2" "eval 'echo hello'; echo $?" "hello\n0\n" "" ""
141 testing "eval3" 'X="echo hello"; eval "$X"' "hello\n" "" ""
142 testing "eval4" 'eval printf '=%s=' \" hello \"' "= hello =" "" ""
143 NOSPACE=1 testing "eval5" 'eval echo \" hello \" | wc' ' 1 1 8' "" ""
144 testing "exec" "exec echo hello" "hello\n" "" ""
145 testing "exec2" "exec echo hello; echo $?" "hello\n" "" ""
148 testing "semicolon" "echo one;echo two" "one\ntwo\n" "" ""
149 testing "simple pipe" "echo hello | cat" "hello\n" "" ""
150 testing "&&" "true && echo hello" "hello\n" "" ""
151 testing "&&2" "false && echo hello" "" "" ""
152 testing "||" "true || echo hello" "" "" ""
153 testing "||2" "false || echo hello" "hello\n" "" ""
154 testing "&& ||" "true && false && potato || echo hello" "hello\n" "" ""
155 testing "&& after function" "x(){ false;};x && echo yes" "" "" ""
156 testing "|| after function" "x(){ false;};x || echo yes" "yes\n" "" ""
160 testing "redir1" "cat < input" "hello\n" "hello\n" ""
161 testing "redir2" "echo blah >out; cat out" "blah\n" "" ""
162 testing "redir3" "echo more >>out; cat out" "blah\nmore\n" "" ""
163 testing "redir4" "touch /not/exist 2>out||grep -o /not/exist out" \
165 testing "redir5" "ls out /not/exist &> out2 || wc -l < out2" "2\n" "" ""
166 testing "redir6" "ls out /not/exist &>>-abc || wc -l < ./-abc" "2\n" "" ""
167 testing "redir7" "ls out /not/exist |& wc -l" "2\n" "" ""
168 testing "redir8" 'echo -n $(<input)' "boing" "boing\n" ""
171 testing "redir10" 'echo hello 3<&3' "hello\n" "" ""
172 testing "redir11" 'if :;then echo one;fi {abc}<input; cat <&$abc' \
178 testing "tilde expansion" "echo ~" "$HOME\n" "" ""
179 testing "tilde2" "echo ~/dir" "$HOME/dir\n" "" ""
180 testing "bracket expansion" \
182 testing "brackets2" "echo {A{a,b}B{c,d}C,D}" "AaBcC AaBdC AbBcC AbBdC D\n" "" ""
183 testing "brackets3" 'echo {A"b,c"D}' "{Ab,cD}\n" "" ""
184 testing "brackets4" 'echo {A"bc",D}' "Abc D\n" "" ""
185 testing "brackets5" 'echo {A,B,C' "{A,B,C\n" "" ""
186 testing "brackets6" 'echo {{{{A,B},C}D},E}' "{AD} {BD} {CD} E\n" "" ""
187 testing "brackets7" 'echo {{{a,b},c,{d,e}},f}' "a b c d e f\n" "" ""
188 testing "brackets8" 'echo A{a{b,c{B,C}D}d{e,f},g{h,i}j}E' \
190 testing "brackets9" 'echo A{B{C,D}E{N,O},F{G,H}I}J{K,L}M' \
193 testing "bracket+tilde" "echo {~,~root}/pwd" "$HOME/pwd $EXPECT/pwd\n" "" ""
197 testing '${x#prefix}' 'x=abcde; echo ${x#abc}' 'de\n' '' ''
198 testing '${x#short} ${x##long}' 'x=banana; echo ${x#b*n} ${x##b*n}' \
200 toyonly testing '${x#utf8}' 'x=aそcde; echo ${x##a?c}' 'de\n' '' ''
201 testing '${x%y}' 'x=potato; echo ${x%t*o} ${x%%t*o}' 'pota po\n' '' ''
202 testing '${x^y}' 'x=aaaaa; echo ${x^a}' 'Aaaaa\n' '' ''
203 testing '${x^^y}' 'x=abccdec; echo ${x^^c}; x=abcdec; echo ${x^^c}' \
205 testing '${x,y}' 'x=BBB; echo ${x,B}' 'bBB\n' '' ''
206 testing '${x,,y}' 'x=POTATO; echo ${x,,} ${x,,?} ${x,,*} ${x,,T}' \
211 testing 'wildcards' 'echo w[v-x]w w[x-v]w abc/*/ghi' \
216 testing '$(( ) )' 'echo ab$((echo hello) | tr e x)cd' "abhxllocd\n" "" ""
217 testing '$((x=y)) lifetime' 'a=boing; echo $a $a$((a=4))$a $a' 'boing boing44 4\n' '' ''
219 testing 'quote' "echo \"'\"" "'\n" "" ""
222 testing "case" 'for i in A C J B; do case "$i" in A) echo got A ;; B) echo and B ;; C) echo then C …
224 testing 'case;;&' 'case wow in w?w) echo ok;;& wow) echo no; esac' 'ok\nno\n' \
226 testing "case newlines" \
229 testing 'loop in && ||' \
231 testing "continue" 'for i in a b c; do for j in d e f; do echo $i $j; continue 2; done; done' \
233 testing "piped loops that don't exit" \
239 testing "expand" 'echo $PWD' "$(pwd)\n" "" ""
240 testing "expand2" 'echo "$PWD"' "$(pwd)\n" "" ""
241 testing "expand3" 'echo "$"PWD' '$PWD\n' "" ""
242 testing "expand4" 'P=x; echo "$P"WD' 'xWD\n' "" ""
243 testing "dequote" "echo one 'two' ''three 'fo'ur '\\'" \
246 testing "leading variable assignment" 'abc=def env | grep ^abc=; echo $abc' \
248 testing "leading variable assignments" \
251 testing "leading assignment occurs after parsing" \
253 testing "leading assignment space" 'X="abc def"; Y=$X; echo "$Y"' \
255 testing "leading assignment space2" \
257 testing "leading assignment fail2" \
259 testing "leading assignment redirect" \
263 testing "{1..5}" "echo {1..5}" "1 2 3 4 5\n" "" ""
264 testing "{5..1}" "echo {5..1}" "5 4 3 2 1\n" "" ""
265 testing "{5..1..2}" "echo {5..1..2}" "5 3 1\n" "" ""
266 testing "{a..z..-3}" "echo {a..z..-3}" "a d g j m p s v y\n" "" ""
269 testing 'background curly block' \
273 testing 'background pipe block' \
282 testing "IFS whitespace before/after" \
285 testing "quotes and whitespace" \
288 testing "quotes and whitespace2" \
291 testing "quotes and whitespace3" \
295 testing "IFS" 'IFS=x; A=abx; echo -n "$A"' "abx" "" ""
296 testing "IFS2" 'IFS=x; A=abx; echo -n $A' "ab" "" ""
297 testing "IFS3" 'IFS=x; echo "$(echo abx)"' "abx\n" "" ""
298 testing "IFS4" 'IFS=x; echo $(echo abx)y' "ab y\n" "" ""
299 testing "IFS5" 'IFS=xy; for i in abcxdefyghi; do echo =$i=; done' \
302 testing 'empty $! is blank' 'echo $!' "\n" "" ""
303 testing '$! = jobs -p' 'true & [ $(jobs -p) = $! ] && echo yes' "yes\n" "" ""
305 testing '$*' 'cc(){ for i in $*;do echo =$i=;done;};cc "" "" "" "" ""' \
307 testing '$*2' 'cc(){ for i in "$*";do echo =$i=;done;};cc ""' \
309 testing '$*3... Flame. Flames. Flames, on the side of my face...' \
311 testing 'why... oh.' \
314 testing 'really?' 'cc() { for i in $*; do echo -$i-; done;}; cc "" "" ""' \
316 testing 'Sigh.' 'cc() { echo =$1$2=;}; cc "" ""' "==\n" "" ""
317 testing '$*4' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "" "" "" ""' \
319 testing '$*5' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "abc" ""' \
323 testing '$* + IFS' \
326 testing '$@' 'cc(){ for i in "$@";do echo =$i=;done;};cc "" "" "" "" ""' \
328 testing "IFS10" 'IFS=bcd; A=abcde; for i in $A; do echo =$i=; done' \
330 testing "IFS11" \
333 testing "IFS12" 'IFS=3;chicken(){ return 3;}; chicken;echo 3$?3' '3 3\n' "" ""
335 testing "IFS combinations" \
339 testing "! isn't special" "echo !" "!\n" "" ""
340 testing "! by itself" '!; echo $?' "1\n" "" ""
341 testing "! true" '! true; echo $?' "1\n" "" ""
342 testing "! ! true" '! ! true; echo $?' "0\n" "" ""
343 testing "! syntax err" '! echo 2>/dev/null < doesnotexist; echo $?' "0\n" "" ""
346 testing "case quoting" 'case a in "a") echo hello;; esac' 'hello\n' "" ""
348 testing "subshell splitting" 'for i in $(true); do echo =$i=; done' "" "" ""
352 testing "assignment nosplit" 'X="one two"; Y=$X; echo $Y' "one two\n" "" ""
353 testing "argument splitting" \
356 testing "assignment nosplit2" 'pop(){ X="$@";};pop one two three; echo $X' \
364 testing "subshell exit err" '(exit 42); echo $?' "42\n" "" ""
370 testing "exec in paren" \
372 testing "exec in brackets" \
375 NOSPACE=1 testing "curly brackets and pipe" \
378 NOSPACE=1 testing "parentheses and pipe" \
381 testing "pipe into parentheses" \
385 testing "\$''" $'echo $\'abc\\\'def\\nghi\'' "abc'def\nghi\n" '' ''
386 testing "shift shift" 'shift; shift; shift; echo $? hello' "1 hello\n" "" ""
387 testing 'search cross $*' 'chicken() { echo ${*/b c/ghi}; }; chicken a b c d' \
389 testing 'eval $IFS' 'IFS=x; X=x; eval abc=a${X}b 2>/dev/null; echo $abc' \
391 testing '${@:3:5}' 'chicken() { for i in "${@:3:5}"; do echo =$i=; done; } ; chicken ab cd ef gh ij…
393 testing '${@:3:5}' 'chicken() { for i in "${*:3:5}"; do unset IFS; echo =$i=; done; } ; IFS=x chick…
395 testing 'sequence check' 'IFS=x; X=abxcd; echo ${X/bxc/g}' 'agd\n' '' ''
408 testing 'here3' 'abc(){ cat <<< x"$@"yz;};abc one two "three four"' \
411 testing '${var}' 'X=abcdef; echo ${X}' 'abcdef\n' '' ''
412 testing '${#}' 'X=abcdef; echo ${#X}' "6\n" "" ""
413 testing 'empty ${}' '{ echo ${};} 2>&1 | grep -o bad' 'bad\n' '' ''
416 testing '${$b}' '{ echo ${$b};} 2>&1 | grep -o bad' 'bad\n' '' ''
417 testing '${!PATH*}' 'echo ${!PATH*}' 'PATH\n' '' ''
418 testing '${!PATH@}' 'echo ${!PATH@}' 'PATH\n' '' ''
420 testing '${!x}' 'X=abcdef Y=X; echo ${!Y}' 'abcdef\n' '' ''
421 testing '${!x@}' 'ABC=def; def=ghi; echo ${!ABC@}' 'ABC\n' '' ''
422 testing '${!x} err' '{ X=abcdef Y=X:2; echo ${!Y}; echo bang;} 2>/dev/null' \
424 testing '${!x*}' 'abcdef=1 abc=2 abcq=; echo "${!abc@}" | tr " " \\n | sort' \
426 testing '${!x*} none' 'echo "${!abc*}"' '\n' '' ''
427 testing '${!x*} err' '{ echo "${!abc*x}"; echo boing;} 2>/dev/null' '' '' ''
428 testing '${!none@Q}' 'echo ${X@Q} ${!X@Q}; X=ABC; echo ${!X@Q}' '\n\n' '' ''
429 testing '${!x@Q}' 'ABC=123 X=ABC; echo ${!X@Q}' "'123'\n" '' ''
430 testing '${#@Q}' 'echo ${#@Q}' "'0'\n" '' ''
431 testing '${!*}' 'xx() { echo ${!*};}; fruit=123; xx fruit' '123\n' '' ''
432 testing '${!*} indirect' 'xx() { echo ${!a@Q};}; a=@; xx one two three' \
434 testing '${!x@ } match' \
436 testing '${!x@ } no match no err' 'echo ${!ABC@ }def' 'def\n' '' ''
437 testing '${!x@ } no match no err2' 'ABC=def; echo ${!ABC@ }ghi' 'ghi\n' '' ''
438 toyonly testing '${#x::}' 'ABC=abcdefghijklmno; echo ${#ABC:1:2}' '5\n' '' ''
440 testing '$""' 'ABC=def; echo $"$ABC"' 'def\n' '' ''
441 testing '"$""" does not nest' 'echo "$"abc""' '$abc\n' '' ''
442 testing '${\}}' 'ABC=ab}cd; echo ${ABC/\}/x}' 'abxcd\n' '' ''
443 testing 'bad ${^}' '{ echo ${^};} 2>&1 | grep -o bad' 'bad\n' '' ''
444 testing '${:}' 'ABC=def; echo ${ABC:1}' 'ef\n' '' ''
445 testing '${a: }' 'ABC=def; echo ${ABC: 1}' 'ef\n' '' ''
446 testing '${a :}' 'ABC=def; { echo ${ABC :1};} 2>&1 | grep -o bad' 'bad\n' '' ''
447 testing '${::}' 'ABC=defghi; echo ${ABC:1:2}' 'ef\n' '' ''
448 testing '${: : }' 'ABC=defghi; echo ${ABC: 1 : 2 }' 'ef\n' '' ''
449 testing '${::} indirect' 'ABC=defghi:1:2; { echo ${!ABC};} 2>&1 | grep -o bad' \
451 testing '${::-}' 'ABC=defghi; echo ${ABC:1:-2}' 'efg\n' '' ''
452 testing '${:-:-}' 'ABC=defghi; echo ${ABC:-3:2}' 'defghi\n' '' ''
453 testing '${:-:-}2' 'echo ${ABC:-3:2}' '3:2\n' '' ''
454 testing '${: -:}' 'ABC=defghi; echo ${ABC: -3:2}' 'gh\n' '' ''
455 testing '${@%}' 'chicken() { for i in "${@%abc}"; do echo "=$i="; done;}; chicken 1abc 2abc 3abc' '…
456 testing '${*%}' 'chicken() { for i in "${*%abc}"; do echo "=$i="; done;}; chicken 1abc 2abc 3abc' '…
457 testing '${@@Q}' 'xx() { echo "${@@Q}"; }; xx one two three' \
467 testing 'SECONDS' 'readonly SECONDS=41; sleep 1; echo $SECONDS' '42\n' '' ''
469 testing 'SECONDS2' 'SECONDS=123+456; echo $SECONDS' '0\n' '' '' #bash!!
470 testing '$LINENO 2' $'echo $LINENO\necho $LINENO' '0\n1\n' '' ''
471 testing '$EUID' 'echo $EUID' "$(id -u)\n" '' ''
472 testing '$UID' 'echo $UID' "$(id -ur)\n" '' ''
474 testing 'readonly leading assignment' \
477 testing 'readonly leading assignment2' \
479 testing 'readonly for' \
482 testing 'readonly {}<' \
484 testing '$_ 1' 'echo walrus; echo $_' 'walrus\nwalrus\n' '' ''
485 testing '$_ 2' 'unset _; echo $_' '_\n' '' ''
490 testing 'IFS wildcards' \
520 testing 'source file' 'source input' 'hello\n' 'echo hello \\\n' ''
521 testing '. file' '. input' 'hello\n' 'echo hello \\\n' ''
522 testing 'source no newline' 'source input' 'hello \\\n' 'echo hello \\' ''