eddie-0.2: test.sh
#!/bin/sh
# $1 is args to use with eddie.hs to process a file, $2 is a shell command to
# run the same process. Run them both on our test file.
# If the outputs differ, report failure of $3, including output unless $4
# is present.
test () {
TEST=$(eval runghc eddie.hs $1 < eddie.hs)
EXPECTED=$(eval "cat eddie.hs | $2")
if [ "$EXPECTED" != "$TEST" ]
then
FAILED="yes"
echo -e
if [ -n "$4" ]
then
echo $3 failed "(output supressed)"
else
echo $3 failed: expected $EXPECTED, got $TEST
fi
fi
echo -n .
}
FAILED="no"
test "" "echo 'usage: eddie.hs [options] (-e expr | expr) [files ...]'; echo '--help for options'" "No arguments test"
test "show.length" "wc -c | xargs echo" "simple char count"
test "show.length.lines" "wc -l | xargs echo" "line count"
test "show.length.words" "wc -w | xargs echo " "word count"
test "-e show.length" "wc -c | xargs echo" "test -e option"
test "-e 'let taker = take 10 in' -e unlines.taker.lines" head "double -e option test"
test "-l reverse" "rev eddie.hs" "test -l option" X
test "-m Text.Printf 'unlines . (zipWith (printf \"%6d\t%s\") [(1::Int) ..]) . lines'" 'cat -n' 'test -m option' X
test "-M Text.Printf,P 'unlines . (zipWith (P.printf \"%6d\t%s\") [(1::Int) ..]) . lines'" 'cat -n' 'test -M option' X
echo -e
if [ $FAILED = "yes" ]
then
exit 1
else
exit 0
fi