From f6c60a6223f0afa0aecbb858ebfdcbcf9926ce05 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 26 Nov 2016 15:26:20 +0100 Subject: [PATCH] Add roundtrip test case for ICSharpCode.Decompiler and pretty tests for Async and YieldReturn --- .../Tests/ICSharpCode.Decompiler.Tests.csproj | 2 ++ .../Tests/PrettyTestRunner.cs | 12 ++++++++++ .../Tests/RoundtripAssembly.cs | 14 ++++++++++-- .../Tests/{ => TestCases/Pretty}/Async.cs | 22 ++++++++++++++++++- .../{ => TestCases/Pretty}/YieldReturn.cs | 0 5 files changed, 47 insertions(+), 3 deletions(-) rename ICSharpCode.Decompiler/Tests/{ => TestCases/Pretty}/Async.cs (91%) rename ICSharpCode.Decompiler/Tests/{ => TestCases/Pretty}/YieldReturn.cs (100%) diff --git a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj index 8904837dd..d7e8fbe8d 100644 --- a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj @@ -127,6 +127,7 @@ + @@ -143,6 +144,7 @@ + diff --git a/ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs index c3aceb3d0..cfff155f2 100644 --- a/ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs @@ -94,6 +94,18 @@ namespace ICSharpCode.Decompiler.Tests Run(cscOptions: cscOptions); } + [Test, Ignore("Not implemented")] + public void Async([ValueSource("defaultOptions")] CompilerOptions cscOptions) + { + Run(cscOptions: cscOptions); + } + + [Test, Ignore("Not implemented")] + public void YieldReturn([ValueSource("defaultOptions")] CompilerOptions cscOptions) + { + Run(cscOptions: cscOptions); + } + void Run([CallerMemberName] string testName = null, AssemblerOptions asmOptions = AssemblerOptions.None, CompilerOptions cscOptions = CompilerOptions.None) { var ilFile = Path.Combine(TestCasePath, testName); diff --git a/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs b/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs index 8917d3046..4193bebd9 100644 --- a/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs +++ b/ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs @@ -45,13 +45,23 @@ namespace ICSharpCode.Decompiler.Tests { RunWithTest("Newtonsoft.Json-net40", "Newtonsoft.Json.dll", "Newtonsoft.Json.Tests.dll"); } - + [Test] public void NRefactory_CSharp() { RunWithTest("NRefactory", "ICSharpCode.NRefactory.CSharp.dll", "ICSharpCode.NRefactory.Tests.dll"); } - + + [Test] + public void ICSharpCode_Decompiler() + { + try { + RunWithTest("ICSharpCode.Decompiler", "ICSharpCode.Decompiler.dll", "ICSharpCode.Decompiler.Tests.dll"); + } catch (CompilationFailedException) { + Assert.Ignore("Ignored because yield return is not yet implemented!"); + } + } + [Test] public void ImplicitConversions() { diff --git a/ICSharpCode.Decompiler/Tests/Async.cs b/ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs similarity index 91% rename from ICSharpCode.Decompiler/Tests/Async.cs rename to ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs index 910da5aeb..d67701b52 100644 --- a/ICSharpCode.Decompiler/Tests/Async.cs +++ b/ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs @@ -133,7 +133,27 @@ public class Async Console.WriteLine("Crash"); } } - + + public async Task AwaitCatch(Task task) + { + try { + Console.WriteLine("Before throw"); + throw new Exception(); + } catch { + Console.WriteLine(await task); + } + } + + public async Task AwaitFinally(Task task) + { + try { + Console.WriteLine("Before throw"); + throw new Exception(); + } finally { + Console.WriteLine(await task); + } + } + public async Task NestedAwait(Task> task) { return await(await task); diff --git a/ICSharpCode.Decompiler/Tests/YieldReturn.cs b/ICSharpCode.Decompiler/Tests/TestCases/Pretty/YieldReturn.cs similarity index 100% rename from ICSharpCode.Decompiler/Tests/YieldReturn.cs rename to ICSharpCode.Decompiler/Tests/TestCases/Pretty/YieldReturn.cs