[tests] Test loading references from LoadFrom and LoadFile contexts
[mono-project.git] / mono / tests / generic-exceptions.2.cs
blobef0777a4cb1c64430e71df3681fc3d7b49afd732
1 using System;
3 public class GenExc<S,T> : Exception {
6 public delegate void ThrowDelegate ();
8 public class Gen<T> {
9 public void catcher<S> (ThrowDelegate thrower) {
10 try {
11 thrower ();
13 catch (GenExc<S,T>) {
17 public static void staticCatcher<S> (ThrowDelegate thrower) {
18 try {
19 thrower ();
21 catch (GenExc<S,T>) {
26 public class main {
27 static void throwObjectObject () {
28 throw new GenExc<object, object> ();
31 static void throwStringObject () {
32 throw new GenExc<string, object> ();
35 static int Main () {
36 Gen<object> go = new Gen<object> ();
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));
44 catch {
45 return 1;
48 try {
49 go.catcher<object> (new ThrowDelegate (main.throwStringObject));
50 return 1;
52 catch {
54 try {
55 Gen<object>.staticCatcher<object> (new ThrowDelegate (main.throwStringObject));
56 return 1;
58 catch {
61 try {
62 go.catcher<string> (new ThrowDelegate (main.throwObjectObject));
63 return 1;
65 catch {
67 try {
68 Gen<object>.staticCatcher<string> (new ThrowDelegate (main.throwObjectObject));
69 return 1;
71 catch {
74 return 0;