[metadata] Fix leaks when handling a few attributes (#16675)
[mono-project.git] / mcs / tests / test-ex-filter-05.cs
blob7a9d46303e1e29976c76f117d88e23283894eaa2
1 using System;
2 using System.Threading.Tasks;
4 class Test
6 static bool Verify (Func<bool> f)
8 return f ();
11 static async Task<int> TestCapturedException (Exception e)
13 try {
14 if (e != null)
15 throw e;
16 } catch (Exception ex) when (Verify (() => ex.Message == "foo")) {
17 await Task.Yield ();
18 Console.WriteLine (ex);
19 return 1;
20 } catch (Exception ex) when (Verify (() => ex.Message != null)) {
21 await Task.Yield ();
22 Console.WriteLine (ex);
23 return 2;
26 return 3;
29 public static int Main()
31 if (TestCapturedException (null).Result != 3)
32 return 1;
34 var ex = new ApplicationException ();
35 if (TestCapturedException (ex).Result != 2)
36 return 2;
38 return 0;