# HG changeset patch # User Paul Boddie # Date 1106323307 -3600 # Node ID 69dd27ca4d7d0e8588d0cb8887e44fb27d8a5440 # Parent 3e197ad55b82e1e97fdecadfc22c9108e037b8be Added the start of a test program. diff -r 3e197ad55b82 -r 69dd27ca4d7d tests/ExceptionTest.java --- a/tests/ExceptionTest.java Tue Jan 18 17:47:24 2005 +0100 +++ b/tests/ExceptionTest.java Fri Jan 21 17:01:47 2005 +0100 @@ -97,6 +97,35 @@ } return x; } + + public static void main(String[] args) { + ExceptionTest test = new ExceptionTest(); + try { + test.testThrow(0); + System.err.println("testThrow(0) failed!"); + } catch (MyException exc) { + System.out.println("testThrow(0) correct: " + exc); + } catch (java.lang.Exception exc) { + System.err.println("testThrow(0) failed (MyException expected)!"); + } + try { + test.testThrow(1); + System.err.println("testThrow(1) failed!"); + } catch (MyOtherException exc) { + System.out.println("testThrow(1) correct: " + exc); + } catch (java.lang.Exception exc) { + System.err.println("testThrow(1) failed (MyOtherException expected)!"); + } + try { + if (test.testThrow(2) != 1) { + System.err.println("testThrow(2) failed!"); + } else { + System.out.println("testThrow(2) correct."); + } + } catch (java.lang.Exception exc) { + System.err.println("testThrow(2) failed (no exception expected)!"); + } + } } class MyException extends java.lang.Exception {