javaclass

Changeset

32:29818b5b62b5
2004-11-11 Paul Boddie raw files shortlog changelog graph Added tests of dispatch according to object class or interface.
tests/DispatchTest.java (file)
     1.1 --- a/tests/DispatchTest.java	Thu Nov 11 16:49:35 2004 +0100
     1.2 +++ b/tests/DispatchTest.java	Thu Nov 11 20:30:29 2004 +0100
     1.3 @@ -29,4 +29,32 @@
     1.4      public void set(float b) {
     1.5          this.b = b;
     1.6      }
     1.7 +
     1.8 +    public int test(DispatchInterface obj) {
     1.9 +        return obj.test();
    1.10 +    }
    1.11 +
    1.12 +    public int test(DispatchClass1 obj) {
    1.13 +        return obj.test();
    1.14 +    }
    1.15 +
    1.16 +    public int testTest(DispatchInterface obj) {
    1.17 +        return test(obj);
    1.18 +    }
    1.19  }
    1.20 +
    1.21 +interface DispatchInterface {
    1.22 +    public int test();
    1.23 +}
    1.24 +
    1.25 +class DispatchClass1 implements DispatchInterface {
    1.26 +    public int test() {
    1.27 +        return 1;
    1.28 +    }
    1.29 +}
    1.30 +
    1.31 +class DispatchClass2 implements DispatchInterface {
    1.32 +    public int test() {
    1.33 +        return 2;
    1.34 +    }
    1.35 +}