Browse Source

Add roundtrip test case for ICSharpCode.Decompiler and pretty tests for Async and YieldReturn

pull/728/merge
Siegfried Pammer 9 years ago
parent
commit
f6c60a6223
  1. 2
      ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 12
      ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs
  3. 10
      ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs
  4. 20
      ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs
  5. 0
      ICSharpCode.Decompiler/Tests/TestCases/Pretty/YieldReturn.cs

2
ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj

@ -127,6 +127,7 @@ @@ -127,6 +127,7 @@
<Compile Include="Loops.cs" />
<Compile Include="PrettyTestRunner.cs" />
<Compile Include="RoundtripAssembly.cs" />
<Compile Include="TestCases\Pretty\Async.cs" />
<Compile Include="TestCases\Correctness\CompoundAssignment.cs" />
<Compile Include="TestCases\Correctness\ConditionalAttr.cs" />
<Compile Include="TestCases\Correctness\ControlFlow.cs" />
@ -143,6 +144,7 @@ @@ -143,6 +144,7 @@
<Compile Include="TestCases\Correctness\UnsafeCode.cs" />
<Compile Include="TestCases\Correctness\ValueTypeCall.cs" />
<Compile Include="CorrectnessTestRunner.cs" />
<Compile Include="TestCases\Pretty\YieldReturn.cs" />
<Compile Include="TestCases\Pretty\CompoundAssignmentTest.cs" />
<Compile Include="TestCases\Pretty\ExceptionHandling.cs" />
<Compile Include="TestCases\Pretty\HelloWorld.cs" />

12
ICSharpCode.Decompiler/Tests/PrettyTestRunner.cs

@ -94,6 +94,18 @@ namespace ICSharpCode.Decompiler.Tests @@ -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);

10
ICSharpCode.Decompiler/Tests/RoundtripAssembly.cs

@ -52,6 +52,16 @@ namespace ICSharpCode.Decompiler.Tests @@ -52,6 +52,16 @@ namespace ICSharpCode.Decompiler.Tests
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()
{

20
ICSharpCode.Decompiler/Tests/Async.cs → ICSharpCode.Decompiler/Tests/TestCases/Pretty/Async.cs

@ -134,6 +134,26 @@ public class Async @@ -134,6 +134,26 @@ public class Async
}
}
public async Task AwaitCatch(Task<int> task)
{
try {
Console.WriteLine("Before throw");
throw new Exception();
} catch {
Console.WriteLine(await task);
}
}
public async Task AwaitFinally(Task<int> task)
{
try {
Console.WriteLine("Before throw");
throw new Exception();
} finally {
Console.WriteLine(await task);
}
}
public async Task<int> NestedAwait(Task<Task<int>> task)
{
return await(await task);

0
ICSharpCode.Decompiler/Tests/YieldReturn.cs → ICSharpCode.Decompiler/Tests/TestCases/Pretty/YieldReturn.cs

Loading…
Cancel
Save