Initial set of Ward sgen annotations (#5705)
[mono.git] / mcs / tests / test-ex-filter-02.cs
1 using System;
2
3 class X
4 {
5         static int TestGeneral ()
6         {
7                 int x = -1;
8                 try {
9                         throw new ApplicationException ();
10                 } catch when (x > 0) {
11                         return 1;
12                 } catch when (x < 0) {
13                         return 0;
14                 } catch {
15                         return 2;
16                 }
17         }
18
19         static int TestSpecific ()
20         {
21                 try {
22                         throw new ApplicationException ();
23                 } catch (Exception e) when (Foo (delegate { Console.WriteLine (e); })) {
24                         Action a = delegate {
25                                 Console.WriteLine (e);
26                         };
27                         return 1;
28                 } catch (Exception e) when (e is InvalidOperationException) {
29                         Console.WriteLine (e);
30
31                         int paramIndex = 0;
32                         while (paramIndex < 3) {
33                                 paramIndex++;
34                         }
35                                                 
36                         return 1;
37                 } catch (ApplicationException) {
38                         return 0;
39                 }
40         }
41
42         static bool Foo (Action a)
43         {
44                 a ();
45                 return false;
46         }
47
48         public static int Main ()
49         {
50                 var r = TestGeneral ();
51                 if (r != 0)
52                         return r;
53
54                 r = TestSpecific ();
55                 if (r != 0)
56                         return 10 + r;
57
58                 Console.WriteLine ("ok");
59                 return 0;
60         }
61 }