Merge pull request #571 from igotti-google/jt2
[mono.git] / mcs / tests / test-async-22.cs
1 using System;
2 using System.Threading.Tasks;
3
4 // contextual async, parser tests
5
6 class A
7 {
8         async Task<int> async ()
9         {
10                 int async;
11                 throw new NotImplementedException ();
12         }
13
14         async Task async (int async)
15         {
16                 throw new NotImplementedException ();
17         }
18         
19         async void CastTest ()
20         {
21                 var res = (int) await async ();
22                 var res2 = (Int32) await async ();
23         }
24
25         public static int Main ()
26         {
27                 return 0;
28         }
29 }
30
31 class B
32 {
33         class async
34         {
35                 async (async arg)
36                 {
37                 }
38         }
39 }
40
41 class C
42 {
43         static void Test (bool async)
44         {
45                 var a = async ? Prop : 2;
46         }
47
48         static int Prop {
49                 get {
50                         return 3;
51                 }
52         }
53 }
54
55 class async
56 {
57         async (async arg)
58         {
59                 int await = 0;
60         }
61 }
62
63 class await
64 {
65         await (await arg)
66         {
67         }
68 }
69
70 [async]
71 class asyncAttribute: Attribute
72 {
73         delegate async async (async async);
74 }
75
76 namespace AsyncNS
77 {
78         class Classes
79         {
80                 class async
81                 {
82                 }
83                 
84                 void M ()
85                 {
86                         async local;
87                 }
88         }
89
90         namespace Namespaces
91         {
92                 namespace async { }
93         }
94 }
95
96 namespace AwaitNS
97 {
98         class Formals
99         {
100                 delegate void D (int x);
101                 static void M1 ()
102                 {
103                         D d1 = await => { };
104                         D d2 = (int await) => { };
105                         D d3 = delegate (int await) { };
106                 }
107         }
108
109         class Methods
110         {
111                 void await () { }
112                 void M (Methods m)
113                 {
114                         m.await ();
115                         this.await ();
116                         // FIXME: await ();
117                 }
118         }
119
120         class Classes
121         {
122                 class await { }
123                 void M ()
124                 {
125                         // FIXME: @await local = new @await ();
126                 }
127         }
128
129         class AnonTypes
130         {
131                 static void M ()
132                 {
133                         var x = new { await = 1 };
134                         var y = x.await;
135                         int await = 2;
136                         var x2 = new { await };
137                 }
138         }
139
140         class Initializer
141         {
142                 int await;
143
144                 static void M ()
145                 {
146                         var a = new Initializer () {
147                                 await = 2
148                         };
149                 }
150         }
151 }