ref: 39321d74d876356004c5314fbeb58fdaa36545aa
dir: /sys/src/cmd/test/test.rc/
#!/bin/rc rfork e ERROR=0 FAILED=0 fn t{ # $1 -> exit code # $2 -> $test expression expect=$1 shift # check for syntax errors syntax=`{../$O.test $* >[2=1]} if(~ $"syntax ''){ switch($expect){ case 0 if(! ../$O.test $*) failed $expect $* case 1 if(../$O.test $*) failed $expect $* } } if not error } fn error{ echo echo ' '^$"syntax ERROR=`{echo $ERROR 1 + p | dc} } fn failed{ echo -n $1^': test' $*(2-)^'^: failed' echo ' failed' FAILED=`{echo $FAILED 1 + p | dc} } t 0 b '=' b t 1 b '!=' b t 0 '(' b '=' b ')' t 1 ! '(' b '=' b ')' t 1 ! -f /bin/rc t 0 -h '=' -h t 0 -o '=' -o #t 1 -f '=' h t 1 -h '=' f t 1 -o '=' f t 1 f '=' -o t 0 '(' -h '=' -h ')' t 1 '(' a '=' -h ')' #t 1 '(' -f '=' h ')' t 0 -h '=' -h -o a t 0 '(' -h '=' -h ')' -o 1 t 0 -h '=' -h -o -h '=' -h t 0 '(' -h '=' -h ')' -o '(' -h '=' -h ')' t 0 roedelheim '=' roedelheim t 1 potsdam '=' berlin-dahlem t 0 -d / t 0 -d / -a a '!=' b t 1 -z -z t 0 -n -n t 0 0 t 0 '(' 0 ')' t 0 '-E' t 0 -X -a -X t 0 -XXX t 0 '(' -E ')' t 0 true -o X t 0 true -o -X t 0 '(' '(' '(' a '=' a ')' -o 1 ')' -a 1 ')' #t 1 -h / t 0 -r / t 1 -w /dev/zero t 0 -w /dev/null t 1 -x /dev/null t 0 -x /bin/rc #t 0 -c /dev/null #t 0 -b /dev/fd0a -o -b /dev/rfd0a -o true t 0 -f /adm/users t 0 -s /adm/users t 1 ! '(' 700 -le 1000 -a -n 1 -a 20 '=' 20 ')' t 0 100 -eq 100 t 0 100 -lt 200 t 1 1000 -lt 200 t 0 1000 -gt 200 t 0 1000 -ge 200 t 0 1000 -ge 1000 t 1 2 -ne 2 t 0 0 -eq 0 t 1 -5 -eq 5 t 0 '(' 0 -eq 0 ')' t 1 1 -eq 0 -o a '=' a -a 1 -eq 0 -o a '=' aa #t 0 '" +123 " -eq 123' #t 1 '"-123 " -gt " -1"' t 0 123 -gt -123 t 0 -0 -eq +0 t 1 +0 -gt 0 t 0 0 -eq 0 t 0 0000 -eq -0 t 0 -1 -gt -2 t 1 1 -gt 2 t 1 4294967296 -eq 0 t 0 12345678901234567890 -eq +12345678901234567890 t 1 '' -o '' t 1 '' -a '' t 1 a -a '' t 0 a -a ! '' t 1 '' t 0 ! '' t 0 1 -eq 1 t 1 ! 1 -eq 1 t 0 ! ! 1 -eq 1 t 1 ! ! ! 1 -eq 1 t 1 ! '(' XXX -o XXX ')' t 0 ! '(' ! '(' XXX -o XXX ')' ')' if(! ~ $ERROR 0 || ! ~ $FAILED 0){ echo echo 'Syntax errors:' $ERROR 'Failed:' $FAILED } if(! ~ $ERROR 0 || ! ~ $FAILED 0) exit 'failures' exit ''