[mono-api-html] Add solution.
[mono.git] / mcs / tests / test-async-30.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Threading.Tasks;
4
5 class C
6 {
7         private IEnumerable<string> Test (string s)
8         {
9                 Func<Task<string>> a = async () => await Task.FromResult(s + "a");
10                 yield return a ().Result;
11         }
12         
13         private IEnumerable<string> Test2 ()
14         {
15                 var s = "bb";
16                 Func<Task<string>> a = async () => await Task.FromResult(s + "a");
17                 yield return a ().Result;
18         }
19
20         public static int Main ()
21         {
22                 var c = new C ();
23                 string res = "";
24                 foreach (var e in c.Test ("tt"))
25                         res += e;
26                 
27                 if (res != "tta")
28                         return 1;
29                 
30                 res = "";
31                 foreach (var e in c.Test2 ())
32                         res += e;
33                 
34                 if (res != "bba")
35                         return 2;
36
37                 return 0;
38         }
39 }