update readme (#21797)
[mono-project.git] / mcs / tests / test-async-03.cs
blob7f8d80778f9618961cea63fe5f1f8956de8a9dcf
1 using System.Runtime.CompilerServices;
2 using System.Threading.Tasks;
4 static class S
6 public static A GetAwaiter (this int i)
8 return new A ();
12 class A : INotifyCompletion
14 bool IsCompleted {
15 get {
16 return true;
20 void INotifyCompletion.OnCompleted (System.Action a)
24 int GetResult ()
26 return 3;
29 static async Task<int> Test1 ()
31 await checked (1);
32 return await checked (2);
35 static async Task<int> Test2 ()
37 await checked (1);
38 return 4;
41 static async Task Test3 ()
43 await checked (1);
46 public static int Main ()
48 var r = Test1 ();
49 System.Console.WriteLine (r.Result);
50 if (r.Result != 3)
51 return 1;
53 r = Test2 ();
54 System.Console.WriteLine (r.Result);
55 if (r.Result != 4)
56 return 2;
58 Test3();
59 return 0;