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. 11
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/CompoundAssignment.cs
  6. 1
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/ConditionalAttr.cs
  7. 5
      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. 13
      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. 6
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/Switch.cs
  16. 5
      ICSharpCode.Decompiler/Tests/TestCases/Correctness/UndocumentedExpressions.cs
  17. 35
      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 @@ -156,6 +156,12 @@ namespace ICSharpCode.Decompiler.Tests
RunCS(options: options);
}
[Test]
public void Capturing([ValueSource("defaultOptions")] CompilerOptions options)
{
RunCS(options: options);
}
void RunCS([CallerMemberName] string testName = null, CompilerOptions options = CompilerOptions.UseDebug)
{
string testFileName = testName + ".cs";

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

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

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

@ -0,0 +1,41 @@ @@ -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; @@ -20,7 +20,7 @@ using System;
#pragma warning disable 652
namespace ICSharpCode.Decompiler.Tests.TestCases
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public class Comparisons
{

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

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

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

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

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

@ -18,8 +18,10 @@ @@ -18,8 +18,10 @@
using System;
class ControlFlow
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
class ControlFlow
{
public static int Main()
{
int result = 0;
@ -102,4 +104,5 @@ class ControlFlow @@ -102,4 +104,5 @@ class ControlFlow
return -1;
}
}
}

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

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

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

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

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

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

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

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

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

@ -19,14 +19,16 @@ @@ -19,14 +19,16 @@
using System;
using System.Collections.Generic;
public class InitializerTests
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public class InitializerTests
{
public static int Main()
{
int[,] test = new int[2,3];
test[0,0] = 0;
test[0,1] = 1;
test[0,2] = 2;
int[,] test = new int[2, 3];
test[0, 0] = 0;
test[0, 1] = 1;
test[0, 2] = 2;
int result = test.Length + test[0, 0] + test[0, 2];
Console.WriteLine(result);
return 0;
@ -893,4 +895,5 @@ public class InitializerTests @@ -893,4 +895,5 @@ public class InitializerTests
}
};
}
}
}

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

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

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

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

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

@ -18,8 +18,10 @@ @@ -18,8 +18,10 @@
using System;
public static class Switch
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public static class Switch
{
public static void Main()
{
TestCase(SparseIntegerSwitch, -100, 1, 2, 3, 4);
@ -144,5 +146,5 @@ public static class Switch @@ -144,5 +146,5 @@ public static class Switch
i++;
}
}
}
}

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

@ -18,8 +18,10 @@ @@ -18,8 +18,10 @@
using System;
public class UndocumentedExpressions
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
public class UndocumentedExpressions
{
static void Main(string[] args)
{
MakeTypedRef("abc");
@ -62,4 +64,5 @@ public class UndocumentedExpressions @@ -62,4 +64,5 @@ public class UndocumentedExpressions
Console.WriteLine("Type is: " + __reftype(tr).Name);
__refvalue(tr, object) = 1;
}
}
}

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

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

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

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

Loading…
Cancel
Save