aboutsummaryrefslogtreecommitdiff
path: root/tests/test.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-12-01 21:58:28 -0600
committerRob Landley <rob@landley.net>2018-12-01 21:58:28 -0600
commitaf6d35ed53de2913e10d1a381a8378eb2c5e6943 (patch)
treeebd232d54bf1a6a1e2409b9be94c63c13d6dc7c1 /tests/test.test
parent428df7d7743859538361f2b2beb3c98aaddd1d38 (diff)
downloadtoybox-af6d35ed53de2913e10d1a381a8378eb2c5e6943.tar.gz
Stop testing the shell builtin, test the actual command.
Diffstat (limited to 'tests/test.test')
-rw-r--r--[-rwxr-xr-x]tests/test.test57
1 files changed, 36 insertions, 21 deletions
diff --git a/tests/test.test b/tests/test.test
index 40a90864..8b60c0bd 100755..100644
--- a/tests/test.test
+++ b/tests/test.test
@@ -4,6 +4,13 @@
#testing "name" "command" "result" "infile" "stdin"
+testcmd '0 args' '; echo $?' '1\n' '' ''
+testcmd '1 arg' '== ; echo $?' '0\n' '' ''
+testcmd '2 args' '-e == ; echo $?' '1\n' '' ''
+testcmd '3 args' '-e == -e ; echo $?' '0\n' '' ''
+testcmd '' '\( == \) ; echo $?' '1\n' '' ''
+testcmd '' '\( == \( ; echo $?' '0\n' '' ''
+
# TODO: Should also have device and socket files
mkdir d
@@ -14,15 +21,10 @@ mkfifo p
type_test()
{
- result=""
for i in d f L s p n
do
- if test $* $i
- then
- result=$result$i
- fi
+ "$C" $* $i && echo -n $i
done
- printf "%s" $result
}
testing "-b" "type_test -b" "" "" ""
@@ -35,33 +37,46 @@ testing "-s" "type_test -s" "ds" "" ""
testing "-S" "type_test -S" "" "" ""
testing "-p" "type_test -p" "p" "" ""
testing "-e" "type_test -e" "dfLsp" "" ""
-testing "! -e" "type_test ! -e" "n" "" ""
+testing "! -e" 'type_test ! -e' "n" "" ""
rm f L s p
rmdir d
# TODO: Test rwx gu t
-testing "test" "test "" || test a && echo yes" "yes\n" "" ""
-testing "-n" "test -n "" || test -n a && echo yes" "yes\n" "" ""
-testing "-z" "test -n a || test -n "" && echo yes" "yes\n" "" ""
-testing "a = b" "test a = b || test "" = "" && echo yes" "yes\n" "" ""
-testing "a != b" "test "" != "" || test a = b && echo yes" "yes\n" "" ""
+testing "" "$C '' || echo yes" "yes\n" "" ""
+testing "" "$C a && echo yes" "yes\n" "" ""
+testing "-n" "$C -n '' || echo yes" "yes\n" "" ""
+testing "-n2" "$C -n a && echo yes" "yes\n" "" ""
+testing "-z" "$C -z '' && echo yes" "yes\n" "" ""
+testing "-z2" "$C -z a || echo yes" "yes\n" "" ""
+testing "" "$C a = b || echo yes" "yes\n" "" ""
+testing "" "$C '' = '' && echo yes" "yes\n" "" ""
+testing "a != b" "$C a != b && echo yes" "yes\n" "" ""
+testing "a != b" "$C a != a || echo yes" "yes\n" "" ""
arith_test()
{
- test -1 $1 1 && echo l
- test 0 $1 0 && echo e
- test -3 $1 -5 && echo g
+ $C -1 $1 1 && echo -n l
+ $C 0 $1 0 && echo -n e
+ $C -3 $1 -5 && echo -n g
}
-testing "-eq" "arith_test -eq" "e\n" "" ""
-testing "-ne" "arith_test -ne" "l\ng\n" "" ""
-testing "-gt" "arith_test -gt" "g\n" "" ""
-testing "-ge" "arith_test -ge" "e\ng\n" "" ""
-testing "-lt" "arith_test -lt" "l\n" "" ""
-testing "-le" "arith_test -le" "l\ne\n" "" ""
+testing "-eq" "arith_test -eq" "e" "" ""
+testing "-ne" "arith_test -ne" "lg" "" ""
+testing "-gt" "arith_test -gt" "g" "" ""
+testing "-ge" "arith_test -ge" "eg" "" ""
+testing "-lt" "arith_test -lt" "l" "" ""
+testing "-le" "arith_test -le" "le" "" ""
# test ! = -o a
# test ! \( = -o a \)
# test \( ! = \) -o a
+# test \( \)
+
+#testing "" "[ -a -eq -a ] && echo yes" "yes\n" "" ""
+
+# -e == -a
+# -e == -a -o -d != -o
+# \( "x" \) -a \) == \)
+# \( ! ! ! -e \) \)