linux-packaging-mono/mcs/tests/test-ex-filter-05.cs
Jo Shields 3c1f479b9d Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
2015-04-07 09:35:12 +01:00

40 lines
710 B
C#

using System;
using System.Threading.Tasks;
class Test
{
static bool Verify (Func<bool> f)
{
return f ();
}
static async Task<int> TestCapturedException (Exception e)
{
try {
if (e != null)
throw e;
} catch (Exception ex) when (Verify (() => ex.Message == "foo")) {
await Task.Yield ();
Console.WriteLine (ex);
return 1;
} catch (Exception ex) when (Verify (() => ex.Message != null)) {
await Task.Yield ();
Console.WriteLine (ex);
return 2;
}
return 3;
}
public static int Main()
{
if (TestCapturedException (null).Result != 3)
return 1;
var ex = new ApplicationException ();
if (TestCapturedException (ex).Result != 2)
return 2;
return 0;
}
}