2 using System
.Threading
.Tasks
;
3 using System
.Threading
;
4 using System
.Reflection
;
6 using System
.Collections
.Generic
;
17 async Task
<bool> Add_1 ()
20 int total
= d
+ await Task
.Factory
.StartNew (() => 2);
24 async Task
<bool> AssignCompound_1 ()
26 dynamic d
= new Base ();
28 d
.Value
+= await Task
.Factory
.StartNew (() => 2);
32 async Task
<bool> Convert_1 ()
34 string s
= await Task
.Factory
.StartNew (() => (dynamic) "x");
38 async Task
<bool> Invocation_1 ()
40 var r
= (await Task
.Factory
.StartNew (() => (dynamic) "x|y|z")).Split ('|');
44 static bool RunTest (MethodInfo test
)
46 Console
.Write ("Running test {0, -25}", test
.Name
);
48 Task t
= test
.Invoke (new Tester (), null) as Task
;
49 if (!Task
.WaitAll (new[] { t }
, 1000)) {
50 Console
.WriteLine ("FAILED (Timeout)");
54 var tb
= t
as Task
<bool>;
57 Console
.WriteLine ("FAILED (Result={0})", tb
.Result
);
62 Console
.WriteLine ("OK");
64 } catch (Exception e
) {
65 Console
.WriteLine ("FAILED");
66 Console
.WriteLine (e
.ToString ());
71 public static int Main ()
73 var tests
= from test
in typeof (Tester
).GetMethods (BindingFlags
.Instance
| BindingFlags
.NonPublic
| BindingFlags
.DeclaredOnly
)
74 where test
.GetParameters ().Length
== 0
76 select RunTest (test
);
78 int failures
= tests
.Count (a
=> !a
);
79 Console
.WriteLine (failures
+ " tests failed");