提交 fa5ff6d0 编写于 作者: V VSadov

Added more tests.

上级 e87ce86f
......@@ -1261,12 +1261,13 @@ static async Task<int> G()
}
catch
{
Console.WriteLine(""rethrowing"");
throw;
}
}
catch(DivideByZeroException ex)
{
x = await F();
x += await F();
System.Console.WriteLine(ex.Message);
}
......@@ -1290,13 +1291,87 @@ public static void Main()
}
}
}";
var expected = @"
var expected = @"rethrowing
Attempted to divide by zero.
2
";
CompileAndVerify(source, expectedOutput: expected);
}
[WorkItem(74, "https://github.com/dotnet/roslyn/issues/1334")]
[Fact]
public void AsyncInCatchRethrow02()
{
var source = @"
using System;
using System.Threading.Tasks;
class Test
{
static async Task<int> F()
{
await Task.Yield();
return 2;
}
static async Task<int> G()
{
int x = 0;
try
{
try
{
x = x / x;
}
catch (ArgumentNullException)
{
Console.WriteLine(""should not get here"");
}
catch (Exception ex) when (ex == null)
{
Console.WriteLine(""should not get here"");
}
catch
{
x = await F();
Console.WriteLine(""rethrowing"");
throw;
}
}
catch(DivideByZeroException ex)
{
x += await F();
System.Console.WriteLine(ex.Message);
}
return x;
}
public static void Main()
{
System.Globalization.CultureInfo saveUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
try
{
Task<int> t2 = G();
t2.Wait(1000 * 60);
Console.WriteLine(t2.Result);
}
finally
{
System.Threading.Thread.CurrentThread.CurrentUICulture = saveUICulture;
}
}
}";
var expected = @"rethrowing
Attempted to divide by zero.
4
";
CompileAndVerify(source, expectedOutput: expected);
}
[Fact]
public void AsyncInCatchFilter()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册