# HG changeset patch # User Paul Boddie # Date 1100098449 -3600 # Node ID 5cf60a47f25194d3f3b2800acc65d29c559e82da # Parent 83643c18d6135cb3e71e15bd6e19351eb4b7a32d Expanded the exception test. Added construction of values in the value test. Added a test of subclass initialisation. diff -r 83643c18d613 -r 5cf60a47f251 tests/ExceptionTest.java --- a/tests/ExceptionTest.java Tue Nov 09 20:05:58 2004 +0100 +++ b/tests/ExceptionTest.java Wed Nov 10 15:54:09 2004 +0100 @@ -1,18 +1,51 @@ public class ExceptionTest { - public int testCatch() { - try { + public int testThrow(int x) throws java.lang.Exception { + if (x == 0) { throw new MyException(); + } else if (x == 1) { + throw new MyOtherException(); + } else { + return 1; + } + } + + public int testCatch(int x) { + try { + if (x == 0) { + throw new MyException(); + } else if (x == 1) { + throw new MyOtherException(); + } else { + x = 1; + } } catch (MyException exc) { - return 1; + x = 3; + } catch (MyOtherException exc) { + x = 2; + } + return x; + } + + public int testIncomingCatch(int x) { + try { + return testThrow(x); + } catch (MyException exc) { + return 3; + } catch (MyOtherException exc) { + return 2; + } catch (java.lang.Exception exc) { + return -1; // Should be unreachable, really. } } public int testFinally(int x) throws java.lang.Exception { try { if (x == 0) { + x = 3; throw new MyException(); } else if (x == 1) { + x = 2; throw new MyOtherException(); } } finally { diff -r 83643c18d613 -r 5cf60a47f251 tests/Value.java --- a/tests/Value.java Tue Nov 09 20:05:58 2004 +0100 +++ b/tests/Value.java Wed Nov 10 15:54:09 2004 +0100 @@ -30,6 +30,10 @@ public int add(int value) { return this.value + value; } + + public Value newValue() { + return new Value(this.getValue()); + } } // vim: tabstop=4 expandtab shiftwidth=4 diff -r 83643c18d613 -r 5cf60a47f251 tests/ValueSubclass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ValueSubclass.java Wed Nov 10 15:54:09 2004 +0100 @@ -0,0 +1,6 @@ +public class ValueSubclass extends Value { + + public ValueSubclass(int x) { + super(x); + } +}