aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-02-17 21:18:14 -0600
committerRob Landley <rob@landley.net>2020-02-17 21:18:14 -0600
commitc17d5be2f1c0dc4ea71630b02f0f43e64ffb605c (patch)
tree2593c8e9d71727a73075054cec0f0b0625cbf14d /tests
parenta24295758beff40825bf3b1fcb35f908a5829242 (diff)
downloadtoybox-c17d5be2f1c0dc4ea71630b02f0f43e64ffb605c.tar.gz
More sh tests.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/sh.test21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/sh.test b/tests/sh.test
index d43ed89f..2bd83e4a 100755
--- a/tests/sh.test
+++ b/tests/sh.test
@@ -91,6 +91,15 @@ testing "leading variable assignments" \
testing "IFS whitespace before/after" \
'IFS=" x"; A=" x " B=" x" C="x " D=x E=" "; for i in $A $B $C $D L$A L$B L$C L$D $A= $B= $C= $D= L$A= L$B= L$C= L$D=; do echo -n {$i}; done' \
"{}{}{}{}{L}{L}{L}{L}{}{=}{}{=}{}{=}{}{=}{L}{=}{L}{=}{L}{=}{L}{=}" "" ""
+testing "quotes and whitespace" \
+ 'A=" abc def "; for i in ""$A""; do echo =$i=; done' \
+ "==\n=abc=\n=def=\n==\n" "" ""
+testing "quotes and whitespace2" \
+ 'A=" abc def "; for i in """"$A""; do echo =$i=; done' \
+ "==\n=abc=\n=def=\n==\n" "" ""
+testing "quotes and whitespace3" \
+ 'A=" abc def "; for i in ""x""$A""; do echo =$i=; done' \
+ "=x=\n=abc=\n=def=\n==\n" "" ""
testing "IFS" 'IFS=x; A=abx; echo -n "$A"' "abx" "" ""
testing "IFS2" 'IFS=x; A=abx; echo -n $A' "ab" "" ""
@@ -101,13 +110,19 @@ testing '$*' 'cc(){ for i in $*;do echo =$i=;done;};cc "" "" "" "" ""' \
"" "" ""
testing '$*2' 'cc(){ for i in "$*";do echo =$i=;done;};cc ""' \
"==\n" "" ""
-# Flame. Flames. Flames, on the side of my face...
-testing '$*3' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" ""' \
- "= =\n" "" ""
+testing '$*3... Flame. Flames. Flames, on the side of my face...' \
+ 'cc(){ for i in "$*";do echo =$i=;done;};cc "" ""' "= =\n" "" ""
+testing 'why... oh.' \
+ 'cc() { echo ="$*"=; for i in =$*=; do echo -$i-; done;}; cc "" ""; echo and; cc ""' \
+ '= =\n-=-\n-=-\nand\n==\n-==-\n' "" ""
+testing 'really?' 'cc() { for i in $*; do echo -$i-; done;}; cc "" "" ""' \
+ "" "" ""
+testing 'Sigh.' 'cc() { echo =$1$2=;}; cc "" ""' "==\n" "" ""
testing '$*4' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "" "" "" ""' \
"= =\n" "" ""
testing '$*5' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "abc" ""' \
"= abc =\n" "" ""
+
# creating empty arguments without quotes
testing '$* + IFS' \
'IFS=x; cc(){ for i in $*; do echo =$i=;done;};cc xabcxx' \