[corlib] Fix a few NSLogWriter issues. (#13799)
[mono-project.git] / mcs / tests / test-ex-filter-04.cs
blobfe5a66b2db79a78b780ec50e3cdcf06cf630d2be
1 using System;
2 using System.Threading.Tasks;
4 class X
6 static Exception ex = new ApplicationException ();
8 public static int Main ()
10 if (Test (5, null).Result != 5)
11 return 1;
13 try {
14 Test (5, ex).Wait ();
15 return 2;
16 } catch (AggregateException ae) {
17 if (ae.InnerException != ex)
18 return 3;
21 try {
22 Test (15, ex).Wait ();
23 return 4;
24 } catch (AggregateException ae) {
25 if (ae.InnerException != ex)
26 return 5;
29 try {
30 TestGeneric (5).Wait ();
31 return 10;
32 } catch (AggregateException ae) {
33 if (ae.InnerException != ex)
34 return 11;
37 try {
38 TestGeneric (15).Wait ();
39 return 12;
40 } catch (AggregateException ae) {
41 if (ae.InnerException != ex)
42 return 13;
45 return 0;
48 async static Task<int> Test (int x, Exception e)
50 try {
51 Console.WriteLine (x);
52 if (e != null)
53 throw e;
54 } catch (Exception) when (x != 15) {
55 await Task.FromResult (0);
56 throw;
59 return x;
62 async static Task<int> TestGeneric (int x)
64 try {
65 Console.WriteLine (x);
66 throw ex;
67 } catch when (x != 15) {
68 await Task.FromResult (0);
69 throw;
72 return x;