// 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