1.1 --- a/tests/DispatchTest.java Sun Jan 23 01:01:34 2005 +0100
1.2 +++ b/tests/DispatchTest.java Sun Jan 23 01:01:40 2005 +0100
1.3 @@ -45,6 +45,52 @@
1.4 public int testTest(DispatchInterface obj) {
1.5 return test(obj);
1.6 }
1.7 +
1.8 + public static void main(String[] args) {
1.9 + DispatchTest test = new DispatchTest();
1.10 + DispatchClass1 dc1 = new DispatchClass1();
1.11 + DispatchClass2 dc2 = new DispatchClass2();
1.12 +
1.13 + if (test.a == 1 && test.b == 2) {
1.14 + System.out.println("test.a, test.b correct: " + test.a + ", " + test.b);
1.15 + } else {
1.16 + System.err.println("test.a, test.b failed!");
1.17 + }
1.18 + test.set(5);
1.19 + if (test.a == 5 && test.b == 2) {
1.20 + System.out.println("test.a, test.b correct: " + test.a + ", " + test.b);
1.21 + } else {
1.22 + System.err.println("test.a, test.b failed!");
1.23 + }
1.24 + test.set(7.0f);
1.25 + if (test.a == 5 && test.b == 7.0f) {
1.26 + System.out.println("test.a, test.b correct: " + test.a + ", " + test.b);
1.27 + } else {
1.28 + System.err.println("test.a, test.b failed!");
1.29 + }
1.30 + if (test.test(dc1) == 11) {
1.31 + System.out.println("test.test(dc1) correct: " + test.test(dc1));
1.32 + } else {
1.33 + System.err.println("test.test(dc1) failed!");
1.34 + }
1.35 + if (test.test(dc2) == 2) {
1.36 + System.out.println("test.test(dc2) correct: " + test.test(dc2));
1.37 + } else {
1.38 + System.err.println("test.test(dc2) failed!");
1.39 + }
1.40 + // Yes, one might think this could be 11, but the parameter becomes
1.41 + // "more vague" when passed to testTest.
1.42 + if (test.testTest(dc1) == 1) {
1.43 + System.out.println("test.testTest(dc1) correct: " + test.testTest(dc1));
1.44 + } else {
1.45 + System.err.println("test.testTest(dc1) failed!");
1.46 + }
1.47 + if (test.testTest(dc2) == 2) {
1.48 + System.out.println("test.testTest(dc2) correct: " + test.testTest(dc2));
1.49 + } else {
1.50 + System.err.println("test.testTest(dc2) failed!");
1.51 + }
1.52 + }
1.53 }
1.54
1.55 interface DispatchInterface {
1.56 @@ -62,3 +108,5 @@
1.57 return 2;
1.58 }
1.59 }
1.60 +
1.61 +// vim: tabstop=4 expandtab shiftwidth=4