#!/bin/sh
#
#  Test-icont -- test the Icon translator and interpreter.
#
#  usage:  Test-icont [file...]
#
#  If $IC is set to iconc, the compiler will be used instead.

IC=${IC-icont}
IC=../../bin/$IC

unset ICONX IPATH LPATH FPATH
unset BLKSIZE BLOCKSIZE HEAPSIZE STRSIZE
unset MSTKSIZE COEXPSIZE QLSIZE

#  check that icont and iconx have been built
ls $IC ../../bin/iconx >/dev/null || exit 0

#  if no files specified, run them all
if [ $# = 0 ]; then
   set - *.std
fi

for F in $*; do
   F=`basename $F .std`
   F=`basename $F .icn`
   rm -f $F.out
   echo "Testing $F"
   $IC -s $F.icn || continue
   if test -r $F.dat
   then
      ./$F <$F.dat >$F.out 2>&1
   else
      ./$F </dev/null >$F.out 2>&1
   fi
   diff $F.std $F.out
   rm -f $F
done
