#!/bin/bash
#
# script to run tautology-checker program repeatedly, with various
#   inputs.  
#

function dotest_() {
	echo ""; echo "input is " $1;
	echo $1 | tautology-checker
}

function dotest_unary_op_() {
	dotest_ "true $1";
	dotest_ "false $1"
}

function dotest_binary_op_() {
	dotest_ "true true $1";
	dotest_ "true false $1";
	dotest_ "false true $1";
	dotest_ "false false $1"
}

#### 
echo ""; echo "**** testing true, false, operators:"
dotest_ "true"
dotest_ "false"
dotest_unary_op_ "!"
dotest_binary_op_ "&&"
dotest_binary_op_ "||"
dotest_binary_op_ "=>"
dotest_binary_op_ "=="

#### 
echo ""; echo "**** testing less trivial constant expressions:"
dotest_ "true false || true &&"
dotest_ "false true false || ||"
dotest_ "false true || true false || &&"
dotest_ "false true false || &&"

####
echo ""; echo "**** testing error checking:"
# too few operands for operator
dotest_ "!"
dotest_ "true &&"
dotest_ "true ||"
dotest_ "true =>"
dotest_ "true =="
# stack size at end not 1
dotest_ " "
dotest_ "true true"
# slightly more complicated tests
dotest_ "true true && &&"
dotest_ "true true !"

####
echo ""; echo "**** testing simple non-constant expressions:"
dotest_ "x"
dotest_ "x x =="
dotest_ "x y =="
dotest_ "x x ! ||"
dotest_ "x y && ! x ! y ! || =="
dotest_ "x ! y ! z ! || ||"

####
echo ""; echo "**** testing complex non-constant expressions:"
dotest_ "a a ! || b b ! || c c ! || d d ! || && && &&"
dotest_ "a a ! || b b ! || c c ! || d d ! || e e ! || f f ! || \
	&& && && && &&"

