#!/bin/sh
#
# Use this shell script to test your program.  It will compile and run
# a test program.
#
# For example, to test a file named simple.pcat, type:
#       run2 simple
#
# The following files are assumed to exist:
#       tst/simple.pcat
#       tst/simple.givenInput
#       tst/simple.givenOutput1
#       tst/simple.givenOutput2
#
# The "givenInput" file will be used as the input to simple; "givenOutput1"
# is what should be produced on stdout and "givenOutput2" is what should
# be produced on stderr.
#
# This script uses "pc" to compile and execute your PCAT program.  It feeds
# "givenInput" to the program and compares its output with the "givenOutput"
# files, displaying any differences.
#
# This script will create the following files:
#       tst/simple.s
#       tst/simple
#       tst/simple.newOutput1
#       tst/simple.newOutput2
#
echo $1:
pc tst/$1 < tst/$1.givenInput 1> tst/$1.newOutput1 2> tst/$1.newOutput2
diff -w tst/$1.givenOutput1 tst/$1.newOutput1
diff -w tst/$1.givenOutput2 tst/$1.newOutput2
rm -f tst/$1.newOutput1
rm -f tst/$1.newOutput2
