#!/bin/sh

# Sticky bit used for test cases that should not yet
# be checked. i.e. Unimplemented functionality.

# Check for expected failures.
echo -n "Fail tests: "
for i in `ls -1d test/fail/* | sort +0.10 -n`; do
  if [ -k $i/in ]; then
    echo -n "("`basename $i`") "
    continue
  fi
  echo -n `basename $i`" "
  if ./algol60 < $i/in > /dev/null 2> test/.chkerr; then
    echo '<Pass '
    exit
  elif ! diff -u $i/err test/.chkerr; then
    echo '<Message '
#    exit
  fi
done

echo
echo -n "Pass tests: "
for i in `ls -1d test/pass/* | sort +0.10 -n`; do
  NUMBER=`basename $i`

  if [ -k $i/in ]; then
    echo -n "($NUMBER) "
    continue
  fi
  echo -n "$NUMBER "

  ./algol60 < $i/in > test/.chking 2> /dev/null
  if ! echo "$ALGOL" | diff -u $i/mu test/.chking &> /dev/null; then
    echo '<Code '
    if [ "$OUTPUT" ]; then diff -u $i/mu test/.chking; fi
  fi

  if [ -f $i/mubug ]; then
    egrep '^declare' test/.chking > test/.mubugdecl
    egrep -v '^declare' test/.chking > test/.mubugcode
    cat test/.mubug{decl,code} > test/.chking
    rm -f test/.mubug{decl,code}
  fi

  MUOUT=`../mu < test/.chking 2>&1 > test/.chkexec | egrep -v '^(MU Interpreter|Execution|Program)'`
  if [ "$MUOUT" ]; then
    echo '<Exec'
    echo $MUOUT
    exit
  elif ! diff -u $i/out test/.chkexec; then
    exit
  fi

  rm -f test/.chk{ing,exec,err}
done
echo
