Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generic-exceptions.2.cs
1 using System;
2
3 public class GenExc<S,T> : Exception {
4 }
5
6 public delegate void ThrowDelegate ();
7
8 public class Gen<T> {
9         public void catcher<S> (ThrowDelegate thrower) {
10                 try {
11                         thrower ();
12                 }
13                 catch (GenExc<S,T>) {
14                 }
15         }
16
17         public static void staticCatcher<S> (ThrowDelegate thrower) {
18                 try {
19                         thrower ();
20                 }
21                 catch (GenExc<S,T>) {
22                 }
23         }
24 }
25
26 public class main {
27         static void throwObjectObject () {
28                 throw new GenExc<object, object> ();
29         }
30
31         static void throwStringObject () {
32                 throw new GenExc<string, object> ();
33         }
34
35         static int Main () {
36                 Gen<object> go = new Gen<object> ();
37
38                 try {
39                         go.catcher<object> (new ThrowDelegate (main.throwObjectObject));
40                         Gen<object>.staticCatcher<object> (new ThrowDelegate (main.throwObjectObject));
41                         go.catcher<string> (new ThrowDelegate (main.throwStringObject));
42                         Gen<object>.staticCatcher<string> (new ThrowDelegate (main.throwStringObject));
43                 }
44                 catch {
45                         return 1;
46                 }
47
48                 try {
49                         go.catcher<object> (new ThrowDelegate (main.throwStringObject));
50                         return 1;
51                 }
52                 catch {
53                 }
54                 try {
55                         Gen<object>.staticCatcher<object> (new ThrowDelegate (main.throwStringObject));
56                         return 1;
57                 }
58                 catch {
59                 }
60
61                 try {
62                         go.catcher<string> (new ThrowDelegate (main.throwObjectObject));
63                         return 1;
64                 }
65                 catch {
66                 }
67                 try {
68                         Gen<object>.staticCatcher<string> (new ThrowDelegate (main.throwObjectObject));
69                         return 1;
70                 }
71                 catch {
72                 }
73
74                 return 0;
75         }
76 }