linux-packaging-mono/mcs/tests/test-ex-filter-05.cs
Jo Shields fe777c5c82 Imported Upstream version 3.8.0
Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
2014-09-04 09:07:35 +01:00

40 lines
706 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) if (Verify (() => ex.Message == "foo")) {
await Task.Yield ();
Console.WriteLine (ex);
return 1;
} catch (Exception ex) if (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;
}
}