Cleanup unnecessary code in exception formatting (dotnet/coreclr#24797)
[mono-project.git] / mcs / tests / test-ex-filter-02.cs
blob9d806bcdaf1607d92ec65eb8f220847c41c6cc6d
1 using System;
3 class X
5 static int TestGeneral ()
7 int x = -1;
8 try {
9 throw new ApplicationException ();
10 } catch when (x > 0) {
11 return 1;
12 } catch when (x < 0) {
13 return 0;
14 } catch {
15 return 2;
19 static int TestSpecific ()
21 try {
22 throw new ApplicationException ();
23 } catch (Exception e) when (Foo (delegate { Console.WriteLine (e); })) {
24 Action a = delegate {
25 Console.WriteLine (e);
27 return 1;
28 } catch (Exception e) when (e is InvalidOperationException) {
29 Console.WriteLine (e);
31 int paramIndex = 0;
32 while (paramIndex < 3) {
33 paramIndex++;
36 return 1;
37 } catch (ApplicationException) {
38 return 0;
42 static bool Foo (Action a)
44 a ();
45 return false;
48 public static int Main ()
50 var r = TestGeneral ();
51 if (r != 0)
52 return r;
54 r = TestSpecific ();
55 if (r != 0)
56 return 10 + r;
58 Console.WriteLine ("ok");
59 return 0;