[build] Fix warning (#4177)
[mono-project.git] / mcs / tests / test-async-63.cs
blob4572d7e2eda3e3cc4acf76583643d0e333f3422f
1 using System;
2 using System.Threading.Tasks;
4 class C
6 static int counter;
7 public static async Task TestSingleAwait (bool throwException)
9 try {
10 if (throwException)
11 throw new ApplicationException ();
12 } catch (ApplicationException ex) {
13 Console.WriteLine ("x1a");
14 ++counter;
15 await Call ();
16 Console.WriteLine ("x2a");
17 ++counter;
18 } catch {
19 throw;
22 Console.WriteLine ("end");
25 public static async Task TestDoubleAwait (bool throwException)
27 try {
28 if (throwException)
29 throw new ApplicationException ();
30 } catch (ApplicationException ex) {
31 Console.WriteLine ("x1a");
32 ++counter;
33 await Call ();
34 Console.WriteLine ("x2a");
35 ++counter;
36 } catch {
37 Console.WriteLine ("x1b");
38 counter += 4;
39 await Call ();
40 Console.WriteLine ("x2b");
41 counter += 7;
44 Console.WriteLine ("end");
47 static Task Call ()
49 return Task.Factory.StartNew (() => false);
52 void HH ()
54 try {
55 throw new ApplicationException ();
56 } catch {
57 throw;
61 public static int Main ()
63 TestSingleAwait (true).Wait ();
64 Console.WriteLine (counter);
65 if (counter != 2)
66 return 1;
68 TestSingleAwait (false).Wait ();
69 if (counter != 2)
70 return 2;
72 counter = 0;
74 TestDoubleAwait (true).Wait ();
75 Console.WriteLine (counter);
76 if (counter != 2)
77 return 3;
79 TestDoubleAwait (false).Wait ();
80 if (counter != 2)
81 return 4;
83 return 0;