cleaned up these tests.
[feisty_meow.git] / kona / src / test / java / semantics / behavior_of_finally_when_exception_in_catch.java
index e722b130e06fbc58a7ca69b296ce40d205625923..d28857f010d83042a5e4e1caab812005cfd2c282 100644 (file)
@@ -2,51 +2,58 @@ package test.java.semantics;
 
 import java.io.FileNotFoundException;
 
-class finally_behavior_test
+//hmmm: convert this to simple unit test.
+public class behavior_of_finally_when_exception_in_catch
 {
-    int calibrador = 17;
+       private int calibrador = 17;
 
-    public finally_behavior_test()
-    {
-    }
+       private boolean ranRight = false;
 
-    public int funkyTown() throws FileNotFoundException
-    {
-        if (calibrador < 3) {
-            // we should never get here.  it should always raise an exception.
-            System.out.println("where did you put it?");
-        } else {
-            throw new FileNotFoundException("is it larger than a breadbox?");
-        }
-        return 25;
-    }
+       public behavior_of_finally_when_exception_in_catch()
+       {
+       }
 
-    public void runTest() throws Throwable
-    {
-        try {
-            int zooty = funkyTown();
-            System.out.println("zooty is " + zooty + " but how did we get here???");
-        } catch (Throwable cause) {
-            System.out.println("caught exception, now will rethrow.");
-            throw cause;
-        } finally {
-            System.out.println("still got to finally, our assumptions are safe.");
-        }
-    }
+       public int funkyTown() throws FileNotFoundException
+       {
+               if (calibrador < 3) {
+                       // we should never get here. it should always raise an exception.
+                       System.out.println("where did you put it?");
+               } else {
+                       throw new FileNotFoundException("is it larger than a breadbox?");
+               }
+               return 25;
+       }
 
-    public static void main(String s[]) throws Exception
-    {
-        // we are asserting that the finally clause of an exception handler will still
-        // fire when an exception is raised in the catch clause. otherwise, all our
-        // assumptions about being able to use finally properly are thrown out the window.
-        finally_behavior_test tony = new finally_behavior_test();
-        try {
-            tony.runTest();
-        } catch (Throwable cause) {
-            //yawn.
-        }
-        System.out.println("Hey, did the finally clause say it ran above?");
-        System.out.println("If so, great.  If not, we've got problems.");
-    }
+       public void runTest() throws Throwable
+       {
+               try {
+                       int zooty = funkyTown();
+                       System.out.println("zooty is " + zooty + " but how did we get here???");
+               } catch (Throwable cause) {
+                       System.out.println("caught exception, now will rethrow.  so far this is fine.");
+                       throw cause;
+               } finally {
+                       System.out.println("ran finally clause; our assumptions are safe.  we MUST see this line!!");
+                       ranRight = true;
+               }
+       }
 
+       public static void main(String s[]) throws Exception
+       {
+               // we are asserting that the finally clause of an exception handler will still
+               // fire when an exception is raised in the catch clause. otherwise, all our
+               // assumptions about being able to use finally properly are thrown out the window.
+               behavior_of_finally_when_exception_in_catch tony = new behavior_of_finally_when_exception_in_catch();
+               try {
+                       tony.runTest();
+               } catch (Throwable cause) {
+                       // yawn.
+               }
+               System.out.println("the finally clause needs to have run above; otherwise, we've got bad problems.");
+               if (!tony.ranRight) {
+                       System.out.println("FAILURE in assumptions about the finally clause!!!");
+               } else {
+                       System.out.println("okay, cool.  test succeeded.");
+               }
+       }
 }