[w32file] Move MonoIO.Find{First,Next,Close} to managed
[mono.git] / mcs / tests / test-async-18.cs
1 using System;
2 using System.Threading.Tasks;
3 using System.Threading;
4
5 class Tester
6 {
7         async Task<int> Lambda_1 ()
8         {
9                 int res = 1;
10                 {
11                         int a = 8;
12                         Func<int> f = () => a;
13                         res = await Task.Factory.StartNew (f).ConfigureAwait (false);
14                         res += f ();
15                 }
16                 
17                 return res - 16;
18         }
19         
20         async Task<int> Lambda_2 ()
21         {
22                 int res = 1;
23                 {
24                         int a = 8;
25                         Func<int> f = () => a + res;
26                         res = await Task.Factory.StartNew (f).ConfigureAwait (false);
27                         res += f ();
28                 }
29                 
30                 return res - 26;
31         }
32         
33         async Task<int> Lambda_3<T> ()
34         {
35                 int res = 1;
36                 {
37                         int a = 8;
38                         Func<int> f = () => a;
39                         res = await Task.Factory.StartNew (f).ConfigureAwait (false);
40                         res += f ();
41                 }
42                 
43                 return res - 16;
44         }       
45
46         public static int Main ()
47         {
48                 var t = new Tester ().Lambda_1 ();
49                 if (!Task.WaitAll (new [] { t }, 1000))
50                         return 1;
51                 
52                 if (t.Result != 0)
53                         return 2;
54                 
55                 t = new Tester ().Lambda_2 ();
56                 if (!Task.WaitAll (new [] { t }, 1000))
57                         return 3;
58                 
59                 if (t.Result != 0)
60                         return 4;
61
62                 t = new Tester ().Lambda_3<ulong>();
63                 if (!Task.WaitAll (new [] { t }, 1000))
64                         return 5;
65                 
66                 if (t.Result != 0)
67                         return 6;
68                 
69                 Console.WriteLine ("ok");
70                 return 0;
71         }
72 }