2013-07-17 20:25:48 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2013-07-18 08:54:25 +00:00
|
|
|
typeset -a listfic
|
|
|
|
if (($#==0)); then
|
|
|
|
listfic=( tests/*(.N) )
|
|
|
|
else
|
|
|
|
for arg in $@; do
|
|
|
|
listfic=( $listfic tests/$arg )
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-07-18 08:47:46 +00:00
|
|
|
tmpfic=tests/tmp
|
2013-07-18 08:54:25 +00:00
|
|
|
for input in $listfic; do
|
2013-07-18 08:47:46 +00:00
|
|
|
sed 's/\\/\\\\/g' $input > $tmpfic
|
|
|
|
# set 3 as the file descriptor for the file $tmpfic
|
|
|
|
exec 3< $tmpfic
|
|
|
|
done=0
|
|
|
|
num=1
|
|
|
|
until ((done == 1)); do
|
|
|
|
read <&3 program
|
|
|
|
(($?!=0)) && {done=1;continue}
|
|
|
|
read <&3 expected
|
|
|
|
(($?!=0)) && {done=1;continue}
|
2013-07-18 16:55:18 +00:00
|
|
|
result="$(runghc y.hs "$program")"
|
2013-07-18 08:47:46 +00:00
|
|
|
printf "%18s (line %3d): " ${input:t} $num
|
|
|
|
if [[ $expected == $result ]]; then
|
|
|
|
print -- "OK"
|
|
|
|
else
|
|
|
|
print -- "ERROR"
|
|
|
|
print -- " program: '$program'"
|
|
|
|
print -- " expected: '$expected'"
|
|
|
|
print -- " got: '$result'"
|
|
|
|
print -- ""
|
|
|
|
fi
|
|
|
|
((num+=2))
|
|
|
|
done
|
2013-07-17 20:25:48 +00:00
|
|
|
done
|
2013-07-18 08:47:46 +00:00
|
|
|
\rm -f $tmpfic
|