linux-packaging-mono/mcs/tests/test-async-03.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

61 lines
801 B
C#

using System.Runtime.CompilerServices;
using System.Threading.Tasks;
static class S
{
public static A GetAwaiter (this int i)
{
return new A ();
}
}
class A : INotifyCompletion
{
bool IsCompleted {
get {
return true;
}
}
void INotifyCompletion.OnCompleted (System.Action a)
{
}
int GetResult ()
{
return 3;
}
static async Task<int> Test1 ()
{
await checked (1);
return await checked (2);
}
static async Task<int> Test2 ()
{
await checked (1);
return 4;
}
static async Task Test3 ()
{
await checked (1);
}
public static int Main ()
{
var r = Test1 ();
System.Console.WriteLine (r.Result);
if (r.Result != 3)
return 1;
r = Test2 ();
System.Console.WriteLine (r.Result);
if (r.Result != 4)
return 2;
Test3();
return 0;
}
}