diff --git a/script.sh b/script.sh index e3fd1df..37c4d8d 100755 --- a/script.sh +++ b/script.sh @@ -8,7 +8,7 @@ This wicked cool script will test your Zwei compiler for conformity to expected behavior. " -file="tests/4/Factorial.zwei" +file="tests/four/Factorial.zwei" $SEPARATOR echo " @@ -25,7 +25,7 @@ echo "Class typing" $SEPARATOR -file="tests/4/01.zwei" +file="tests/four/01.zwei" echo "Testing file $file : Error in file : undeclared superclass \"b\" (line 1) @@ -35,7 +35,7 @@ $SEPARATOR -file="tests/4/02.zwei" +file="tests/four/02.zwei" echo "Testing file $file : Error in file : class \"a\" already declared (line 3) @@ -51,7 +51,7 @@ echo "Supertypes" $SEPARATOR -file="tests/4/03.zwei" +file="tests/four/03.zwei" echo "Testing file $file : Error in file : illegal call of method \"equal\" : arguments have no common supertype (line 13) @@ -61,7 +61,7 @@ $SEPARATOR -file="tests/4/04.zwei" +file="tests/four/04.zwei" echo "Testing file $file : No error in file : arguments have common supertype @@ -77,7 +77,7 @@ echo "Class typing, courtesy M. Ganguin & J. Ruffin" $SEPARATOR -file="tests/4/class00-1.zwei" +file="tests/four/class00-1.zwei" echo "Testing file $file : Error in file : undeclared superclass \"unknown\" (line 1) @@ -87,7 +87,7 @@ $SEPARATOR -file="tests/4/class00-2.zwei" +file="tests/four/class00-2.zwei" echo "Testing file $file : Error in file : class \"ClassSymbolTest\" already declared (line 3) @@ -97,7 +97,7 @@ $SEPARATOR -file="tests/4/class00-3.zwei" +file="tests/four/class00-3.zwei" echo "Testing file $file : Error in file : type \"RANDOM\" is unknown (class hasn't been declared) (line 3) @@ -107,7 +107,7 @@ $SEPARATOR -file="tests/4/class00-4.zwei" +file="tests/four/class00-4.zwei" echo "Testing file $file : Error in file : undeclared identifier \"NONE\" (line 3) @@ -123,7 +123,7 @@ echo "Field typing, courtesy M. Ganguin & J. Ruffin" $SEPARATOR -file="tests/4/field00-1.zwei" +file="tests/four/field00-1.zwei" echo "Testing file $file : Error in file : type \"UNKNOWN\" is unknown (line 1) @@ -133,7 +133,7 @@ $SEPARATOR -file="tests/4/field00-2.zwei" +file="tests/four/field00-2.zwei" echo "Testing file $file : Recursive typing in classes (no error should be returned) @@ -143,7 +143,7 @@ $SEPARATOR -file="tests/4/field00-3.zwei" +file="tests/four/field00-3.zwei" echo "Testing file $file : Error in file : field \"a\" already declared (line 3) @@ -160,7 +160,7 @@ echo "Method typing, courtesy M. Ganguin & J. Ruffin" $SEPARATOR -file="tests/4/method00-1.zwei" +file="tests/four/method00-1.zwei" echo "Testing file $file : Error in file : return type \"UNKNOWN\" is unknown (line 4) @@ -170,7 +170,7 @@ $SEPARATOR -file="tests/4/method00-2.zwei" +file="tests/four/method00-2.zwei" echo "Testing file $file : Error in file : argument type \"UNKNOWN\" is unknown (line 2) @@ -180,7 +180,7 @@ $SEPARATOR -file="tests/4/method00-3.zwei" +file="tests/four/method00-3.zwei" echo "Testing file $file : Error in file : Overriding method \"overrideTest\" in class \"MethodTest\" has bad return type. (line 14) @@ -190,7 +190,7 @@ $SEPARATOR -file="tests/4/method00-4.zwei" +file="tests/four/method00-4.zwei" echo "Testing file $file : Error in file : Overriding method \"overrideTest\" in class \"MethodTest\" has bad argument type. (line 11) @@ -200,7 +200,7 @@ $SEPARATOR -file="tests/4/method00-5.zwei" +file="tests/four/method00-5.zwei" echo "Testing file $file : Error in file : Method \"returnExpressionTypeTest\" does not return correct type. (line 8) @@ -210,7 +210,7 @@ $SEPARATOR -file="tests/4/method00-6.zwei" +file="tests/four/method00-6.zwei" echo "Testing file $file : Should return no errors : returning container class @@ -220,7 +220,7 @@ $SEPARATOR -file="tests/4/method00-7.zwei" +file="tests/four/method00-7.zwei" echo "Testing file $file : Should return no errors : overriding and polymorphism @@ -230,7 +230,7 @@ $SEPARATOR -file="tests/4/method00-8.zwei" +file="tests/four/method00-8.zwei" echo "Testing file $file : Should return no errors : testing variable scope @@ -240,7 +240,7 @@ $SEPARATOR -file="tests/4/method00-9.zwei" +file="tests/four/method00-9.zwei" echo "Testing file $file : Should return no errors : checking method return types @@ -256,7 +256,7 @@ echo "Program typing, courtesy M. Ganguin & J. Ruffin" $SEPARATOR -file="tests/4/program00-1.zwei" +file="tests/four/program00-1.zwei" echo "Testing file $file : Error in file : type \"RANDOM\" is unknown (line 1) @@ -266,7 +266,7 @@ $SEPARATOR -file="tests/4/program00-2.zwei" +file="tests/four/program00-2.zwei" echo "Testing file $file : Error in file : undeclared identifier \"k\" (line 3) @@ -282,7 +282,7 @@ echo "Statement typing, courtesy M. Ganguin & J. Ruffin" $SEPARATOR -file="tests/4/statement-while.zwei" +file="tests/four/statement-while.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected : Int, found : null) in condition (line 6) @@ -293,7 +293,7 @@ $SEPARATOR -file="tests/4/statement-var.zwei" +file="tests/four/statement-var.zwei" echo "Testing file $file : Errors in file : * type \"nonexistent\" is unknown (line 8) @@ -306,7 +306,7 @@ $SEPARATOR -file="tests/4/statement-set.zwei" +file="tests/four/statement-set.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"s\" (line 10) @@ -318,7 +318,7 @@ $SEPARATOR -file="tests/4/statement-do.zwei" +file="tests/four/statement-do.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected : Int, found : null) (line 5) @@ -328,7 +328,7 @@ $SEPARATOR -file="tests/4/statement-printInt.zwei" +file="tests/four/statement-printInt.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected : Int, found : foo) (line 7) @@ -338,7 +338,7 @@ $SEPARATOR -file="tests/4/statement-printChar.zwei" +file="tests/four/statement-printChar.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected : Int, found : foo) (line 7) @@ -354,7 +354,7 @@ echo "Term typing, courtesy M. Ganguin & J. Ruffin" $SEPARATOR -file="tests/4/term-ident.zwei" +file="tests/four/term-ident.zwei" echo "Testing file $file : Error in file : undeclared identifier \"y\" (line 6) @@ -364,7 +364,7 @@ $SEPARATOR -file="tests/4/term-select.zwei" +file="tests/four/term-select.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"k\" (line 16) @@ -375,7 +375,7 @@ $SEPARATOR -file="tests/4/term-call.zwei" +file="tests/four/term-call.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"k\" (line 20) @@ -388,7 +388,7 @@ $SEPARATOR -file="tests/4/term-new.zwei" +file="tests/four/term-new.zwei" echo "Testing file $file : Errors in file : * undeclared class \"unknown\" (line 17) @@ -400,7 +400,7 @@ $SEPARATOR -file="tests/4/term-unop.zwei" +file="tests/four/term-unop.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"y\" (line 6) @@ -411,7 +411,7 @@ $SEPARATOR -file="tests/4/term-binop.zwei" +file="tests/four/term-binop.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"k\" (line 7) @@ -424,7 +424,7 @@ $SEPARATOR -file="tests/4/term-objComp.zwei" +file="tests/four/term-objComp.zwei" echo "Testing file $file : Errors in file : * two type mismatches (neither opr�rand is an Int) (line 18) @@ -438,7 +438,7 @@ $SEPARATOR -file="tests/4/term-if.zwei" +file="tests/four/term-if.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"k\" (line 21) @@ -453,7 +453,7 @@ $SEPARATOR -file="tests/4/term-block.zwei" +file="tests/four/term-block.zwei" echo "Testing file $file : Errors in file : * type mismatch (expected return type : Int, found : null) (line 24) @@ -470,7 +470,7 @@ echo "Various test files, courtesy R. Tagliani" $SEPARATOR -file="tests/4/bionInt.zwei" +file="tests/four/bionInt.zwei" echo "Testing file $file : No errors in file @@ -480,91 +480,91 @@ $SEPARATOR -file="tests/4/blockvar.zwei" +file="tests/four/blockvar.zwei" echo "Testing file $file : No errors in file " -file="tests/4/classes.zwei" +file="tests/four/classes.zwei" echo "Testing file $file : No errors in file " -file="tests/4/classes0.zwei" +file="tests/four/classes0.zwei" echo "Testing file $file : No errors in file " -file="tests/4/expr_if.zwei" +file="tests/four/expr_if.zwei" echo "Testing file $file : No errors in file " -file="tests/4/expr_readChar.zwei" +file="tests/four/expr_readChar.zwei" echo "Testing file $file : No errors in file " -file="tests/4/expr_readInt.zwei" +file="tests/four/expr_readInt.zwei" echo "Testing file $file : No errors in file " -file="tests/4/functions.zwei" +file="tests/four/functions.zwei" echo "Testing file $file : No errors in file " -file="tests/4/new.zwei" +file="tests/four/new.zwei" echo "Testing file $file : No errors in file " -file="tests/4/null.zwei" +file="tests/four/null.zwei" echo "Testing file $file : No errors in file " -file="tests/4/printChar.zwei" +file="tests/four/printChar.zwei" echo "Testing file $file : No errors in file " -file="tests/4/printInt.zwei" +file="tests/four/printInt.zwei" echo "Testing file $file : No errors in file " -file="tests/4/select.zwei" +file="tests/four/select.zwei" echo "Testing file $file : No errors in file " -file="tests/4/unop.zwei" +file="tests/four/unop.zwei" echo "Testing file $file : No errors in file " -file="tests/4/unopa.zwei" +file="tests/four/unopa.zwei" echo "Testing file $file : No errors in file " -file="tests/4/blockvar_2xerror0.zwei" +file="tests/four/blockvar_2xerror0.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"y\" (line 3) @@ -575,7 +575,7 @@ $SEPARATOR -file="tests/4/blockvar_error0.zwei" +file="tests/four/blockvar_error0.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"z\" (line 3) @@ -585,7 +585,7 @@ $SEPARATOR -file="tests/4/blockvar_error1.zwei" +file="tests/four/blockvar_error1.zwei" echo "Testing file $file : Errors in file : * variable \"x\" already declared (line 3) @@ -595,7 +595,7 @@ $SEPARATOR -file="tests/4/classes_error0.zwei" +file="tests/four/classes_error0.zwei" echo "Testing file $file : Errors in file : * class \"C1\" already declared (line 2) @@ -605,7 +605,7 @@ $SEPARATOR -file="tests/4/classes_error1.zwei" +file="tests/four/classes_error1.zwei" echo "Testing file $file : Errors in file : * undeclared superclass \"C1\" (line 2) @@ -615,7 +615,7 @@ $SEPARATOR -file="tests/4/classes_error2.zwei" +file="tests/four/classes_error2.zwei" echo "Testing file $file : Errors in file : * field \"a\" already declared (line 3) @@ -625,7 +625,7 @@ $SEPARATOR -file="tests/4/functions_error0.zwei" +file="tests/four/functions_error0.zwei" echo "Testing file $file : Errors in file : * method \"f1\" does not return correct type (line 2) @@ -635,7 +635,7 @@ $SEPARATOR -file="tests/4/functions_error1.zwei" +file="tests/four/functions_error1.zwei" echo "Testing file $file : Errors in file : * method \"f2\" does not return correct type (line 3) @@ -645,7 +645,7 @@ $SEPARATOR -file="tests/4/new_error0.zwei" +file="tests/four/new_error0.zwei" echo "Testing file $file : Errors in file : * illegal use of class constructor : argument types do not match (line 6) @@ -655,7 +655,7 @@ $SEPARATOR -file="tests/4/new_error0.zwei" +file="tests/four/new_error0.zwei" echo "Testing file $file : Errors in file : * illegal use of class constructor : wrong number of parameters (line 6) @@ -665,7 +665,7 @@ $SEPARATOR -file="tests/4/printChar_error0.zwei" +file="tests/four/printChar_error0.zwei" echo "Testing file $file : Errors in file : * program starts with block (line 0) @@ -675,7 +675,7 @@ $SEPARATOR -file="tests/4/unopa_error1.zwei" +file="tests/four/unopa_error1.zwei" echo "Testing file $file : Errors in file : * undeclared identifier \"b\" (line 3) diff --git a/tests/four/01.zwei b/tests/four/01.zwei new file mode 100755 index 0000000..e646e91 --- /dev/null +++ b/tests/four/01.zwei @@ -0,0 +1,3 @@ +class a extends b{} + +2 \ No newline at end of file diff --git a/tests/four/02.zwei b/tests/four/02.zwei new file mode 100755 index 0000000..cfb82a5 --- /dev/null +++ b/tests/four/02.zwei @@ -0,0 +1,5 @@ +class a {} + +class a {} + +2 \ No newline at end of file diff --git a/tests/four/03.zwei b/tests/four/03.zwei new file mode 100755 index 0000000..a26e2db --- /dev/null +++ b/tests/four/03.zwei @@ -0,0 +1,15 @@ +class A { + Int x; +} + +class B { + Int x; + Int equal(B that) { + return this.x == that.x + } +} + +{ + printInt(new B(1).equal(new A(2))); + printChar(10); +} diff --git a/tests/four/04.zwei b/tests/four/04.zwei new file mode 100755 index 0000000..47895f1 --- /dev/null +++ b/tests/four/04.zwei @@ -0,0 +1,18 @@ +class A { + Int x; +} + +class B { + Int x; + Int equal(B that) { + return this.x == that.x + } +} + +class C extends B{ +} + +{ + printInt(new B(1).equal(new C(2))); + printChar(10); +} diff --git a/tests/four/Factorial.zwei b/tests/four/Factorial.zwei new file mode 100755 index 0000000..6d1c0b7 --- /dev/null +++ b/tests/four/Factorial.zwei @@ -0,0 +1,43 @@ +class Factorial { + + // Recursive definition + Int factorial1(Int x) { + return if (x == 0) 1 + else x * this.factorial1(x - 1) + } + + // Tail-recursive definition + Int factorial2_aux(Int x, Int acc) { + return if (x == 0) acc + else this.factorial2_aux(x - 1, acc * x) + } + Int factorial2(Int x) { + return this.factorial2_aux(x, 1) + } + + // Iterative definition + Int factorial3(Int x) { + Int p = 1; + while (x > 0) { + p = p * x; + x = x - 1; + } + return p + } + +} + +class Example { + Null main() { + Factorial fac = new Factorial(); + Int x = 5; + printInt(fac.factorial1(x)); + printChar(10); + printInt(fac.factorial2(x)); + printChar(10); + printInt(fac.factorial3(x)); + printChar(10); + } +} + +new Example().main() diff --git a/tests/four/binopInt.zwei b/tests/four/binopInt.zwei new file mode 100755 index 0000000..0f314d2 --- /dev/null +++ b/tests/four/binopInt.zwei @@ -0,0 +1,2 @@ +3>=2 + diff --git a/tests/four/blockvar.zwei b/tests/four/blockvar.zwei new file mode 100755 index 0000000..4b5ac59 --- /dev/null +++ b/tests/four/blockvar.zwei @@ -0,0 +1,4 @@ +{ + Int x = 0; + Int y = x; +} diff --git a/tests/four/blockvar_2xerror0.zwei b/tests/four/blockvar_2xerror0.zwei new file mode 100755 index 0000000..29b53e9 --- /dev/null +++ b/tests/four/blockvar_2xerror0.zwei @@ -0,0 +1,5 @@ +{ + Int x = 0; + Int y = y; + Int n = z; +} diff --git a/tests/four/blockvar_error0.zwei b/tests/four/blockvar_error0.zwei new file mode 100755 index 0000000..d26a63e --- /dev/null +++ b/tests/four/blockvar_error0.zwei @@ -0,0 +1,4 @@ +{ + Int x = 0; + Int y = z; +} diff --git a/tests/four/blockvar_error1.zwei b/tests/four/blockvar_error1.zwei new file mode 100755 index 0000000..24d6022 --- /dev/null +++ b/tests/four/blockvar_error1.zwei @@ -0,0 +1,4 @@ +{ + Int x = 0; + Int x = 9; +} diff --git a/tests/four/class00-1.zwei b/tests/four/class00-1.zwei new file mode 100755 index 0000000..e4c61f7 --- /dev/null +++ b/tests/four/class00-1.zwei @@ -0,0 +1,3 @@ +class SuperClassTest extends unknown {} + +2 \ No newline at end of file diff --git a/tests/four/class00-2.zwei b/tests/four/class00-2.zwei new file mode 100755 index 0000000..8ad0dc6 --- /dev/null +++ b/tests/four/class00-2.zwei @@ -0,0 +1,5 @@ +class ClassSymbolTest {} + +class ClassSymbolTest {} + +2 \ No newline at end of file diff --git a/tests/four/class00-3.zwei b/tests/four/class00-3.zwei new file mode 100755 index 0000000..57bc86a --- /dev/null +++ b/tests/four/class00-3.zwei @@ -0,0 +1,7 @@ +class ClassMemberTest { + Int x; // success + RANDOM y; // 3/4 failure of clause 3 (incorrectly typed member) + Int bar() { Int a = 2; return a + 2 } // success +} + +2 \ No newline at end of file diff --git a/tests/four/class00-4.zwei b/tests/four/class00-4.zwei new file mode 100755 index 0000000..fb47ac2 --- /dev/null +++ b/tests/four/class00-4.zwei @@ -0,0 +1,7 @@ +class ClassMemberTest { + Int x; // success + Null foo() { NONE; } // 4/4 failure of clause 3 (incorrectly typed member) + Int bar() { Int a = 2; return a + 2 } // success +} + +2 \ No newline at end of file diff --git a/tests/four/class00.zwei b/tests/four/class00.zwei new file mode 100755 index 0000000..7e4cdf4 --- /dev/null +++ b/tests/four/class00.zwei @@ -0,0 +1,37 @@ +// zweic - test program for class typing +// M. Ganguin, J. Ruffin 2005 + +// Class + +// Superclass typing +class SuperClassTest extends unknown {} // 1/4 failure of clause 1 (incorrectly typed superclass) + +// Class scope typing +class ClassSymbolTest {} class ClassSymbolTest {} // 2/4 failure of clause 2 (class already defined) + +// Class member typing +class ClassMemberTest { + Int x; // success + RANDOM y; // 3/4 failure of clause 3 (incorrectly typed member) + Null foo() { NONE; } // 4/4 failure of clause 3 (incorrectly typed member) + Int bar() { Int a = 2; return a + 2 } // success +} + +// Happy Day Scenario + +class WorkingClassTest { + Int x; + Null y; + Null foo() { + 2 + 2; + } + Int bar() { + Int z = this.x + 2; + return z + } +} // success + +{ + WorkingClassTest w = new WorkingClassTest(3, null); + return w.bar() +} diff --git a/tests/four/classes.zwei b/tests/four/classes.zwei new file mode 100755 index 0000000..36d06ac --- /dev/null +++ b/tests/four/classes.zwei @@ -0,0 +1,16 @@ +class C0 +{ + Int b; +} + +class C1 +{ + Int b; + Int f1(Int a, Int b) + { + this.b; + printInt(a); + return b + } +} +null \ No newline at end of file diff --git a/tests/four/classes0.zwei b/tests/four/classes0.zwei new file mode 100755 index 0000000..d96cac7 --- /dev/null +++ b/tests/four/classes0.zwei @@ -0,0 +1,16 @@ +class C0 +{ + Int b; +} + +class C1 extends C0 +{ + Int f1(Int a, Int b) + { + Int y = 0; + this.b; + printInt(a); + return y + } +} +null \ No newline at end of file diff --git a/tests/four/classes_error0.zwei b/tests/four/classes_error0.zwei new file mode 100755 index 0000000..6ae6c52 --- /dev/null +++ b/tests/four/classes_error0.zwei @@ -0,0 +1,4 @@ +class C1 {} +class C1 {} +null + diff --git a/tests/four/classes_error1.zwei b/tests/four/classes_error1.zwei new file mode 100755 index 0000000..a4ccf0e --- /dev/null +++ b/tests/four/classes_error1.zwei @@ -0,0 +1,3 @@ +class C1 {} +class C2 extends C3 {} +null \ No newline at end of file diff --git a/tests/four/classes_error2.zwei b/tests/four/classes_error2.zwei new file mode 100755 index 0000000..0e36668 --- /dev/null +++ b/tests/four/classes_error2.zwei @@ -0,0 +1,5 @@ +class C1 { + Int a; + Null a; +} +null \ No newline at end of file diff --git a/tests/four/expr_if.zwei b/tests/four/expr_if.zwei new file mode 100755 index 0000000..c3293d7 --- /dev/null +++ b/tests/four/expr_if.zwei @@ -0,0 +1,22 @@ +class List { + Int isEmpty() { return this.isEmpty() } + Int head() { return this.head() } + List tail() { return this.tail() } + List cons(Int x) { return this.cons(x) } +} + +class Cons extends List { + Int head; + List tail; + Int isEmpty() { return false } + Int head() { return this.head } + List tail() { return this.tail } + List cons(Int x) { return new Cons(x, this) } +} + +class Nil extends List { + Int isEmpty() { return true } + List cons(Int x) { return new Cons(x, this) } +} + +if(3==2)"e1"else"e2" diff --git a/tests/four/expr_readChar.zwei b/tests/four/expr_readChar.zwei new file mode 100755 index 0000000..4fe4f78 --- /dev/null +++ b/tests/four/expr_readChar.zwei @@ -0,0 +1 @@ +readChar diff --git a/tests/four/expr_readInt.zwei b/tests/four/expr_readInt.zwei new file mode 100755 index 0000000..3e29b45 --- /dev/null +++ b/tests/four/expr_readInt.zwei @@ -0,0 +1 @@ +readInt diff --git a/tests/four/field00-1.zwei b/tests/four/field00-1.zwei new file mode 100755 index 0000000..198605d --- /dev/null +++ b/tests/four/field00-1.zwei @@ -0,0 +1,3 @@ +class C { UNKNOWN a; } // 1/2 failure of clause 1 (incorrect field type) + +2 \ No newline at end of file diff --git a/tests/four/field00-2.zwei b/tests/four/field00-2.zwei new file mode 100755 index 0000000..21a9b17 --- /dev/null +++ b/tests/four/field00-2.zwei @@ -0,0 +1,3 @@ +class B { B b; } // success of clause 2 (recursive class definition) + +2 \ No newline at end of file diff --git a/tests/four/field00-3.zwei b/tests/four/field00-3.zwei new file mode 100755 index 0000000..85b8a3a --- /dev/null +++ b/tests/four/field00-3.zwei @@ -0,0 +1,9 @@ +class foo { + Int a; // success + Null a; // 2/2 failure of clause 3 (field already defined) +} + +{ + foo f = new foo(1); + f.a; // success of clause 4 (class with new field is in scope) +} \ No newline at end of file diff --git a/tests/four/field00.zwei b/tests/four/field00.zwei new file mode 100755 index 0000000..3978f23 --- /dev/null +++ b/tests/four/field00.zwei @@ -0,0 +1,21 @@ +// zweic - test program for field typing +// M. Ganguin, J. Ruffin 2005 + +// Field + +// Containing class typing + +class C { UNKNOWN a; } // 1/2 failure of clause 1 (incorrect field type) +class B { B b; } // success of clause 2 (recursive class definition) + +// field name check + +class foo { + Int a; // success + Null a; // 2/2 failure of clause 3 (field already defined) +} + +{ + foo f = new foo(1); + f.a; // success of clause 4 (class with new field is in scope) +} diff --git a/tests/four/functions_error0.zwei b/tests/four/functions_error0.zwei new file mode 100755 index 0000000..ff0049b --- /dev/null +++ b/tests/four/functions_error0.zwei @@ -0,0 +1,5 @@ +class C1 { + Int f1(){} + Int f1(){} +} +null \ No newline at end of file diff --git a/tests/four/functions_error1.zwei b/tests/four/functions_error1.zwei new file mode 100755 index 0000000..7bc19b0 --- /dev/null +++ b/tests/four/functions_error1.zwei @@ -0,0 +1,5 @@ +class C1 { + Null f1(){} + Int f2(){} +} +null \ No newline at end of file diff --git a/tests/four/method00-1.zwei b/tests/four/method00-1.zwei new file mode 100755 index 0000000..c40f734 --- /dev/null +++ b/tests/four/method00-1.zwei @@ -0,0 +1,7 @@ +// Method + +class MethodTest { + UNKNOWN foo() {} // 1/5 failure of clause 1 (incorrectly typed return type) +} + +2 \ No newline at end of file diff --git a/tests/four/method00-2.zwei b/tests/four/method00-2.zwei new file mode 100755 index 0000000..3bc12a5 --- /dev/null +++ b/tests/four/method00-2.zwei @@ -0,0 +1,5 @@ +class MethodTest { + Null bar(Int a, Null b, UNKNOWN c) {} // 2/5 failure of clause 1 (incorrectly typed arguments) +} + +2 \ No newline at end of file diff --git a/tests/four/method00-3.zwei b/tests/four/method00-3.zwei new file mode 100755 index 0000000..a62d908 --- /dev/null +++ b/tests/four/method00-3.zwei @@ -0,0 +1,19 @@ +// zweic - test program for method typing +// M. Ganguin, J. Ruffin 2005 + +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + + bar overrideTest(bar a, bar b) { return new bar() } // success of clause 3 + + foo overrideTest(bar a, bar b) { // 3/5 failure of clauses 3 and 4 (return type not subtype of bar) + return new bar() + } +} + +0 diff --git a/tests/four/method00-4.zwei b/tests/four/method00-4.zwei new file mode 100755 index 0000000..541eb1a --- /dev/null +++ b/tests/four/method00-4.zwei @@ -0,0 +1,17 @@ +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + + bar overrideTest(bar a, bar b) { return new bar() } // success of clause 3 + + bar overrideTest(baz a, bar b) { // 4/5 failure of clauses 3 and 4 (parameter type not supertype of bar) + return new bar() + } + +} + +0 \ No newline at end of file diff --git a/tests/four/method00-5.zwei b/tests/four/method00-5.zwei new file mode 100755 index 0000000..66e0c52 --- /dev/null +++ b/tests/four/method00-5.zwei @@ -0,0 +1,12 @@ +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + bar returnExpressionTypeTest() { return new foo() } // 5/5 failure of clause 7 (expression type not subtype of declared return type) + +} + +0 \ No newline at end of file diff --git a/tests/four/method00-6.zwei b/tests/four/method00-6.zwei new file mode 100755 index 0000000..6f9b378 --- /dev/null +++ b/tests/four/method00-6.zwei @@ -0,0 +1,9 @@ +// Method + +class MethodTest { + MethodTest classReturnTest() { // success of clause 2 (containing class as return type) + return this + } +} + +0 diff --git a/tests/four/method00-7.zwei b/tests/four/method00-7.zwei new file mode 100755 index 0000000..f912336 --- /dev/null +++ b/tests/four/method00-7.zwei @@ -0,0 +1,20 @@ +// zweic - test program for method typing +// M. Ganguin, J. Ruffin 2005 + +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + + bar overrideTest(bar a, bar b) { return new bar() } // success of clause 3 + + baz overrideTest(foo a, foo b) { // successful override + return new baz() // success (polymorphism) + } + +} + +0 diff --git a/tests/four/method00-8.zwei b/tests/four/method00-8.zwei new file mode 100755 index 0000000..8386d72 --- /dev/null +++ b/tests/four/method00-8.zwei @@ -0,0 +1,18 @@ +// zweic - test program for method typing +// M. Ganguin, J. Ruffin 2005 + +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + Null varScopeTest(Int a, foo f) { + Int b = a; // success of clause 6 (parameter in variable scope) + foo g = f; // success of clause 6 (parameter in variable scope) + MethodTest m = this; // success of clause 6 (this in variable scope) + } +} + +0 diff --git a/tests/four/method00-9.zwei b/tests/four/method00-9.zwei new file mode 100755 index 0000000..9df4a27 --- /dev/null +++ b/tests/four/method00-9.zwei @@ -0,0 +1,15 @@ +// zweic - test program for method typing +// M. Ganguin, J. Ruffin 2005 + +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + bar returnExpressionTypeTest2() { return new baz() } // success of clause 7 + +} + +0 diff --git a/tests/four/method00.zwei b/tests/four/method00.zwei new file mode 100755 index 0000000..d637cea --- /dev/null +++ b/tests/four/method00.zwei @@ -0,0 +1,45 @@ +// zweic - test program for method typing +// M. Ganguin, J. Ruffin 2005 + +class foo {} +class bar extends foo {} +class baz extends bar {} + +// Method + +class MethodTest { + UNKNOWN foo() {} // 1/5 failure of clause 1 (incorrectly typed return type) + + Null bar(Int a, Null b, UNKNOWN c) {} // 2/5 failure of clause 1 (incorrectly typed arguments) + + MethodTest classReturnTest() { // success of clause 2 (containing class as return type) + return this + } + + bar overrideTest(bar a, bar b) { return new bar() } // success of clause 3 + + foo overrideTest(bar a, bar b) { // 3/5 failure of clauses 3 and 4 (return type not subtype of bar) + return new bar() + } + + bar overrideTest(baz a, bar b) { // 4/5 failure of clauses 3 and 4 (parameter type not supertype of bar) + return new bar() + } + + baz overrideTest(foo a, foo b) { // successful override + return new baz() // success (polymorphism) + } + + Null varScopeTest(Int a, foo f) { + Int b = a; // success of clause 6 (parameter in variable scope) + foo g = f; // success of clause 6 (parameter in variable scope) + MethodTest m = this; // success of clause 6 (this in variable scope) + } + + bar returnExpressionTypeTest() { return new foo() } // 5/5 failure of clause 7 (expression type not subtype of declared return type) + + bar returnExpressionTypeTest2() { return new baz() } // success of clause 7 + +} + +0 diff --git a/tests/four/new.zwei b/tests/four/new.zwei new file mode 100755 index 0000000..8acf2b4 --- /dev/null +++ b/tests/four/new.zwei @@ -0,0 +1,6 @@ +class c1 { +Int a; +Int b; +Null g; +} +new c1(7, 2, null) diff --git a/tests/four/new_error0.zwei b/tests/four/new_error0.zwei new file mode 100755 index 0000000..ae585ee --- /dev/null +++ b/tests/four/new_error0.zwei @@ -0,0 +1,6 @@ +class c1 { +Int a; +Int b; +Null g; +} +new c1(null, 7, 8) diff --git a/tests/four/new_error1.zwei b/tests/four/new_error1.zwei new file mode 100755 index 0000000..9684d02 --- /dev/null +++ b/tests/four/new_error1.zwei @@ -0,0 +1,6 @@ +class c1 { +Int a; +Int b; +Null g; +} +new c1(7, null) diff --git a/tests/four/null.zwei b/tests/four/null.zwei new file mode 100755 index 0000000..d234dd4 --- /dev/null +++ b/tests/four/null.zwei @@ -0,0 +1,4 @@ +class C1 { + Null a; +} +null \ No newline at end of file diff --git a/tests/four/printChar.zwei b/tests/four/printChar.zwei new file mode 100755 index 0000000..8db60f0 --- /dev/null +++ b/tests/four/printChar.zwei @@ -0,0 +1,3 @@ +{ + printChar(readInt); +} \ No newline at end of file diff --git a/tests/four/printChar_error0.zwei b/tests/four/printChar_error0.zwei new file mode 100755 index 0000000..ff56775 --- /dev/null +++ b/tests/four/printChar_error0.zwei @@ -0,0 +1,3 @@ +{ + printChar("str1"); +} \ No newline at end of file diff --git a/tests/four/printInt.zwei b/tests/four/printInt.zwei new file mode 100755 index 0000000..a3058a8 --- /dev/null +++ b/tests/four/printInt.zwei @@ -0,0 +1,3 @@ +{ + printInt(2); +} \ No newline at end of file diff --git a/tests/four/program00-1.zwei b/tests/four/program00-1.zwei new file mode 100755 index 0000000..f53d1eb --- /dev/null +++ b/tests/four/program00-1.zwei @@ -0,0 +1,3 @@ +class foo { RANDOM k; } + +1 \ No newline at end of file diff --git a/tests/four/program00-2.zwei b/tests/four/program00-2.zwei new file mode 100755 index 0000000..2a037ef --- /dev/null +++ b/tests/four/program00-2.zwei @@ -0,0 +1,3 @@ +class foo { Int k; } + +k // 2/2 failure of clause 2 (incorrectly typed expression) diff --git a/tests/four/program00.zwei b/tests/four/program00.zwei new file mode 100755 index 0000000..0c4733d --- /dev/null +++ b/tests/four/program00.zwei @@ -0,0 +1,6 @@ +// zweic - test program for... program testing +// M. Ganguin, J. Ruffin 2005 + +class foo { RANDOM k; } // 1/2 failure of clause 1 (incorrect classes) + +k // 2/2 failure of clause 2 (incorrectly typed expression) diff --git a/tests/four/select.zwei b/tests/four/select.zwei new file mode 100755 index 0000000..243038f --- /dev/null +++ b/tests/four/select.zwei @@ -0,0 +1,6 @@ +class c1 { +Int a; +Int b; +Null g; +} +new c1(5, 7, null).a diff --git a/tests/four/statement-do.zwei b/tests/four/statement-do.zwei new file mode 100755 index 0000000..a535f38 --- /dev/null +++ b/tests/four/statement-do.zwei @@ -0,0 +1,10 @@ +// Do +class DoTest { + Null foo() { + Null k = null; + 2 + k; // 1/1 failure of clause 1 (incorrectly typed expression) + 2 + 2; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/statement-printChar.zwei b/tests/four/statement-printChar.zwei new file mode 100755 index 0000000..f55b033 --- /dev/null +++ b/tests/four/statement-printChar.zwei @@ -0,0 +1,12 @@ +// PrintChar + +class foo{} + +class PrintCharTest { + Null foo() { + printChar(new foo()); // 1/1 failure of clause 1 (type must be Int) + printChar(2); //success + } +} + +0 \ No newline at end of file diff --git a/tests/four/statement-printInt.zwei b/tests/four/statement-printInt.zwei new file mode 100755 index 0000000..3a345f7 --- /dev/null +++ b/tests/four/statement-printInt.zwei @@ -0,0 +1,12 @@ +// PrintInt + +class foo {} + +class PrintIntTest { + Null foo() { + printInt(new foo()); // 1/1 failure of clause 1 (type must be Int) + printInt(2); //success + } +} + +1 \ No newline at end of file diff --git a/tests/four/statement-set.zwei b/tests/four/statement-set.zwei new file mode 100755 index 0000000..0ee42db --- /dev/null +++ b/tests/four/statement-set.zwei @@ -0,0 +1,17 @@ +class foo {} +class bar extends foo {} +class baz {} + +// Set +class SetTest { + Null foo() { + Int n = 1; + bar b = new bar(); + s = 2; // 1/3 failure of clause 1 (nonexistent variable) + n = new foo(); // 2/3 failure of clauses 2 and 3 (subtype mismatch) + b = new foo(); // 3/3 failure of clauses 2 and 3 (inverted sub- and supertypes) + b = new bar(); // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/statement-var.zwei b/tests/four/statement-var.zwei new file mode 100755 index 0000000..9323e6a --- /dev/null +++ b/tests/four/statement-var.zwei @@ -0,0 +1,16 @@ +// Var +class foo {} +class bar extends foo {} +class baz {} +class VarTest { + Null foo() { + Int n = 1; + nonexistent ne = new nonexistent(); // 1/4 failure of clause 1 (nonexistent type) + baz b = new foo(); // 2/4 failure of clause 2 (subtype mismatch) + bar f = new foo(); // 3/4 failure of clause 2 (inverted sub- and supertypes) + Int n = 2; // 4/4 failure of clause 3 (variable n already exists) + Int z = 3; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/statement-while.zwei b/tests/four/statement-while.zwei new file mode 100755 index 0000000..42b1970 --- /dev/null +++ b/tests/four/statement-while.zwei @@ -0,0 +1,12 @@ +// While +class WhileTest { + Null foo() { + Int t = 0; + Null n = null; + while(n) {} // 1/2 failure of clause 1 (condition type not Int) + while(t) { Int s = null; } // 2/2 failure of clause 2 (incorrectly typed statement) + while(t) { Int s = 0; } // correct + } +} + +1 \ No newline at end of file diff --git a/tests/four/statement00.zwei b/tests/four/statement00.zwei new file mode 100755 index 0000000..4db29a1 --- /dev/null +++ b/tests/four/statement00.zwei @@ -0,0 +1,67 @@ +// zweic - test program for statement testing +// M. Ganguin, J. Ruffin 2005 + +// While +class WhileTest { + Null foo() { + Int t = 0; + Null n = null; + while(n) {} // 1/2 failure of clause 1 (condition type not Int) + while(t) { Int s = null; } // 2/2 failure of clause 2 (incorrectly typed statement) + while(t) { Int s = 0; } // correct + } +} + +// Var +class foo {} +class bar extends foo {} +class baz {} +class VarTest { + Null foo() { + Int n = 1; + nonexistent ne = new nonexistent(); // 1/4 failure of clause 1 (nonexistent type) + baz b = new foo(); // 2/4 failure of clause 2 (subtype mismatch) + bar f = new foo(); // 3/4 failure of clause 2 (inverted sub- and supertypes) + Int n = 2; // 4/4 failure of clause 3 (variable n already exists) + Int z = 3; // success + } +} + +// Set +class SetTest { + Null foo() { + Int n = 1; + bar b = new bar(); + s = 2; // 1/3 failure of clause 1 (nonexistent variable) + n = new foo(); // 2/3 failure of clauses 2 and 3 (subtype mismatch) + b = new foo(); // 3/3 failure of clauses 2 and 3 (inverted sub- and supertypes) + b = new bar(); // success + } +} + +// Do +class DoTest { + Null foo() { + Null k = null; + 2 + k; // 1/1 failure of clause 1 (incorrectly typed expression) + 2 + 2; // success + } +} + +// PrintInt +class PrintIntTest { + Null foo() { + printInt(new foo()); // 1/1 failure of clause 1 (type must be Int) + printInt(2); //success + } +} + +// PrintChar +class PrintCharTest { + Null foo() { + printChar(new foo()); // 1/1 failure of clause 1 (type must be Int) + printChar(2); //success + } +} + +0 diff --git a/tests/four/term-binop.zwei b/tests/four/term-binop.zwei new file mode 100755 index 0000000..3549c41 --- /dev/null +++ b/tests/four/term-binop.zwei @@ -0,0 +1,15 @@ +// Binop +class BinOpTest { + Null foo() { + Int x1 = 2; + Int x2 = 3; + Null z = null; + k + x2; // 1/4 failure of clause 1 (nonexistent ident) + x1 + l; // 2/4 failure of clause 2 (nonexistent ident) + z + x2; // 3/4 failure of clause 1 (type of ident not Int) + x1 + z; // 4/4 failure of clause 2 (type of ident not Int) + x1 + x2; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-block.zwei b/tests/four/term-block.zwei new file mode 100755 index 0000000..bf35a65 --- /dev/null +++ b/tests/four/term-block.zwei @@ -0,0 +1,38 @@ +// Block + +// Select +class bar { + Int h; +} + +class bof extends bar {} + +class IfTest { + Null foo() { + Int t = 0; + + bar b = new bar(2); + bar z = new bof(3); + + bar y = if (t) b else z; // 7/7 failure of clause 3 (return type mismatch) + } +} + +class BlockTest { + Null foo() { + { + Int x = null; // 1/2 failure of clause 1 (incorrectly typed statement in block) + return x + }; + { + Int x = 2; + return y // 2/2 failure of clause 2 (expression not in block scope) + }; + { + Int x = 2; + return x // success + }; + } +} + +0 \ No newline at end of file diff --git a/tests/four/term-call.zwei b/tests/four/term-call.zwei new file mode 100755 index 0000000..b1697d7 --- /dev/null +++ b/tests/four/term-call.zwei @@ -0,0 +1,28 @@ +// Call + +class foo { + Int y; +} + +class bar { + Int h; +} + +class bof extends bar {} + +class baz { + Int x; + Null works(Int a, bar c) {} + Null foo() { + bof b = new bof(1); + foo h = new foo(1); + baz z = new baz(1); + k.foo(); // 1/4 failure of clauses 1 and 2 (nonexistent ident) + h.gneuh(); // 2/4 failure of clause 3 (nonexistent method) + z.works(1); // 3/4 failure of clause 3 (wrong number of arguments) + z.works(1, h); // 4/4 failure of clause 4 (parameter not subtype of bof) + z.works(2, b); // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-ident.zwei b/tests/four/term-ident.zwei new file mode 100755 index 0000000..c368639 --- /dev/null +++ b/tests/four/term-ident.zwei @@ -0,0 +1,11 @@ +// Ident +class foo { + Int y; + Null bar() { + Int x = 0; + y; // 1/1 failure of clause 1 + x; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-if.zwei b/tests/four/term-if.zwei new file mode 100755 index 0000000..20356e7 --- /dev/null +++ b/tests/four/term-if.zwei @@ -0,0 +1,33 @@ +// If + +class foo { + Int y; +} + +class bar { + Int h; +} + +class bof extends bar {} + +class IfTest { + Null foo() { + Int t = 0; + Null n = null; + + bar b = new bar(2); + bof z = new bof(3); + + if(k) {} else {}; // 1/7 failure of clause 1 (nonexistent condition) + if(n) {} else {}; // 2/7 failure of clause 1 (condition not Int) + if(t) {gorh g = null;return g} else 2; // 3/7 failure of clause 2 (unknown type) + if(t) 2 else {gorh g = null;return g }; // 4/7 failure of clause 2 (unknown type) + if(t) {foo f = new foo(1);return f} else 2; // 5/7 failure of clause 3 (LUB not found) + if(t) 2 else {foo f = new foo(2);return f}; // 6/7 failure of clause 3 (LUB not found) + bof y = if (t) b else z; // 7/7 failure of clause 3 (return type mismatch) + if(t) 2 else 3; // success + if(t) b else z; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-new.zwei b/tests/four/term-new.zwei new file mode 100755 index 0000000..4ce7b83 --- /dev/null +++ b/tests/four/term-new.zwei @@ -0,0 +1,24 @@ +// New + +class foo { + Int y; +} + +class bar { + Int h; +} + +class bof extends bar {} + +class testnew { + Int x; + Null foo() { + bof bof = new bof(3); + new unknown(); // 1/3 failure of clause 1 (nonexistent class) + bar b = new bar(); // 2/3 failure of clauses 2 and 3 (wrong number of arguments) + bar c = new bar(bof); // 3/3 failure of clauses 2 and 3 (argument not subtype of Int) + foo f = new foo(1); // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-objComp.zwei b/tests/four/term-objComp.zwei new file mode 100755 index 0000000..ee16673 --- /dev/null +++ b/tests/four/term-objComp.zwei @@ -0,0 +1,27 @@ +// ObjComp + +class foo { + Int y; +} + +class bar { + Int h; +} + +class bof extends bar {} + +class ObjCompTest { + Null foo() { + bar b = new bar(1); + bof z = new bof(1); + foo f = new foo(2); + f + b; // 1/5 failure of clause 1 (binop not == or !=) + k == b; // 2/5 failure of clause 2 (nonexistent ident) + b == l; // 3/5 failure of clause 2 (nonexistent ident) + f == b; // 4/5 failure of clause 3 (subtype mismatch) + b == f; // 5/5 failure of clause 3 (subtype mismatch) + z == b; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-select.zwei b/tests/four/term-select.zwei new file mode 100755 index 0000000..0b1a41e --- /dev/null +++ b/tests/four/term-select.zwei @@ -0,0 +1,19 @@ +// Select + +class foo { + Int y; +} + +class bar { + Int h; + Null foo() { + foo f = new foo(1); + this.h; // success in returning own attributes + k.h; // 1/2 failure of clauses 1 and 2 (nonexistent ident) + bar h = new bar(1); // success of recursive class definition + f.x; // 2/2 failure of clause 3 + f.y; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term-unop.zwei b/tests/four/term-unop.zwei new file mode 100755 index 0000000..6e6fa13 --- /dev/null +++ b/tests/four/term-unop.zwei @@ -0,0 +1,13 @@ +// UnOp +class UnOpTest { + Null foo() { + Int x = 2; + Null z = null; + -y; // 1/2 failure of clause 1 (nonexistent ident) + -z; // 2/2 failure of clause 1 (ident not of type Int) + -x; // success + !x; // success + } +} + +1 \ No newline at end of file diff --git a/tests/four/term00.zwei b/tests/four/term00.zwei new file mode 100755 index 0000000..5f3b190 --- /dev/null +++ b/tests/four/term00.zwei @@ -0,0 +1,142 @@ +// zweic - test program for term typing checks +// M. Ganguin, J. Ruffin 2005 + +// Ident +class foo { + Int y; + Null bar() { + Int x = 0; + y; // 1/1 failure of clause 1 + x; // success + } +} + +// Select +class bar { + Int h; + Null foo() { + foo f = new foo(1); + k.h; // 1/2 failure of clauses 1 and 2 (nonexistent ident) + bar h = new bar(1); // success of recursive class definition + f.x; // 2/2 failure of clause 3 + f.y; // success + } +} + +// Call +class bof extends bar { +} +class baz { + Int x; + Null works(Int a, bar c) {} + Null foo() { + bof b = new bof(1); + foo h = new foo(1); + baz z = new baz(1); + k.foo(); // 1/4 failure of clauses 1 and 2 (nonexistent ident) + h.gneuh(); // 2/4 failure of clause 3 (nonexistent method) + z.works(1); // 3/4 failure of clause 3 (wrong number of arguments) + z.works(1, h); // 4/4 failure of clause 4 (parameter not subtype of bof) + z.works(2, b); // success + } +} + +// New +class testnew { + Int x; + Null foo() { + new unknown(); // 1/3 failure of clause 1 (nonexistent class) + bar b = new bar(); // 2/3 failure of clauses 2 and 3 (wrong number of arguments) + bar c = new bar(bof); // 3/3 failure of clauses 2 and 3 (argument not subtype of Int) + foo f = new foo(1); // success + } +} + +// IntLit : untestable +// NullLit : untestable + +// UnOp +class UnOpTest { + Null foo() { + Int x = 2; + Null z = null; + -y; // 1/2 failure of clause 1 (nonexistent ident) + -z; // 2/2 failure of clause 1 (ident not of type Int) + -x; // success + !x; // success + } +} + +// Binop +class BinOpTest { + Null foo() { + Int x1 = 2; + Int x2 = 3; + Null z = null; + k + x2; // 1/4 failure of clause 1 (nonexistent ident) + x1 + l; // 2/4 failure of clause 2 (nonexistent ident) + z + x2; // 3/4 failure of clause 1 (type of ident not Int) + x1 + z; // 4/4 failure of clause 2 (type of ident not Int) + x1 + x2; // success + } +} + +// ObjComp +class ObjCompTest { + Null foo() { + bar b = new bar(1); + bof z = new bof(1); + foo f = new foo(2); + f + b; // 1/5 failure of clause 1 (binop not == or !=) + k == b; // 2/5 failure of clause 2 (nonexistent ident) + b == l; // 3/5 failure of clause 2 (nonexistent ident) + f == b; // 4/5 failure of clause 3 (subtype mismatch) + b == f; // 5/5 failure of clause 3 (subtype mismatch) + z == b; // success + } +} + +// ReadInt : untestable +// ReadChar : untestable + +// If +class IfTest { + Null foo() { + Int t = 0; + Null n = null; + + bar b = new bar(2); + bof z = new bof(3); + + if(k) {} else {}; // 1/7 failure of clause 1 (nonexistent condition) + if(n) {} else {}; // 2/7 failure of clause 1 (condition not Int) + if(t) {gorh g = null;return g} else 2; // 3/7 failure of clause 2 (unknown type) + if(t) 2 else {gorh g = null;return g }; // 4/7 failure of clause 2 (unknown type) + if(t) {foo f = new foo(1);return f} else 2; // 5/7 failure of clause 3 (LUB not found) + if(t) 2 else {foo f = new foo(2);return f}; // 6/7 failure of clause 3 (LUB not found) + bof y = if (t) b else z; // 7/7 failure of clause 3 (return type mismatch) + if(t) 2 else 3; // success + if(t) b else z; // success + } +} + +// Block + +class BlockTest { + Null foo() { + { + Int x = null; // 1/2 failure of clause 1 (incorrectly typed statement in block) + return x + }; + { + Int x = 2; + return y // 2/2 failure of clause 2 (expression not in block scope) + }; + { + Int x = 2; + return x // success + }; + } +} + +0 diff --git a/tests/four/unop.zwei b/tests/four/unop.zwei new file mode 100755 index 0000000..a83d1d5 --- /dev/null +++ b/tests/four/unop.zwei @@ -0,0 +1 @@ +-3 diff --git a/tests/four/unopa.zwei b/tests/four/unopa.zwei new file mode 100755 index 0000000..386d600 --- /dev/null +++ b/tests/four/unopa.zwei @@ -0,0 +1,4 @@ +{ + Int a = 0; + -a; +} \ No newline at end of file diff --git a/tests/four/unopa_error1.zwei b/tests/four/unopa_error1.zwei new file mode 100755 index 0000000..77be693 --- /dev/null +++ b/tests/four/unopa_error1.zwei @@ -0,0 +1,4 @@ +{ + Int a = 0; + -b; +} \ No newline at end of file diff --git a/tests/four/varScope_error0.zwei b/tests/four/varScope_error0.zwei new file mode 100755 index 0000000..051ecbe --- /dev/null +++ b/tests/four/varScope_error0.zwei @@ -0,0 +1,13 @@ +class C0 +{ + Int f0 () + { + Int a = 0; + return a + } + Int f1 () + { + return a + } +} +null \ No newline at end of file