#!/bin/sh
COMMAND="scala -cp classes zweic.AnalyzerTest"
SEPARATOR="echo =========================================================================================================="
echo "
This wicked cool script will test your Zwei compiler for conformity to expected behavior.
"
file="tests/4/Factorial.zwei"
$SEPARATOR
echo "
Testing file $file. No errors should be returned.
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Class typing"
$SEPARATOR
file="tests/4/01.zwei"
echo "Testing file $file :
Error in file : undeclared superclass \"b\" (line 1)
"
$COMMAND $file
$SEPARATOR
file="tests/4/02.zwei"
echo "Testing file $file :
Error in file : class \"a\" already declared (line 3)
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Supertypes"
$SEPARATOR
file="tests/4/03.zwei"
echo "Testing file $file :
Error in file : illegal call of method \"equal\" : arguments have no common supertype (line 13)
"
$COMMAND $file
$SEPARATOR
file="tests/4/04.zwei"
echo "Testing file $file :
No error in file : arguments have common supertype
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Class typing, courtesy M. Ganguin & J. Ruffin"
$SEPARATOR
file="tests/4/class00-1.zwei"
echo "Testing file $file :
Error in file : undeclared superclass \"unknown\" (line 1)
"
$COMMAND $file
$SEPARATOR
file="tests/4/class00-2.zwei"
echo "Testing file $file :
Error in file : class \"ClassSymbolTest\" already declared (line 3)
"
$COMMAND $file
$SEPARATOR
file="tests/4/class00-3.zwei"
echo "Testing file $file :
Error in file : type \"RANDOM\" is unknown (class hasn't been declared) (line 3)
"
$COMMAND $file
$SEPARATOR
file="tests/4/class00-4.zwei"
echo "Testing file $file :
Error in file : undeclared identifier \"NONE\" (line 3)
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Field typing, courtesy M. Ganguin & J. Ruffin"
$SEPARATOR
file="tests/4/field00-1.zwei"
echo "Testing file $file :
Error in file : type \"UNKNOWN\" is unknown (line 1)
"
$COMMAND $file
$SEPARATOR
file="tests/4/field00-2.zwei"
echo "Testing file $file :
Recursive typing in classes (no error should be returned)
"
$COMMAND $file
$SEPARATOR
file="tests/4/field00-3.zwei"
echo "Testing file $file :
Error in file : field \"a\" already declared (line 3)
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Method typing, courtesy M. Ganguin & J. Ruffin"
$SEPARATOR
file="tests/4/method00-1.zwei"
echo "Testing file $file :
Error in file : return type \"UNKNOWN\" is unknown (line 4)
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-2.zwei"
echo "Testing file $file :
Error in file : argument type \"UNKNOWN\" is unknown (line 2)
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-3.zwei"
echo "Testing file $file :
Error in file : Overriding method \"overrideTest\" in class \"MethodTest\" has bad return type. (line 14)
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-4.zwei"
echo "Testing file $file :
Error in file : Overriding method \"overrideTest\" in class \"MethodTest\" has bad argument type. (line 11)
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-5.zwei"
echo "Testing file $file :
Error in file : Method \"returnExpressionTypeTest\" does not return correct type. (line 8)
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-6.zwei"
echo "Testing file $file :
Should return no errors : returning container class
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-7.zwei"
echo "Testing file $file :
Should return no errors : overriding and polymorphism
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-8.zwei"
echo "Testing file $file :
Should return no errors : testing variable scope
"
$COMMAND $file
$SEPARATOR
file="tests/4/method00-9.zwei"
echo "Testing file $file :
Should return no errors : checking method return types
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Program typing, courtesy M. Ganguin & J. Ruffin"
$SEPARATOR
file="tests/4/program00-1.zwei"
echo "Testing file $file :
Error in file : type \"RANDOM\" is unknown (line 1)
"
$COMMAND $file
$SEPARATOR
file="tests/4/program00-2.zwei"
echo "Testing file $file :
Error in file : undeclared identifier \"k\" (line 3)
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Statement typing, courtesy M. Ganguin & J. Ruffin"
$SEPARATOR
file="tests/4/statement-while.zwei"
echo "Testing file $file :
Errors in file : * type mismatch (expected : Int, found : null) in condition (line 6)
* type mismatch (expected : Int, found : null) in statement (line 7)
"
$COMMAND $file
$SEPARATOR
file="tests/4/statement-var.zwei"
echo "Testing file $file :
Errors in file : * type \"nonexistent\" is unknown (line 8)
* undeclared class \"nonexistent\" (line 8)
* type mismatch (expected : Int, found : null) for return type (line 10)
* type mismatch (expected : Int, found : null) for return type (line 11)
"
$COMMAND $file
$SEPARATOR
file="tests/4/statement-set.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"s\" (line 10)
* type mismatch (expected : Int, found : foo) (line 11)
* type mismatch (expected : bar, found : foo) (line 12)
"
$COMMAND $file
$SEPARATOR
file="tests/4/statement-do.zwei"
echo "Testing file $file :
Errors in file : * type mismatch (expected : Int, found : null) (line 5)
"
$COMMAND $file
$SEPARATOR
file="tests/4/statement-printInt.zwei"
echo "Testing file $file :
Errors in file : * type mismatch (expected : Int, found : foo) (line 7)
"
$COMMAND $file
$SEPARATOR
file="tests/4/statement-printChar.zwei"
echo "Testing file $file :
Errors in file : * type mismatch (expected : Int, found : foo) (line 7)
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Term typing, courtesy M. Ganguin & J. Ruffin"
$SEPARATOR
file="tests/4/term-ident.zwei"
echo "Testing file $file :
Error in file : undeclared identifier \"y\" (line 6)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-select.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"k\" (line 16)
* undeclared field \"x\" in class \"foo\" (line 18)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-call.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"k\" (line 20)
* undeclared method \"gneuh\" in class \"foo\" (line 21)
* illegal call of method \"works\" (wrong number of arguments) (line 22)
* illegal call of method \"works\" (argument types do not match) (line 23)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-new.zwei"
echo "Testing file $file :
Errors in file : * undeclared class \"unknown\" (line 17)
* illegal use of class constructor (wrong number of arguments) (line 18)
* illegal use of class constructor (argument types do not match) (line 19)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-unop.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"y\" (line 6)
* type mismatch (unop can only be applied to Int) (line 7)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-binop.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"k\" (line 7)
* undeclared identifier \"l\" (line 8)
* type mismatch (binop can only be applied to two Ints) (line 9)
* type mismatch (binop can only be applied to two Ints) (line 10)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-objComp.zwei"
echo "Testing file $file :
Errors in file : * two type mismatches (neither oprêrand is an Int) (line 18)
* undeclared identifier \"k\" (line 19)
* undeclared identifier \"l\" (line 20)
* type mismatch (expected : foo, found : bar) (line 21)
* type mismatch (expected : bar, found : foo) (line 22)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-if.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"k\" (line 21)
* condition in \"if\" is not an Int (line 22)
* unknown type \"gorh\" (line 23)
* unknown type \"gorh\" (line 24)
* return value types in \"if ... else\" bock do not have a common supertype (lines 24, 25, 26)
* type mismatch in \"if\" block (expected : bof, found : bar) (line 27)
"
$COMMAND $file
$SEPARATOR
file="tests/4/term-block.zwei"
echo "Testing file $file :
Errors in file : * type mismatch (expected return type : Int, found : null) (line 24)
* undeclared identifier \"y\" (outside of block scope) (line 29)
"
$COMMAND $file
$SEPARATOR
####################################################################################
$SEPARATOR
echo "Various test files, courtesy R. Tagliani"
$SEPARATOR
file="tests/4/bionInt.zwei"
echo "Testing file $file :
No errors in file
"
$COMMAND $file
$SEPARATOR
file="tests/4/blockvar.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/classes.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/classes0.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/expr_if.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/expr_readChar.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/expr_readInt.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/functions.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/new.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/null.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/printChar.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/printInt.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/select.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/unop.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/unopa.zwei"
echo "Testing file $file :
No errors in file
"
file="tests/4/blockvar_2xerror0.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"y\" (line 3)
* undeclared identifier \"z\" (line 4)
"
$COMMAND $file
$SEPARATOR
file="tests/4/blockvar_error0.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"z\" (line 3)
"
$COMMAND $file
$SEPARATOR
file="tests/4/blockvar_error1.zwei"
echo "Testing file $file :
Errors in file : * variable \"x\" already declared (line 3)
"
$COMMAND $file
$SEPARATOR
file="tests/4/classes_error0.zwei"
echo "Testing file $file :
Errors in file : * class \"C1\" already declared (line 2)
"
$COMMAND $file
$SEPARATOR
file="tests/4/classes_error1.zwei"
echo "Testing file $file :
Errors in file : * undeclared superclass \"C1\" (line 2)
"
$COMMAND $file
$SEPARATOR
file="tests/4/classes_error2.zwei"
echo "Testing file $file :
Errors in file : * field \"a\" already declared (line 3)
"
$COMMAND $file
$SEPARATOR
file="tests/4/functions_error0.zwei"
echo "Testing file $file :
Errors in file : * method \"f1\" does not return correct type (line 2)
"
$COMMAND $file
$SEPARATOR
file="tests/4/functions_error1.zwei"
echo "Testing file $file :
Errors in file : * method \"f2\" does not return correct type (line 3)
"
$COMMAND $file
$SEPARATOR
file="tests/4/new_error0.zwei"
echo "Testing file $file :
Errors in file : * illegal use of class constructor : argument types do not match (line 6)
"
$COMMAND $file
$SEPARATOR
file="tests/4/new_error0.zwei"
echo "Testing file $file :
Errors in file : * illegal use of class constructor : wrong number of parameters (line 6)
"
$COMMAND $file
$SEPARATOR
file="tests/4/printChar_error0.zwei"
echo "Testing file $file :
Errors in file : * program starts with block (line 0)
"
$COMMAND $file
$SEPARATOR
file="tests/4/unopa_error1.zwei"
echo "Testing file $file :
Errors in file : * undeclared identifier \"b\" (line 3)
"
$COMMAND $file
$SEPARATOR