[tests] Test loading references from LoadFrom and LoadFile contexts
[mono-project.git] / mono / tests / bug-46661.cs
blobfe88b57e7481d819d021818a4d34e1d89ff12257
1 using System;
2 using System.Linq;
3 using System.IO;
5 namespace ExceptionFilterTestLauncher
7 class Program
9 public static object newObject = null;
10 public static bool SubTest(int i)
12 return newObject.GetHashCode() == i;
15 public static bool HandleException(Exception e)
17 return true;
20 public static bool Test2(int i)
22 bool test = true;
23 try
25 test = SubTest(i);
27 catch (Exception e) when (!HandleException(e))
30 return test;
33 static void Main(string[] args)
35 try
37 bool result = Test2(12345);
39 catch (Exception e)
41 // Before bug 46661 was fixed, the when would cut the stack trace, so Test(int) wouldn't show up
42 if(!e.StackTrace.Contains("SubTest"))
43 throw new Exception("Stack trace doesn't reference SubTest function. Current stacktrace is " + e.StackTrace.ToString());
44 else
45 // Correct result
46 Environment.Exit(0);
48 throw new Exception("Exception should have been caught!");