# HG changeset patch # User Paul Boddie # Date 1100183061 -3600 # Node ID 8bd6e8322ae0f08a3da938bc4af1ce2e6d215f24 # Parent fe4821483813995a515fa292a1ac4dad6239b32f Added overriding tests to ValueSubclass, modifying Value. Added a test of dispatch to methods with identical names. diff -r fe4821483813 -r 8bd6e8322ae0 tests/DispatchTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/DispatchTest.java Thu Nov 11 15:24:21 2004 +0100 @@ -0,0 +1,32 @@ +public class DispatchTest { + public int a; + public float b; + + public DispatchTest() { + this.a = 1; + this.b = 2; + } + + public DispatchTest(int a) { + this.a = a; + this.b = 2; + } + + public DispatchTest(float b) { + this.a = 1; + this.b = b; + } + + public DispatchTest(int a, float b) { + this.a = a; + this.b = b; + } + + public void set(int a) { + this.a = a; + } + + public void set(float b) { + this.b = b; + } +} diff -r fe4821483813 -r 8bd6e8322ae0 tests/Value.java --- a/tests/Value.java Wed Nov 10 17:47:04 2004 +0100 +++ b/tests/Value.java Thu Nov 11 15:24:21 2004 +0100 @@ -1,5 +1,5 @@ public class Value { - private int value; + protected int value; public Value(int value) { this.value = value; diff -r fe4821483813 -r 8bd6e8322ae0 tests/ValueSubclass.java --- a/tests/ValueSubclass.java Wed Nov 10 17:47:04 2004 +0100 +++ b/tests/ValueSubclass.java Thu Nov 11 15:24:21 2004 +0100 @@ -1,6 +1,31 @@ public class ValueSubclass extends Value { + /** + * Test of subclass initialisation with super usage and foreign object initialisation. + */ public ValueSubclass(int x) { super(x); + Value tmp = new Value(42); + } + + /** + * Test of overriding. + */ + public void setValue(int x) { + this.value = -x; + } + + /** + * Test of overriding and super methods. + */ + public int add(int x) { + return super.add(-x); + } + + /** + * Test of objects as arguments. + */ + public void setValueObject(Value v) { + this.value = v.getValue(); } }