diff options
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs index 9a92ab742..2660b240d 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs @@ -1,18 +1,46 @@ using System; using System.Reflection.Emit; using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; namespace Mono.Linker.Tests.Cases.UnreachableBlock { + [SetupCompileArgument ("/optimize-")] // Relying on debug csc behaviour public class ComplexConditions { - public static void Main() + public static void Main () { Test_1 (null); + Test_2 (9); } [Kept] +#if !NETCOREAPP [ExpectBodyModified] +#else + [ExpectedInstructionSequence (new [] { + "nop", + "ldarg.0", + "isinst", + "brtrue.s", + "call", + "pop", + "ldarg.0", + "isinst", + "ldnull", + "cgt.un", + "br.s", + "nop", + "br.s", + "ldc.i4.1", + "stloc.0", + "ldloc.0", + "brfalse.s", + "call", + "nop", + "ret" + })] +#endif static void Test_1 (object type) { if (type is Type || (IsDynamicCodeSupported && type is TypeBuilder)) @@ -20,6 +48,47 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock } [Kept] +#if !NETCOREAPP + [ExpectBodyModified] +#else + [ExpectedInstructionSequence (new [] { + "nop", + "call", + "stloc.1", + "ldloc.1", + "pop", + "ldc.i4.0", + "stloc.0", + "ldarg.0", + "ldc.i4.2", + "beq.s", + "ldarg.0", + "ldc.i4.3", + "ceq", + "br.s", + "ldc.i4.1", + "stloc.2", + "ldloc.2", + "brfalse.s", + "newobj", + "throw", + "newobj", + "throw" + })] +#endif + static void Test_2 (int a) + { + int zero; + if (IsDynamicCodeSupported) + zero = 0; + + if (a == 2 || a == 3) + throw new ArgumentException (); + + throw new ApplicationException (); + } + + [Kept] static bool IsDynamicCodeSupported { [Kept] get { @@ -29,7 +98,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] static void Reached_1 () - { + { } } }
\ No newline at end of file |