Browse Source

Test both with and without optimizations

pull/205/head
Pent Ploompuu 15 years ago
parent
commit
85fbaf8255
  1. 12
      ICSharpCode.Decompiler/Tests/InitializerTests.cs
  2. 14
      ICSharpCode.Decompiler/Tests/TestRunner.cs

12
ICSharpCode.Decompiler/Tests/InitializerTests.cs

@ -532,9 +532,9 @@ public class InitializerTests @@ -532,9 +532,9 @@ public class InitializerTests
});
}
public void MultidimensionalInit()
public int[,] MultidimensionalInit()
{
int[,] expr_09 = new int[, ]
return new int[, ]
{
{
@ -651,9 +651,9 @@ public class InitializerTests @@ -651,9 +651,9 @@ public class InitializerTests
};
}
public void MultidimensionalInit2()
public int[][,] MultidimensionalInit2()
{
int[][,] array = new int[][,]
return new int[][,]
{
new int[, ]
{
@ -785,9 +785,9 @@ public class InitializerTests @@ -785,9 +785,9 @@ public class InitializerTests
};
}
public void ArrayOfArrayOfArrayInit()
public int[][,,] ArrayOfArrayOfArrayInit()
{
int[][,,] array = new int[][,,]
return new int[][,,]
{
new int[, , ]
{

14
ICSharpCode.Decompiler/Tests/TestRunner.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.Decompiler.Tests @@ -55,7 +55,7 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void ExceptionHandling()
{
TestFile(@"..\..\Tests\ExceptionHandling.cs");
TestFile(@"..\..\Tests\ExceptionHandling.cs", false);
}
[Test]
@ -155,9 +155,15 @@ namespace ICSharpCode.Decompiler.Tests @@ -155,9 +155,15 @@ namespace ICSharpCode.Decompiler.Tests
}
static void TestFile(string fileName)
{
TestFile(fileName, false);
TestFile(fileName, true);
}
static void TestFile(string fileName, bool optimize)
{
string code = File.ReadAllText(fileName);
AssemblyDefinition assembly = Compile(code);
AssemblyDefinition assembly = Compile(code, optimize);
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
decompiler.AddAssembly(assembly);
new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
@ -166,11 +172,11 @@ namespace ICSharpCode.Decompiler.Tests @@ -166,11 +172,11 @@ namespace ICSharpCode.Decompiler.Tests
CodeAssert.AreEqual(code, output.ToString());
}
static AssemblyDefinition Compile(string code)
static AssemblyDefinition Compile(string code, bool optimize)
{
CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<string, string> { { "CompilerVersion", "v4.0" } });
CompilerParameters options = new CompilerParameters();
options.CompilerOptions = "/unsafe /o-";
options.CompilerOptions = "/unsafe /o" + (optimize ? "+" : "-");
options.ReferencedAssemblies.Add("System.Core.dll");
CompilerResults results = provider.CompileAssemblyFromSource(options, code);
try {

Loading…
Cancel
Save