diff options
author | Marek Safar <marek.safar@gmail.com> | 2021-05-07 18:51:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 18:51:40 +0300 |
commit | a5f4931bc577ca94d05cd6b64e810c5cc4f035bb (patch) | |
tree | 20a746e4f6c0a801d044d111c3fed50c59be4706 /test | |
parent | 17dd8b63f0f1752685575f920a3c3db00c51ecb9 (diff) |
Improve expected tests results verification for branch instructions (#2018)
Diffstat (limited to 'test')
10 files changed, 47 insertions, 38 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Advanced/TypeCheckRemoval.cs b/test/Mono.Linker.Tests.Cases/Advanced/TypeCheckRemoval.cs index eb0e22cf1..a1530ee37 100644 --- a/test/Mono.Linker.Tests.Cases/Advanced/TypeCheckRemoval.cs +++ b/test/Mono.Linker.Tests.Cases/Advanced/TypeCheckRemoval.cs @@ -57,7 +57,7 @@ namespace Mono.Linker.Tests.Cases.Advanced [ExpectedInstructionSequence (new[] { "ldarg.0", "dup", - "brtrue.s", + "brtrue.s il_6", "pop", "ldarg.1", "pop", @@ -76,7 +76,7 @@ namespace Mono.Linker.Tests.Cases.Advanced "ldarg.0", "pop", "ldnull", - "brfalse.s", + "brfalse.s il_6", "ret", "call", "ret" diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs index 6a77a146a..2900168f8 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs @@ -23,7 +23,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "nop", "ldarg.0", "isinst", - "brtrue.s", + "brtrue.s il_19", "call", "pop", "ldarg.0", @@ -31,12 +31,12 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "ldnull", "ldnull", "cgt.un", - "br.s", - "br.s", + "br.s il_17", + "br.s il_1a", "ldc.i4.1", "stloc.0", "ldloc.0", - "brfalse.s", + "brfalse.s il_24", "call", "nop", "ret" @@ -62,15 +62,15 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "stloc.0", "ldarg.0", "ldc.i4.2", - "beq.s", + "beq.s il_15", "ldarg.0", "ldc.i4.3", "ceq", - "br.s", + "br.s il_16", "ldc.i4.1", "stloc.2", "ldloc.2", - "brfalse.s", + "brfalse.s il_20", "newobj", "throw", "newobj", diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/InstanceMethodSubstitutions.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/InstanceMethodSubstitutions.cs index c1c07b75e..162f26662 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/InstanceMethodSubstitutions.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/InstanceMethodSubstitutions.cs @@ -58,9 +58,9 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "brfalse.s", + "brfalse.s il_7", "ldc.i4.1", - "ret", + "ret" })] int TestCallOnInstanceMulti () { @@ -153,10 +153,10 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "brfalse.s", + "brfalse.s il_7", "ldarg.0", "call", - "ret", + "ret" })] void TestStaticPropagation () { diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedReturns.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedReturns.cs index 0758e32c7..73d568fbf 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedReturns.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedReturns.cs @@ -136,10 +136,10 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "call", "pop", "call", - "leave.s", + "leave.s il_16", "pop", "call", - "leave.s", + "leave.s il_15", "ret", "ret" })] @@ -168,12 +168,12 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "ldc.i4.1", "conv.i8", "stloc.0", - "leave.s", + "leave.s il_16", "pop", "ldc.i4.2", "conv.i8", "stloc.0", - "leave.s", + "leave.s il_16", "ldloc.0", "ret" })] @@ -200,11 +200,11 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "call", "ldc.i4.1", "stloc.1", - "leave.s", + "leave.s il_1c", "pop", "ldloc.0", "call", - "leave.s", + "leave.s il_1a", "ldc.i4.3", "ret", "ldloc.1", @@ -254,9 +254,9 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "call", "pop", "call", - "leave.s", + "leave.s il_10", "pop", - "leave.s", + "leave.s il_10", "ret" })] static void Test9 () diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs index ef53264be..cc3e3bd40 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs @@ -29,7 +29,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [ExpectedInstructionSequence (new[] { "call", "ldc.i4.3", - "beq.s", + "beq.s il_8", "ret" })] static void TestProperty_int_1 () @@ -42,7 +42,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [ExpectedInstructionSequence (new[] { "ldc.i4.3", "call", - "beq.s", + "beq.s il_8", "ret" })] static void TestProperty_int_2 () @@ -58,7 +58,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [ExpectedInstructionSequence (new[] { "call", "ldc.i4.5", - "ble.s", + "ble.s il_8", "ldc.i4.0", "ret" })] @@ -91,7 +91,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "brfalse.s", + "brfalse.s il_7", "ret" })] static void TestProperty_bool_1 () @@ -106,7 +106,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "brfalse.s", + "brfalse.s il_7", "ret" })] static void TestProperty_bool_2 () @@ -120,7 +120,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [ExpectedInstructionSequence (new[] { "call", "call", - "beq.s", + "beq.s il_c", "ret" })] static void TestProperty_bool_3 () @@ -132,7 +132,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { - "br.s", + "br.s il_2", "call", "pop", "ret" @@ -147,7 +147,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "brfalse.s", + "brfalse.s il_7", "ret" })] static void TestProperty_null_1 () diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryCatchBlocks.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryCatchBlocks.cs index dca8e0cfa..bf1f4f852 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryCatchBlocks.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryCatchBlocks.cs @@ -17,7 +17,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [ExpectedInstructionSequence (new[] { "call", "ldc.i4.6", - "beq.s", + "beq.s il_8", "ldc.i4.3", "ret" })] diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFilterBlocks.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFilterBlocks.cs index be36dbd0b..124fce138 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFilterBlocks.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFilterBlocks.cs @@ -17,16 +17,16 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "brfalse.s", + "brfalse.s il_7", "call", - "leave.s", + "leave.s il_1c", "pop", "call", "ldc.i4.0", "cgt.un", "endfilter", "pop", - "leave.s", + "leave.s il_1c", "ldc.i4.2", "ret" })] @@ -47,16 +47,16 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] [ExpectedInstructionSequence (new[] { "call", - "leave.s", + "leave.s il_18", "pop", "call", - "brfalse.s", + "brfalse.s il_f", "ldc.i4.0", "ldc.i4.0", "cgt.un", "endfilter", "pop", - "leave.s", + "leave.s il_18", "ldc.i4.3", "ret" })] diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFinallyBlocks.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFinallyBlocks.cs index e39a2f936..1c1dfdabd 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFinallyBlocks.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFinallyBlocks.cs @@ -17,7 +17,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [ExpectedInstructionSequence (new[] { "call", "ldc.i4.3", - "beq.s", + "beq.s il_8", "ret" })] static void TestSimpleTry () diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/WorksWithDynamicAssembly.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/WorksWithDynamicAssembly.cs index e72d08bd7..ae495b8d8 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/WorksWithDynamicAssembly.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/WorksWithDynamicAssembly.cs @@ -18,7 +18,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock "TestProperty()", new string[] { "call", - "brfalse.s", + "brfalse.s il_7", "ret" })] [Kept] diff --git a/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index d3b00386b..421e4ac1a 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -386,6 +386,15 @@ namespace Mono.Linker.Tests.TestCasesRunner public static string FormatInstruction (Instruction instr) { + switch (instr.OpCode.FlowControl) { + case FlowControl.Branch: + case FlowControl.Cond_Branch: + if (instr.Operand is Instruction target) + return $"{instr.OpCode.ToString ()} il_{target.Offset.ToString ("X")}"; + + break; + } + switch (instr.OpCode.Code) { case Code.Ldc_I4: if (instr.Operand is int ivalue) |