fixed bug in while(){continue};
[swftools.git] / lib / as3 / ok / finally.as
1 package {
2     import flash.display.MovieClip;
3
4     public class Main extends flash.display.MovieClip {
5         function test_return() {
6             try {
7                 return;
8                 trace("error");
9             } finally {
10                 trace("ok 1/8");
11             }
12             trace("error");
13         }
14         
15         function test_break() {
16             do {
17                 try {
18                     break;
19                     trace("error");
20                 } finally {
21                     trace("ok 2/8");
22                 }
23                 trace("error");
24             } while(true);
25         }
26         
27         function test_fallthrough() {
28             try {
29                 var x = 1+1;
30             } finally {
31                 trace("ok 3/8");
32             }
33         }
34         
35         function test_exception() {
36             try {
37                 try {
38                     throw new Error();
39                     trace("error");
40                 } finally {
41                     trace("ok 4/8");
42                 }
43                 trace("error");
44             } catch(e:Error) {
45                 trace("ok 5/8");
46             }
47         }
48         
49         function test_exception2() {
50             var x:int = 0;
51             try {
52                 throw new Error();
53                 trace("error");
54             } catch(e:Error) {
55                 x=1;
56             } finally {
57                 x*=2;
58             }
59             if(x==2)
60                 trace("ok 6/8");
61         }
62
63         function fail() {
64             try {
65                 throw new Error();
66             } finally {
67                 trace("ok 7/8");
68             }
69         }
70         
71         function test_exception3() {
72             try {
73                 fail();
74             } catch(e:Error) {
75                 trace("ok 8/8");
76             }
77         }
78
79         function Main() {
80             test_return();
81             test_break();
82             test_fallthrough();
83             test_exception();
84             test_exception2();
85             test_exception3();
86         }
87     }
88 }