#!/bin/bash
#
# script to run infix2postfix program repeatedly, with various
#   inputs.  
#

function dotest_() {
	echo ""; echo "input is $1";
	echo "$1" | infix2postfix
}

function dotest2lines_() {
	echo ""; echo "input is $1"; echo "    $2"
	infix2postfix << EOF
	$1
	$2
EOF
}

echo ""; echo "**simple tests:"
dotest_ "x"
dotest_ "( x + y )"
dotest_ "( xy Q zw )"
dotest2lines_ "( x + " "z )"

echo ""; echo "**tests of error checking:"
dotest_ " "
dotest_ "x y"
dotest_ "("
dotest_ "( x"
dotest_ "( x + "
dotest_ "( x + y"
dotest_ "( x + y z)"
dotest_ "(x + y) z"

echo ""; echo "**more complicated tests:"
dotest_ "( ( x + y ) / z )"
dotest_ "( a + ( b / c ) )"
dotest_ "( ( a + b ) * ( c / d ) )"
dotest_ "( ( ( ( a + b ) * ( c * d ) ) - ( e - f ) ) Z \
	( ( k Q l ) + ( ( g / h ) / ( i % j ) ) ) )"
