Another dist build fix for rx integration, move *.cs file to safe-ish path.
[mono-project.git] / mcs / tests / test-async-18.cs
blob898d9ed4dedaac879274ce2c3716cd348cbb55a6
1 // Compiler options: -langversion:future
2 using System;
3 using System.Threading.Tasks;
4 using System.Threading;
6 class Tester
8 async Task<int> Lambda_1 ()
10 int res = 1;
12 int a = 8;
13 Func<int> f = () => a;
14 res = await Task.Factory.StartNew (f);
15 res += f ();
18 return res - 16;
21 async Task<int> Lambda_2 ()
23 int res = 1;
25 int a = 8;
26 Func<int> f = () => a + res;
27 res = await Task.Factory.StartNew (f);
28 res += f ();
31 return res - 26;
34 async Task<int> Lambda_3<T> ()
36 int res = 1;
38 int a = 8;
39 Func<int> f = () => a;
40 res = await Task.Factory.StartNew (f);
41 res += f ();
44 return res - 16;
47 public static int Main ()
49 var t = new Tester ().Lambda_1 ();
50 if (!Task.WaitAll (new [] { t }, 1000))
51 return 1;
53 if (t.Result != 0)
54 return 2;
56 t = new Tester ().Lambda_2 ();
57 if (!Task.WaitAll (new [] { t }, 1000))
58 return 3;
60 if (t.Result != 0)
61 return 4;
63 t = new Tester ().Lambda_3<ulong>();
64 if (!Task.WaitAll (new [] { t }, 1000))
65 return 5;
67 if (t.Result != 0)
68 return 6;
70 Console.WriteLine ("ok");
71 return 0;