Merge pull request #249 from pcc/xgetinputfocus
[mono.git] / mcs / tests / test-async-31.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Threading.Tasks;
4
5 class C
6 {
7         async Task<int> M(int v)
8         {
9                 {
10                         await Task.Yield();
11                         int vv = 0;
12                         Func<int> a = () => vv;
13                         vv = 3;
14                         Func<int> a2 = () => v + vv;
15                         if (a() != vv)
16                                 return 1;
17
18                         if (a2() != 58)
19                                 return 2;
20                 }
21                 return 0;
22         }
23
24         async Task<int> M2(int v, int o)
25         {
26                 await Task.Yield();
27                 var xo = await Task.FromResult(v);
28                 int vv = v;
29                 Action a2;
30                 int b = o;
31                 {
32                         a2 = () => {
33                                 v = 500;
34                                 b = 2;
35                         };
36                 }
37
38                 await Task.Yield();
39                 a2 ();
40                 if (v != 500)
41                         return 1;
42
43                 return 0;
44         }
45         
46         public static int Main()
47         {
48                 var c = new C();
49                 if (c.M(55).Result != 0)
50                         return 1;
51
52                 if (c.M2(55, 22).Result != 0)
53                         return 2;
54
55                 return 0;
56         }
57 }