Browse Source

Move correctness tests to single namespace

pull/728/merge
Siegfried Pammer 9 years ago
parent
commit
f24f1e007e
  1. 6
      ICSharpCode.Decompiler/Tests/CorrectnessTestRunner.cs
  2. 1
      ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
  3. 41
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/Capturing.cs
  4. 2
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/Comparisons.cs
  5. 9
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/CompoundAssignment.cs
  6. 1
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/ConditionalAttr.cs
  7. 3
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/ControlFlow.cs
  8. 2
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/Conversions.cs
  9. 2
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/DecimalFields.cs
  10. 2
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/Generics.cs
  11. 2
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/HelloWorld.cs
  12. 3
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/InitializerTests.cs
  13. 2
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/MemberLookup.cs
  14. 4
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/PropertiesAndEvents.cs
  15. 4
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/Switch.cs
  16. 3
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/UndocumentedExpressions.cs
  17. 33
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/UnsafeCode.cs
  18. 6
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/ValueTypeCall.cs

6
ICSharpCode.Decompiler/Tests/CorrectnessTestRunner.cs

@ -156,6 +156,12 @@ namespace ICSharpCode.Decompiler.Tests
RunCS(options: options); RunCS(options: options);
} }
[Test]
public void Capturing([ValueSource("defaultOptions")] CompilerOptions options)
{
RunCS(options: options);
}
void RunCS([CallerMemberName] string testName = null, CompilerOptions options = CompilerOptions.UseDebug) void RunCS([CallerMemberName] string testName = null, CompilerOptions options = CompilerOptions.UseDebug)
{ {
string testFileName = testName + ".cs"; string testFileName = testName + ".cs";

1
ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj

@ -126,6 +126,7 @@
<Compile Include="Helpers\TypeSystemHelper.cs" /> <Compile Include="Helpers\TypeSystemHelper.cs" />
<Compile Include="PrettyTestRunner.cs" /> <Compile Include="PrettyTestRunner.cs" />
<Compile Include="RoundtripAssembly.cs" /> <Compile Include="RoundtripAssembly.cs" />
<Compile Include="TestCases\Correctness\Capturing.cs" />
<Compile Include="TestCases\Correctness\OverloadResolution.cs" /> <Compile Include="TestCases\Correctness\OverloadResolution.cs" />
<Compile Include="TestCases\Pretty\AnonymousTypes.cs" /> <Compile Include="TestCases\Pretty\AnonymousTypes.cs" />
<Compile Include="TestCases\Pretty\Async.cs" /> <Compile Include="TestCases\Pretty\Async.cs" />

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

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
class Capturing
{
static void Main(string[] args)
{
TestCase1();
}
static void TestCase1()
{
Console.WriteLine("TestCase1");
for (int i = 0; i < 10; i++)
Console.WriteLine(i);
// i no longer declared
List<Action> actions = new List<Action>();
int max = 5;
string line;
while (ReadLine(out line, ref max)) {
actions.Add(() => Console.WriteLine(line));
}
// line still declared
line = null;
Console.WriteLine("----");
foreach (var action in actions)
action();
}
private static bool ReadLine(out string line, ref int v)
{
line = v + " line";
return --v > 0;
}
}
}

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

@ -20,7 +20,7 @@ using System;
#pragma warning disable 652 #pragma warning disable 652
namespace ICSharpCode.Decompiler.Tests.TestCases namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
public class Comparisons public class Comparisons
{ {

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

@ -19,6 +19,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
class CompoundAssignment class CompoundAssignment
{ {
static void Main() static void Main()
@ -41,7 +43,8 @@ class CompoundAssignment
int instanceField; int instanceField;
public int InstanceProperty { public int InstanceProperty
{
get { get {
Console.WriteLine("In get_InstanceProperty"); Console.WriteLine("In get_InstanceProperty");
return instanceField; return instanceField;
@ -54,7 +57,8 @@ class CompoundAssignment
static int staticField; static int staticField;
public static int StaticProperty { public static int StaticProperty
{
get { get {
Console.WriteLine("In get_StaticProperty"); Console.WriteLine("In get_StaticProperty");
return staticField; return staticField;
@ -90,3 +94,4 @@ class CompoundAssignment
Test(X(), ++GetDict()[GetString()]); Test(X(), ++GetDict()[GetString()]);
} }
} }
}

1
ICSharpCode.Decompiler/Tests/TestCases/Correctness/ConditionalAttr.cs

@ -5,7 +5,6 @@ using System.Diagnostics;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
class ConditionalAttr class ConditionalAttr
{ {
[Conditional("PRINT")] [Conditional("PRINT")]

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

@ -18,6 +18,8 @@
using System; using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
class ControlFlow class ControlFlow
{ {
public static int Main() public static int Main()
@ -103,3 +105,4 @@ class ControlFlow
return -1; return -1;
} }
} }
}

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

@ -21,7 +21,7 @@
using System; using System;
using ICSharpCode.Decompiler.Util; using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.Tests.TestCases namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
public class Conversions public class Conversions
{ {

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

@ -18,7 +18,7 @@
using System; using System;
namespace ICSharpCode.Decompiler.Tests.TestCases namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
/// <summary> /// <summary>
/// Description of DecimalFields. /// Description of DecimalFields.

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

@ -18,7 +18,7 @@
using System; using System;
namespace Generics namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
/// <summary> /// <summary>
/// Description of Generics. /// Description of Generics.

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

@ -18,7 +18,7 @@
using System; using System;
namespace HelloWorld namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
class HelloWorld class HelloWorld
{ {

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

@ -19,6 +19,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public class InitializerTests public class InitializerTests
{ {
public static int Main() public static int Main()
@ -894,3 +896,4 @@ public class InitializerTests
}; };
} }
} }
}

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

@ -18,7 +18,7 @@
using System; using System;
namespace ICSharpCode.Decompiler.Tests.TestCases namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
public class MemberLookup public class MemberLookup
{ {

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

@ -1,8 +1,8 @@
using System; using System;
namespace PropertiesAndEvents namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
class Program class PropertiesAndEvents
{ {
public static int Main(string[] args) public static int Main(string[] args)
{ {

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

@ -18,6 +18,8 @@
using System; using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public static class Switch public static class Switch
{ {
public static void Main() public static void Main()
@ -145,4 +147,4 @@ public static class Switch
} }
} }
} }
}

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

@ -18,6 +18,8 @@
using System; using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public class UndocumentedExpressions public class UndocumentedExpressions
{ {
static void Main(string[] args) static void Main(string[] args)
@ -63,3 +65,4 @@ public class UndocumentedExpressions
__refvalue(tr, object) = 1; __refvalue(tr, object) = 1;
} }
} }
}

33
ICSharpCode.Decompiler/Tests/TestCases/Correctness/UnsafeCode.cs

@ -18,6 +18,8 @@
using System; using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public class UnsafeCode public class UnsafeCode
{ {
struct SimpleStruct struct SimpleStruct
@ -34,8 +36,7 @@ public class UnsafeCode
public unsafe int* NullPointer public unsafe int* NullPointer
{ {
get get {
{
return null; return null;
} }
} }
@ -67,8 +68,7 @@ public class UnsafeCode
public unsafe void PassRefParameterAsPointer(ref int p) public unsafe void PassRefParameterAsPointer(ref int p)
{ {
fixed (int* ptr = &p) fixed (int* ptr = &p) {
{
this.PassPointerAsRefParameter(ptr); this.PassPointerAsRefParameter(ptr);
} }
} }
@ -80,8 +80,7 @@ public class UnsafeCode
public unsafe void AddressInMultiDimensionalArray(double[,] matrix) public unsafe void AddressInMultiDimensionalArray(double[,] matrix)
{ {
fixed (double* ptr = &matrix[1, 2]) fixed (double* ptr = &matrix[1, 2]) {
{
this.PointerReferenceExpression(ptr); this.PointerReferenceExpression(ptr);
this.PointerReferenceExpression(ptr); this.PointerReferenceExpression(ptr);
} }
@ -89,8 +88,7 @@ public class UnsafeCode
public unsafe int MultipleExitsOutOfFixedBlock(int[] arr) public unsafe int MultipleExitsOutOfFixedBlock(int[] arr)
{ {
fixed (int* ptr = &arr[0]) fixed (int* ptr = &arr[0]) {
{
if (*ptr < 0) if (*ptr < 0)
return *ptr; return *ptr;
if (*ptr == 21) if (*ptr == 21)
@ -106,11 +104,9 @@ public class UnsafeCode
public unsafe void FixedStringAccess(string text) public unsafe void FixedStringAccess(string text)
{ {
fixed (char* ptr = text) fixed (char* ptr = text) {
{
char* ptr2 = ptr; char* ptr2 = ptr;
while (*ptr2 != '\0') while (*ptr2 != '\0') {
{
*ptr2 = 'A'; *ptr2 = 'A';
ptr2++; ptr2++;
} }
@ -119,16 +115,14 @@ public class UnsafeCode
public unsafe void PutDoubleIntoLongArray1(long[] array, int index, double val) public unsafe void PutDoubleIntoLongArray1(long[] array, int index, double val)
{ {
fixed (long* ptr = array) fixed (long* ptr = array) {
{
((double*)ptr)[index] = val; ((double*)ptr)[index] = val;
} }
} }
public unsafe void PutDoubleIntoLongArray2(long[] array, int index, double val) public unsafe void PutDoubleIntoLongArray2(long[] array, int index, double val)
{ {
fixed (long* ptr = &array[index]) fixed (long* ptr = &array[index]) {
{
*(double*)ptr = val; *(double*)ptr = val;
} }
} }
@ -145,8 +139,7 @@ public class UnsafeCode
public unsafe void FixMultipleStrings(string text) public unsafe void FixMultipleStrings(string text)
{ {
fixed (char* ptr = text, userName = Environment.UserName, ptr2 = text) fixed (char* ptr = text, userName = Environment.UserName, ptr2 = text) {
{
*ptr = 'c'; *ptr = 'c';
*userName = 'd'; *userName = 'd';
*ptr2 = 'e'; *ptr2 = 'e';
@ -157,8 +150,7 @@ public class UnsafeCode
{ {
char* ptr = stackalloc char[count]; char* ptr = stackalloc char[count];
char* ptr2 = stackalloc char[100]; char* ptr2 = stackalloc char[100];
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
{
ptr[i] = (char)i; ptr[i] = (char)i;
} }
return this.PointerReferenceExpression((double*)ptr); return this.PointerReferenceExpression((double*)ptr);
@ -216,3 +208,4 @@ public class UnsafeCode
this.PassPointerAsRefParameter(this.NullPointer); this.PassPointerAsRefParameter(this.NullPointer);
} }
} }
}

6
ICSharpCode.Decompiler/Tests/TestCases/Correctness/ValueTypeCall.cs

@ -1,6 +1,6 @@
using System; using System;
namespace ValueTypeCall namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{ {
public struct MutValueType public struct MutValueType
{ {
@ -41,7 +41,7 @@ namespace ValueTypeCall
} }
} }
public class Program public class ValueTypeCall
{ {
public static void Main() public static void Main()
{ {
@ -52,7 +52,7 @@ namespace ValueTypeCall
Box(); Box();
var gvt = new GenericValueType<string>("Test"); var gvt = new GenericValueType<string>("Test");
gvt.Call(ref gvt); gvt.Call(ref gvt);
new Program().InstanceFieldTests(); new ValueTypeCall().InstanceFieldTests();
} }
static void RefParameter(ref MutValueType m) static void RefParameter(ref MutValueType m)

Loading…
Cancel
Save