Browse Source

Use mcs for correctness tests.

pull/1087/head
Daniel Grunwald 7 years ago
parent
commit
3fae36dab9
  1. 30
      ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
  2. 14
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  3. 4
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  4. 9
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs
  5. 3
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Capturing.cs
  6. 2
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs
  7. 24
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/ExpressionTrees.cs
  8. 2
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs
  9. 4
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs
  10. 8
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs
  11. 3
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs
  12. 4
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs
  13. 2
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
  14. 1
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs
  15. 2
      ILSpy-tests

30
ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs

@ -46,16 +46,16 @@ namespace ICSharpCode.Decompiler.Tests @@ -46,16 +46,16 @@ namespace ICSharpCode.Decompiler.Tests
}
}
static readonly CompilerOptions[] defaultOptions =
static readonly CompilerOptions[] noMonoOptions =
{
CompilerOptions.None,
CompilerOptions.Optimize,
CompilerOptions.UseRoslyn,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn
CompilerOptions.Optimize | CompilerOptions.UseRoslyn,
};
static readonly CompilerOptions[] defaultOptionsWithMcs =
{
static readonly CompilerOptions[] defaultOptions =
{
CompilerOptions.None,
CompilerOptions.Optimize,
CompilerOptions.UseRoslyn,
@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
public void HelloWorld([ValueSource("defaultOptionsWithMcs")] CompilerOptions options)
public void HelloWorld([ValueSource("defaultOptions")] CompilerOptions options)
{
RunCS(options: options);
}
@ -115,6 +115,9 @@ namespace ICSharpCode.Decompiler.Tests @@ -115,6 +115,9 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void Switch([ValueSource("defaultOptions")] CompilerOptions options)
{
if (options.HasFlag(CompilerOptions.UseMcs)) {
Assert.Ignore("Decompiler bug with mono!");
}
RunCS(options: options);
}
@ -127,6 +130,9 @@ namespace ICSharpCode.Decompiler.Tests @@ -127,6 +130,9 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void Loops([ValueSource("defaultOptions")] CompilerOptions options)
{
if (options.HasFlag(CompilerOptions.UseMcs)) {
Assert.Ignore("Decompiler bug with mono!");
}
RunCS(options: options);
}
@ -161,7 +167,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -161,7 +167,7 @@ namespace ICSharpCode.Decompiler.Tests
}
[Test]
public void UndocumentedExpressions([ValueSource("defaultOptions")] CompilerOptions options)
public void UndocumentedExpressions([ValueSource("noMonoOptions")] CompilerOptions options)
{
RunCS(options: options);
}
@ -223,6 +229,9 @@ namespace ICSharpCode.Decompiler.Tests @@ -223,6 +229,9 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void UnsafeCode([ValueSource("defaultOptions")] CompilerOptions options)
{
if (options.HasFlag(CompilerOptions.UseMcs)) {
Assert.Ignore("Decompiler bug with mono!");
}
RunCS(options: options);
}
@ -247,6 +256,9 @@ namespace ICSharpCode.Decompiler.Tests @@ -247,6 +256,9 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void YieldReturn([ValueSource("defaultOptions")] CompilerOptions options)
{
if (options.HasFlag(CompilerOptions.UseMcs)) {
Assert.Ignore("Decompiler bug with mono!");
}
RunCS(options: options);
}
@ -259,12 +271,18 @@ namespace ICSharpCode.Decompiler.Tests @@ -259,12 +271,18 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void LINQRaytracer([ValueSource("defaultOptions")] CompilerOptions options)
{
if (options.HasFlag(CompilerOptions.UseMcs)) {
Assert.Ignore("Decompiler bug with mono!");
}
RunCS(options: options);
}
[Test]
public void MiniJSON([ValueSource("defaultOptions")] CompilerOptions options)
{
if (options.HasFlag(CompilerOptions.UseMcs)) {
Assert.Ignore("Decompiler bug with mono!");
}
RunCS(options: options);
}

14
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -172,12 +172,15 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -172,12 +172,15 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
}
if (flags.HasFlag(CompilerOptions.UseRoslyn)) {
preprocessorSymbols.Add("ROSLYN");
preprocessorSymbols.Add("CS60");
preprocessorSymbols.Add("CS70");
preprocessorSymbols.Add("CS71");
preprocessorSymbols.Add("CS72");
} else if (flags.HasFlag(CompilerOptions.UseMcs)) {
preprocessorSymbols.Add("MCS");
} else {
preprocessorSymbols.Add("LEGACY_CSC");
}
if (flags.HasFlag(CompilerOptions.UseMcs)) {
preprocessorSymbols.Add("MONO_MCS");
}
return preprocessorSymbols;
}
@ -239,6 +242,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -239,6 +242,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
} else {
otherOptions += "-platform:anycpu ";
}
if (preprocessorSymbols.Count > 0) {
otherOptions += " \"-d:" + string.Join(";", preprocessorSymbols) + "\" ";
}
ProcessStartInfo info = new ProcessStartInfo(mcsPath);
info.Arguments = $"{otherOptions}-out:\"{Path.GetFullPath(results.PathToAssembly)}\" {string.Join(" ", sourceFileNames.Select(fn => '"' + Path.GetFullPath(fn) + '"'))}";
@ -246,6 +252,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers @@ -246,6 +252,8 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Console.WriteLine($"\"{info.FileName}\" {info.Arguments}");
Process process = Process.Start(info);
var outputTask = process.StandardOutput.ReadToEndAsync();

