#! /bin/bash

criteria="*.xc"
tot_passed=0
tot_failed=0

function xlang_test ()
{
  rm -Rf $1.tmp
  touch $1.tmp

  ../xlang $1.$2 > $1.tmp
  tr -d '\r' < $1.tmp > $1.out
  rm $1.tmp

  diff $1.out $1.tst > $1.diff 2> /dev/null
  ret=$?

  if [ $ret -eq 0 ]; then
    let tot_passed=tot_passed+1
    msg="Passed";
  else
    let tot_failed=tot_failed+1
    msg="Failed"
  fi

  echo $3 : $msg
}

echo ""
echo "-----------------"
echo "X/lang bench test"
echo "-----------------"
echo ""

cd ./test
xlang_test "test-01" "xc" "Comparators test"
xlang_test "test-02" "xc" "While test"
xlang_test "test-03" "xc" "Empty test"
xlang_test "test-04" "xc" "Invalid class test"
xlang_test "test-05" "xc" "Invalid file name"
xlang_test "test-06" "xx" "Invalid file name extension"
xlang_test "test-07" "xc" "Undefined variable"
xlang_test "test-08" "xc" "Array"
xlang_test "test-09" "xc" "Class test"

echo ""
echo "Summary"
echo "-------"
echo ""
echo "Total passed :      " $tot_passed
echo "Total failed :      " $tot_failed
echo ""     

