added test for finally
authorkramm <kramm>
Fri, 2 Jan 2009 19:42:13 +0000 (19:42 +0000)
committerkramm <kramm>
Fri, 2 Jan 2009 19:42:13 +0000 (19:42 +0000)
lib/as3/ok/finally.as [new file with mode: 0644]

diff --git a/lib/as3/ok/finally.as b/lib/as3/ok/finally.as
new file mode 100644 (file)
index 0000000..6878020
--- /dev/null
@@ -0,0 +1,88 @@
+package {
+    import flash.display.MovieClip;
+
+    public class Main extends flash.display.MovieClip {
+        function test_return() {
+            try {
+                return;
+                trace("error");
+            } finally {
+                trace("ok 1/8");
+            }
+            trace("error");
+        }
+        
+        function test_break() {
+            do {
+                try {
+                    break;
+                    trace("error");
+                } finally {
+                    trace("ok 2/8");
+                }
+                trace("error");
+            } while(true);
+        }
+        
+        function test_fallthrough() {
+            try {
+                var x = 1+1;
+            } finally {
+                trace("ok 3/8");
+            }
+        }
+        
+        function test_exception() {
+            try {
+                try {
+                    throw new Error();
+                    trace("error");
+                } finally {
+                    trace("ok 4/8");
+                }
+                trace("error");
+            } catch(e:Error) {
+                trace("ok 5/8");
+            }
+        }
+        
+        function test_exception2() {
+            var x:int = 0;
+            try {
+                throw new Error();
+                trace("error");
+            } catch(e:Error) {
+                x=1;
+            } finally {
+                x*=2;
+            }
+            if(x==2)
+                trace("ok 6/8");
+        }
+
+        function fail() {
+            try {
+                throw new Error();
+            } finally {
+                trace("ok 7/8");
+            }
+        }
+        
+        function test_exception3() {
+            try {
+                fail();
+            } catch(e:Error) {
+                trace("ok 8/8");
+            }
+        }
+
+        function Main() {
+            test_return();
+            test_break();
+            test_fallthrough();
+            test_exception();
+            test_exception2();
+            test_exception3();
+        }
+    }
+}