Permalink
Browse files

Use mcs for correctness tests.

  • Loading branch information...
dgrunwald committed Feb 26, 2018
1 parent 6769921 commit 3fae36dab9d572eabe3864a835191b2f203ede46
@@ -46,16 +46,16 @@ public void AllFilesHaveTests()
}
}
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 @@ public void FloatingPointArithmetic([ValueSource("defaultOptions")] CompilerOpti
}
[Test]
public void HelloWorld([ValueSource("defaultOptionsWithMcs")] CompilerOptions options)
public void HelloWorld([ValueSource("defaultOptions")] CompilerOptions options)
{
RunCS(options: options);
}
@@ -115,6 +115,9 @@ public void PropertiesAndEvents([ValueSource("defaultOptions")] CompilerOptions
[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 @@ public void Using([ValueSource("defaultOptions")] CompilerOptions options)
[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 @@ public void DecimalFields([ValueSource("defaultOptions")] CompilerOptions option
}
[Test]
public void UndocumentedExpressions([ValueSource("defaultOptions")] CompilerOptions options)
public void UndocumentedExpressions([ValueSource("noMonoOptions")] CompilerOptions options)
{
RunCS(options: options);
}
@@ -223,6 +229,9 @@ public void StackTypes([Values(false, true)] bool force32Bit)
[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 @@ public void Capturing([ValueSource("defaultOptions")] CompilerOptions options)
[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 @@ public void Async([Values(CompilerOptions.None, CompilerOptions.Optimize)] Compi
[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);
}
@@ -172,12 +172,15 @@ public static List<string> GetPreprocessorSymbols(CompilerOptions flags)
}
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,13 +242,18 @@ public static CompilerResults CompileCSharp(string sourceFileName, CompilerOptio
} 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) + '"'))}";
info.RedirectStandardError = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Console.WriteLine($"\"{info.FileName}\" {info.Arguments}");
Process process = Process.Start(info);
var outputTask = process.StandardOutput.ReadToEndAsync();
@@ -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" />
@@ -21,7 +21,6 @@
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 @@ public async Task Run()
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 @@ public async Task TaskMethodWithoutAwaitButWithExceptionHandling()
}
}
#if !LEGACY_CSC
#if CS60
public async Task AwaitCatch(Task<int> task)
{
try {
@@ -155,7 +154,7 @@ public async Task AwaitWithStack2(Task<int> task)
}
}
#if !LEGACY_CSC
#if CS60
public async Task AwaitInCatch(Task<int> task1, Task<int> task2)
{
try {
@@ -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
{
@@ -136,7 +136,7 @@ static void CallTwice()
static void UnsignedShiftRightInstanceField()
{
#if !LEGACY_CSC
#if CS70
ref int f = ref new CompoundAssignment().instanceField;
Test(X(), f = (int)((uint)f >> 2));
#endif
@@ -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
{
@@ -609,7 +609,7 @@ static string GetString()
return "Test";
}
#if !LEGACY_CSC
#if CS60
public static void SimpleDictInitializer()
{
InitializerTests.X(InitializerTests.Y(), new InitializerTests.Data {
@@ -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
{
@@ -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 @@ public CtorTestObj(int i, params object[] items)
#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");
}
@@ -55,9 +55,12 @@ static void Main()
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");
}
@@ -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 @@ public bool SimpleTryCatchExceptionWithName()
return false;
}
#if !LEGACY_CSC
#if CS60
public bool SimpleTryCatchExceptionWithNameAndCondition()
{
try {
@@ -349,7 +349,7 @@ private static void NoOp(Guid?[] array)
}
#if !LEGACY_CSC
#if CS60
public static void SimpleDictInitializer()
{
InitializerTests.X(InitializerTests.Y(), new Data {
@@ -40,6 +40,7 @@ void IDisposable.Dispose()
}
#if LEGACY_CSC
// roslyn optimizes out the try-finally; mcs has a compiler bug on using(null-literal)
public void SimpleUsingNullStatement()
{
using (null) {

0 comments on commit 3fae36d

Please sign in to comment.