2010-03-17 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mcs / ilasm / tests / test-seh-e.il
1 //
2 // Test multiple catch blocks
3 //
4 // Author(s):
5 //  Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
9
10 .assembly extern mscorlib { }
11 .assembly extern System { }
12 .assembly 'test-seh-b' { }
13
14
15 .class public T {
16
17         .field private static int32 exc_not_thrown
18         .field private static int32 catch_1
19         .field private static int32 catch_2
20         .field private static int32 catch_3
21   
22         .method public static specialname void .cctor ()
23         {
24                 ldc.i4.0
25                 stsfld int32 T::exc_not_thrown
26
27                 ldc.i4.0
28                 stsfld int32 T::catch_1
29
30                 ldc.i4.0
31                 stsfld int32 T::catch_2
32
33                 ldc.i4.0
34                 stsfld int32 T::catch_3
35
36                 ret
37         }
38
39         .method public static int32 Main ()
40         {
41                 .entrypoint
42
43                 //
44                 // Only the second catch block should be executed
45                 //
46                 
47                 .try {
48                         ldc.i4.0
49                         ldc.i4.0
50                         div
51
52                         ldc.i4.1
53                         stsfld int32 T::exc_not_thrown
54
55                         leave outer
56                 } catch [mscorlib]System.InvalidCastException {
57                         ldc.i4.1
58                         stsfld int32 T::catch_1
59                         leave outer
60                 } catch [mscorlib]System.DivideByZeroException {
61                         ldc.i4.1
62                         stsfld int32 T::catch_2
63                         leave outer
64                 } catch [mscorlib]System.Exception {
65                         ldc.i4.1
66                         stsfld int32 T::catch_3
67                         leave outer
68                 }
69            
70
71         outer:
72                 ldsfld int32 T::exc_not_thrown
73                 brtrue fail
74
75                 ldsfld int32 T::catch_1
76                 brtrue fail
77
78                 ldsfld int32 T::catch_2
79                 brfalse fail
80
81                 ldsfld int32 T::catch_3
82                 brtrue fail
83
84         pass:
85                 ldstr "PASS"
86                 call void [mscorlib]System.Console::WriteLine (string)
87                 ldc.i4.0
88                 ret
89
90         fail:
91                 ldstr "FAIL"
92                 call void [mscorlib]System.Console::WriteLine (string)
93                 ldc.i4.1
94                 ret
95
96         }
97
98 }
99                 
100