Signed-off-by: Tomek Grabiec <[email protected]>
---
 regression/jvm/ExceptionsTest.java |   77 ++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/regression/jvm/ExceptionsTest.java 
b/regression/jvm/ExceptionsTest.java
index eafcc7d..b82db1c 100644
--- a/regression/jvm/ExceptionsTest.java
+++ b/regression/jvm/ExceptionsTest.java
@@ -25,6 +25,23 @@
  */
 package jvm;
 
+class MyException extends Exception {
+    static final long serialVersionUID = 0;
+
+    public MyException(String msg) {
+        super(msg);
+    }
+};
+
+class MyException2 extends MyException {
+    static final long serialVersionUID = 0;
+
+    public MyException2(String msg) {
+        super(msg);
+    }
+};
+
+
 /**
  * @author Tomasz Grabiec
  */
@@ -39,16 +56,70 @@ public class ExceptionsTest extends TestCase {
         try {
             i = 2;
         } catch (Exception e) {
-            i--;
-            return i;
+            i = 3;
         } catch (Throwable e) {
-            i++;
+            i = 4;
         }
 
         return i;
     }
 
+    public static void testThrowAndCatchInTheSameMethod() {
+        Exception e = new Exception("the horror!");
+        boolean catched = false;
+
+        try {
+            throw e;
+        } catch (Exception _e) {
+            assertEquals(e, _e);
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void methodThrowingException(int counter) throws Exception {
+        if (counter == 0)
+            throw new Exception("boom");
+        else
+            methodThrowingException(counter - 1);
+    }
+
+    public static void testUnwinding() {
+        boolean catched = false;
+
+        try {
+            methodThrowingException(10);
+        } catch (Exception e) {
+            assertEquals(e.getMessage(), "boom");
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testMultipleCatchBlocks() {
+        int section = 0;
+
+        try {
+            throw new MyException("boom");
+        } catch (MyException2 e) {
+            section = 1;
+        } catch (MyException e) {
+            section = 2;
+        } catch (Exception e) {
+            section = 3;
+        }
+
+        assertEquals(section, 2);
+    }
+
     public static void main(String args[]) {
+        testCatchCompilation();
+        testThrowAndCatchInTheSameMethod();
+        testUnwinding();
+        testMultipleCatchBlocks();
+
         Runtime.getRuntime().halt(retval);
     }
 };
-- 
1.6.0.6


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to