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