4
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -31,6 +31,10 @@ @@ -31,6 +31,10 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG;NET46;ROSLYN;CS60;CS70</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DiffLib" Version="1.0.0.55" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.0" />

9
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Async.cs

@ -21,7 +21,6 @@ using System; @@ -21,7 +21,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
@ -40,14 +39,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -40,14 +39,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
StreamCopyToWithConfigureAwait(new MemoryStream(new byte[1024]), 16);
await AwaitInForEach(Enumerable.Range(0, 100).Select(i => Task.FromResult(i)));
await TaskMethodWithoutAwaitButWithExceptionHandling();
#if !LEGACY_CSC
#if CS60
await AwaitCatch(Task.FromResult(1));
await AwaitFinally(Task.FromResult(2));
#endif
await NestedAwait(Task.FromResult(Task.FromResult(5)));
await AwaitWithStack(Task.FromResult(3));
await AwaitWithStack2(Task.FromResult(4));
#if !LEGACY_CSC
#if CS60
await AwaitInCatch(Task.FromResult(1), Task.FromResult(2));
await AwaitInFinally(Task.FromResult(2), Task.FromResult(4));
#endif
@ -113,7 +112,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -113,7 +112,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
}
}
#if !LEGACY_CSC
#if CS60
public async Task AwaitCatch(Task<int> task)
{
try {
@ -155,7 +154,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -155,7 +154,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
}
}
#if !LEGACY_CSC
#if CS60
public async Task AwaitInCatch(Task<int> task1, Task<int> task2)
{
try {

3
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Capturing.cs

@ -1,8 +1,5 @@ @@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{

2
ICSharpCode.Decompiler.Tests/TestCases/Correctness/CompoundAssignment.cs

@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
static void UnsignedShiftRightInstanceField()
{
#if !LEGACY_CSC
#if CS70
ref int f = ref new CompoundAssignment().instanceField;
Test(X(), f = (int)((uint)f >> 2));
#endif

24
ICSharpCode.Decompiler.Tests/TestCases/Correctness/ExpressionTrees.cs

@ -1,9 +1,23 @@ @@ -1,9 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{

2
ICSharpCode.Decompiler.Tests/TestCases/Correctness/InitializerTests.cs

@ -609,7 +609,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -609,7 +609,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
return "Test";
}
#if !LEGACY_CSC
#if CS60
public static void SimpleDictInitializer()
{
InitializerTests.X(InitializerTests.Y(), new InitializerTests.Data {

4
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Loops.cs

@ -19,10 +19,6 @@ @@ -19,10 +19,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{

8
ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs

@ -17,10 +17,6 @@ @@ -17,10 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
@ -74,13 +70,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -74,13 +70,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
#region params with nulls
static void TestParamsMethod()
{
TestCall(1, null, (TypeAccessException)null);
TestCall(1, null, (NullReferenceException)null);
TestCall(2, null, (AccessViolationException)null);
TestCall(3, null);
TestCall(3, null, null, null);
}
static void TestCall(int v, Type p1, TypeAccessException p2)
static void TestCall(int v, Type p1, NullReferenceException p2)
{
Console.WriteLine("TestCall without params");
}

3
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs

@ -55,9 +55,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -55,9 +55,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
public static void SimpleUsingNullStatement()
{
Console.WriteLine("before using");
// Mono has a compiler bug and introduces an assembly reference to [gmcs] here...
#if !MCS
using (null) {
Console.WriteLine("using (null)");
}
#endif
Console.WriteLine("after using");
}

4
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
#if !LEGACY_CSC
#if CS60
using System.IO;
#endif
using System.Threading;
@ -64,7 +64,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -64,7 +64,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return false;
}
#if !LEGACY_CSC
#if CS60
public bool SimpleTryCatchExceptionWithNameAndCondition()
{
try {

2
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs

@ -349,7 +349,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -349,7 +349,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
#if !LEGACY_CSC
#if CS60
public static void SimpleDictInitializer()
{
InitializerTests.X(InitializerTests.Y(), new Data {

1
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Using.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -40,6 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
#if LEGACY_CSC
// roslyn optimizes out the try-finally; mcs has a compiler bug on using(null-literal)
public void SimpleUsingNullStatement()
{
using (null) {

2
ILSpy-tests

@ -1 +1 @@ @@ -1 +1 @@
Subproject commit 2c480d5f589e3f2acb96cd3efa67f608af25a05c
Subproject commit 4ed2643065a15d4440971fe2a5409cdeba6aaeac
Loading…
Cancel
Save