Add support for Windows x64 Full AOT + LLVM + Interpreter on CI. (#15276)
[mono-project.git] / mcs / tests / test-async-18.cs
blob1dcfa4c546b2b5f560cedf422a5c45bdaa6d0103
1 using System;
2 using System.Threading.Tasks;
3 using System.Threading;
5 class Tester
7 async Task<int> Lambda_1 ()
9 int res = 1;
11 int a = 8;
12 Func<int> f = () => a;
13 res = await Task.Factory.StartNew (f).ConfigureAwait (false);
14 res += f ();
17 return res - 16;
20 async Task<int> Lambda_2 ()
22 int res = 1;
24 int a = 8;
25 Func<int> f = () => a + res;
26 res = await Task.Factory.StartNew (f).ConfigureAwait (false);
27 res += f ();
30 return res - 26;
33 async Task<int> Lambda_3<T> ()
35 int res = 1;
37 int a = 8;
38 Func<int> f = () => a;
39 res = await Task.Factory.StartNew (f).ConfigureAwait (false);
40 res += f ();
43 return res - 16;
46 public static int Main ()
48 var t = new Tester ().Lambda_1 ();
49 if (!Task.WaitAll (new [] { t }, 1000))
50 return 1;
52 if (t.Result != 0)
53 return 2;
55 t = new Tester ().Lambda_2 ();
56 if (!Task.WaitAll (new [] { t }, 1000))
57 return 3;
59 if (t.Result != 0)
60 return 4;
62 t = new Tester ().Lambda_3<ulong>();
63 if (!Task.WaitAll (new [] { t }, 1000))
64 return 5;
66 if (t.Result != 0)
67 return 6;
69 Console.WriteLine ("ok");
70 return 0;