Browse Source

Fix CS73_StackAllocInitializer tests

pull/2542/head
Siegfried Pammer 4 years ago
parent
commit
b87cdf6bc4
  1. 10
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  2. 10
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs

10
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -79,6 +79,14 @@ namespace ICSharpCode.Decompiler.Tests
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest, CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
}; };
static readonly CompilerOptions[] roslyn3OrNewerOptions =
{
CompilerOptions.UseRoslyn3_11_0,
CompilerOptions.Optimize | CompilerOptions.UseRoslyn3_11_0,
CompilerOptions.UseRoslynLatest,
CompilerOptions.Optimize | CompilerOptions.UseRoslynLatest,
};
static readonly CompilerOptions[] roslynLatestOnlyOptions = static readonly CompilerOptions[] roslynLatestOnlyOptions =
{ {
CompilerOptions.UseRoslynLatest, CompilerOptions.UseRoslynLatest,
@ -440,7 +448,7 @@ namespace ICSharpCode.Decompiler.Tests
} }
[Test] [Test]
public void CS73_StackAllocInitializers([ValueSource(nameof(roslynLatestOnlyOptions))] CompilerOptions cscOptions) public void CS73_StackAllocInitializers([ValueSource(nameof(roslyn3OrNewerOptions))] CompilerOptions cscOptions)
{ {
RunForLibrary(cscOptions: cscOptions); RunForLibrary(cscOptions: cscOptions);
} }

10
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs

@ -193,11 +193,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe string NegativeOffsets(int a, int b, int c) public unsafe string NegativeOffsets(int a, int b, int c)
{ {
#if OPT #if OPT
byte* intPtr = stackalloc byte[12]; byte* num = stackalloc byte[12];
*(int*)intPtr = 1; *(int*)num = 1;
*(int*)(intPtr - 4) = 2; *(int*)(num - 4) = 2;
*(int*)(intPtr - 8) = 3; *(int*)(num - 8) = 3;
int* ptr = (int*)intPtr; int* ptr = (int*)num;
Console.WriteLine(*ptr); Console.WriteLine(*ptr);
return UsePointer((byte*)ptr); return UsePointer((byte*)ptr);
#else #else

Loading…
Cancel
Save