Browse Source

Adjust tests: the improved stack slot type caused variable names to improve.

pull/4071/head
Daniel Grunwald 3 weeks ago
parent
commit
b360268d6d
  1. 28
      ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue684.cs
  2. 17
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs
  3. 8
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs
  4. 8
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs
  5. 9
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs

28
ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Issue684.cs

@ -8,35 +8,35 @@ public static class Issue684 @@ -8,35 +8,35 @@ public static class Issue684
int num = int.Parse(Console.ReadLine());
// Point of this test was to ensure the stack slot here uses an appropriate type,
// (bool instead of int). Unfortunately our type fixup runs too late to affect variable names.
bool num2 = num >= 1000;
if (!num2)
bool flag = num >= 1000;
if (!flag)
{
num2 = num < 2;
flag = num < 2;
}
if (num2)
if (flag)
{
Console.WriteLine(-1);
}
else
{
int i = 2;
for (int num3 = 2; num3 <= num; num3 = i)
for (int num2 = 2; num2 <= num; num2 = i)
{
Console.WriteLine(num3);
for (; i <= num; i += num3)
Console.WriteLine(num2);
for (; i <= num; i += num2)
{
int num4 = 1;
array[i] = num4;
int num3 = 1;
array[i] = num3;
}
i = num3;
i = num2;
while (true)
{
bool num5 = i <= num;
if (num5)
bool flag2 = i <= num;
if (flag2)
{
num5 = array[i] != 0;
flag2 = array[i] != 0;
}
if (!num5)
if (!flag2)
{
break;
}

17
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AnonymousTypes.cs

@ -40,11 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -40,11 +40,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
private void SimpleArray()
{
#if ROSLYN && OPT
var obj = new[] {
#else
var array = new[] {
#endif
new {
X = 5,
Y = 2,
@ -57,13 +53,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -57,13 +53,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
};
#if ROSLYN && OPT
Console.WriteLine(obj[0].X);
Console.WriteLine(obj[1].X);
#else
Console.WriteLine(array[0].X);
Console.WriteLine(array[1].X);
#endif
}
#if !MCS
private void JaggedArray()
@ -80,19 +71,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -80,19 +71,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Z = -6
}
};
#if ROSLYN && OPT
var obj = new[] { array, array };
Console.WriteLine(array[0].X);
Console.WriteLine(array[1].X);
Console.WriteLine(obj.Length);
#else
var array2 = new[] { array, array };
Console.WriteLine(array[0].X);
Console.WriteLine(array[1].X);
Console.WriteLine(array2.Length);
#endif
}
#endif
#if CS70

8
ICSharpCode.Decompiler.Tests/TestCases/Pretty/DeconstructionTests.cs

@ -623,17 +623,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -623,17 +623,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
// leaf instead of becoming a nested designation.
public void LocalVariable_TupleInner_ElementUsedOutside()
{
#if OPT
(int, (int, int)) tuple = GetTuple<int, (int, int)>();
int item = tuple.Item1;
(int, int) item2 = tuple.Item2;
Console.WriteLine(item);
Console.WriteLine(item2.Item1);
#else
var (value, tuple2) = GetTuple<int, (int, int)>();
Console.WriteLine(value);
Console.WriteLine(tuple2.Item1);
#endif
}
// Same, but the escaping element is in the first position. Every leaf of the

8
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Loops.cs

@ -647,19 +647,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -647,19 +647,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe void ForEachOverMultiDimArray3(int*[,] items)
{
#if ROSLYN && OPT
foreach (int* intPtr in items)
{
Console.WriteLine(*intPtr);
Console.WriteLine(*intPtr);
}
#else
foreach (int* ptr in items)
{
Console.WriteLine(*ptr);
Console.WriteLine(*ptr);
}
#endif
}
#endif

9
ICSharpCode.Decompiler.Tests/TestCases/Pretty/QueryExpressions.cs

@ -264,21 +264,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -264,21 +264,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public static IEnumerable<char> Issue1310a(bool test)
{
#if ROSLYN && OPT
IEnumerable<char> obj = (test ? (from c in Enumerable.Range(0, 255)
where char.IsLetter((char)c)
select (char)c) : (from c in Enumerable.Range(0, 255)
where char.IsDigit((char)c)
select (char)c));
return obj.Concat(obj);
#else
IEnumerable<char> enumerable = (test ? (from c in Enumerable.Range(0, 255)
where char.IsLetter((char)c)
select (char)c) : (from c in Enumerable.Range(0, 255)
where char.IsDigit((char)c)
select (char)c));
return enumerable.Concat(enumerable);
#endif
}
public static Maybe<TB> Cast<TA, TB>(Maybe<TA> a) where TB : class

Loading…
Cancel
Save