#! /bin/sh

SUCCESS=0

. dtx/definitions

if [ $# != 1 ]; then
    SUCCESS=1
else
    cat "$1" | (SUCCESS=0;
    IFS=''
    export LINE=1
    while read i0; do
	l0="$(echo "$i0"
	      while read i0; do
		  echo "$i0"
		  if [ x"$i0" = "xEOF" ]; then
		      break;
		  fi
	      done)"
	LINE=$(expr $LINE + 1)
	lz="$(sh -c "$l0")"
	SUCCESS=$?
	LINE=$(expr $LINE - 1)
	if [ $SUCCESS != 0 ]; then
	    /bin/echo -n >&2 $0: "$1"\[$LINE\]:" "
	    echo >&2 exited $SUCCESS
#	    echo >&2 test was "$l0"
	    break
	fi
	read lx
	f0="$(echo "$l0" | tr \\n \ )"
	l1="$(echo $f0 | cut -b -4)"
	if [ x"$l1" = xsrc/ ]; then
	    l1="$(echo "$f0" | cut -b 5-)"
	else
	    l1="$f0"
	fi
#	l2=$(expr length "$l1")
	l2=$(src/express17 'length(s1)' text s1 "$l1")
	if [ 63 -lt "$l2" ]; then
	    l1="$(echo "$l1" | cut -b -60)"...
	fi
	printf "%-64s" "$l1"
	if [ x"$lx" != x"$lz" ]; then
	    src/express17 '"[\033[1;31mfailed\033[0;39m]"'
#	    echo [failed]
	else
#	    src/express17 '"[\033[1;32mpassed\033[0;39m]"'
	    echo [passed]
	fi
	if [ x"$lx" != x"$lz" ]; then
	    echo >&2 $0: "$1"\[$LINE\]:" failed "\`"$l0"\'
	    /bin/echo -n >&2 $0: "$1"\[$LINE\]:" "
	    echo >&2 output was \`"$lz"\'
	    /bin/echo -n >&2 $0: "$1"\[$LINE\]:" "
	    echo >&2 "  expected" \`"$lx"\'
	    SUCCESS=1
	    break
	fi
	LINE=$(src/express17 "$LINE + 1 + $(echo "$l0" | wc -l)")
    done
    exit $SUCCESS)
    SUCCESS=$?
fi

exit $SUCCESS
