#!/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="Factorial.zwei" $SEPARATOR echo " Testing file $file. No errors should be returned. " $COMMAND $file $SEPARATOR #################################################################################### $SEPARATOR echo "Class typing" $SEPARATOR file="01.zwei" echo "Testing file $file : Error in file : undeclared superclass \"b\" (line 1) " $COMMAND $file $SEPARATOR file="02.zwei" echo "Testing file $file : Error in file : class \"a\" already declared (line 3) " $COMMAND $file $SEPARATOR #################################################################################### $SEPARATOR echo "Supertypes" $SEPARATOR file="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="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="class00-1.zwei" echo "Testing file $file : Error in file : undeclared superclass \"unknown\" (line 1) " $COMMAND $file $SEPARATOR file="class00-2.zwei" echo "Testing file $file : Error in file : class \"ClassSymbolTest\" already declared (line 3) " $COMMAND $file $SEPARATOR file="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="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="field00-1.zwei" echo "Testing file $file : Error in file : type \"UNKNOWN\" is unknown (line 1) " $COMMAND $file $SEPARATOR file="field00-2.zwei" echo "Testing file $file : Recursive typing in classes (no error should be returned) " $COMMAND $file $SEPARATOR file="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="method00-1.zwei" echo "Testing file $file : Error in file : return type \"UNKNOWN\" is unknown (line 4) " $COMMAND $file $SEPARATOR file="method00-2.zwei" echo "Testing file $file : Error in file : argument type \"UNKNOWN\" is unknown (line 2) " $COMMAND $file $SEPARATOR file="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="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="method00-5.zwei" echo "Testing file $file : Error in file : Method \"returnExpressionTypeTest\" does not return correct type. (line 8) " $COMMAND $file $SEPARATOR file="method00-6.zwei" echo "Testing file $file : Should return no errors : returning container class " $COMMAND $file $SEPARATOR file="method00-7.zwei" echo "Testing file $file : Should return no errors : overriding and polymorphism " $COMMAND $file $SEPARATOR file="method00-8.zwei" echo "Testing file $file : Should return no errors : testing variable scope " $COMMAND $file $SEPARATOR file="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="program00-1.zwei" echo "Testing file $file : Error in file : type \"RANDOM\" is unknown (line 1) " $COMMAND $file $SEPARATOR file="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="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="statement-var.zwei" echo "Testing file $file : Errors in file : * type \"nonexistent\" is unknown (line 8) * undeclared class \"nonexistent\" (line 8) * type mismatch (expected : baz, found : foo) for return type (line 9) * type mismatch (expected : bar, found : foo) for return type (line 10) * variable \"n\" already declared (line 11) " $COMMAND $file $SEPARATOR file="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="statement-do.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected : Int, found : null) (line 5) " $COMMAND $file $SEPARATOR file="statement-printInt.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected : Int, found : foo) (line 7) " $COMMAND $file $SEPARATOR file="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="term-ident.zwei" echo "Testing file $file : Error in file : undeclared identifier \"y\" (line 6) " $COMMAND $file $SEPARATOR file="term-select.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"k\" (line 12) * undeclared field \"x\" in class \"foo\" (line 14) " $COMMAND $file $SEPARATOR file="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="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="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="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="term-objComp.zwei" echo "Testing file $file : Errors in file : * two type mismatches (neither operand 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="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="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="bionInt.zwei" echo "Testing file $file : No errors in file " $COMMAND $file $SEPARATOR file="blockvar.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="classes.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="classes0.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="expr_if.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="expr_readChar.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="expr_readInt.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="functions.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="new.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="null.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="printChar.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="printInt.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="select.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="unop.zwei" echo "Testing file $file : No errors in file " $COMMAND $file file="unopa.zwei" echo "Testing file $file : No errors in file " $COMMAND $file $SEPARATOR file="blockvar_2xerror0.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"y\" (line 3) * undeclared identifier \"z\" (line 4) " $COMMAND $file $SEPARATOR file="blockvar_error0.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"z\" (line 3) " $COMMAND $file $SEPARATOR file="blockvar_error1.zwei" echo "Testing file $file : Errors in file : * variable \"x\" already declared (line 3) " $COMMAND $file $SEPARATOR file="classes_error0.zwei" echo "Testing file $file : Errors in file : * class \"C1\" already declared (line 2) " $COMMAND $file $SEPARATOR file="classes_error1.zwei" echo "Testing file $file : Errors in file : * undeclared superclass \"C3\" (line 2) " $COMMAND $file $SEPARATOR file="classes_error2.zwei" echo "Testing file $file : Errors in file : * field \"a\" already declared (line 3) " $COMMAND $file $SEPARATOR file="functions_error0.zwei" echo "Testing file $file : Errors in file : * method \"f1\" does not return correct type (line 2) " $COMMAND $file $SEPARATOR file="functions_error1.zwei" echo "Testing file $file : Errors in file : * method \"f2\" does not return correct type (line 3) " $COMMAND $file $SEPARATOR file="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="new_error1.zwei" echo "Testing file $file : Errors in file : * illegal use of class constructor : wrong number of parameters (line 6) " $COMMAND $file $SEPARATOR file="printChar_error0.zwei" echo "Testing file $file : Errors in file : * program starts with block (line 0) " $COMMAND $file $SEPARATOR file="unopa_error1.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"b\" (line 3) " $COMMAND $file $SEPARATOR