// This test file tests some sample scenarios with the class syntax // Run this after the basic class functionality works for you // 1. Multiple field declarations on the same line // 2. Functions with zero parameters. More than two parameters // 3. Functions with an empty method body // 4. Empty blocks // 5. Blocks with statements and declarations interleaved // 6. If stmt then stmt // 7. If stmt then stmt else stmt // 8. The empty statement // 9. return with no value // 10. return with a value // 11. Expressions that should be accepted by the grammar. Might not make real sense- // a. 5 = 6 // b. +++--+-5 // c. ++(int)--5 // d. --5 && ++6 // e. 5 instanceof int; // f. a.b.c().d.e.f(g,h).i(j) // g. a.b(c.d(),e.f(g,h)) // h. a = ((b)c()).d() // i. ((int)y).x(f) public class Junk { int a, b, c; // 1 public Junk(int a1, int b1, int c1) { a = a1; b = b1; c = c1; } public Junk M1(){ return this;} // 2,3 public boolean M2(int a, Junk b, boolean c) // 2 { int j; j = 5; int k; // 5 k = -j; if (j > k) // 6 j = 10; if (j < k) // 7 j = 5; else k = 5; ; // 8 return (j==k); } } public class RecycledJunk extends Junk { public RecycledJunk() { super(5,6,7); // 11.j } private boolean ExpressionTester() { 5 = 6; // 11.a +++--+-5; // 11.b ++(int)--5; // 11.c --5 && ++6; // 11.d 5 instanceof int; // 11.e // And now the heavy duty stuff. None of the following are semantically valid // Here we just want to test that these can be parsed by the parser. a.b.c().d.e.f(g,h).i(j,k); // 11.f a.b(c.d(),e.f(g,h)); // 11.g a = ((b)c()).d(); // 11.h ((int)y).x(f); // 11.i return 6; } public static void main() {} }