diff options
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/UnreachableBlock/DeadVariables.cs')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/UnreachableBlock/DeadVariables.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/DeadVariables.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/DeadVariables.cs new file mode 100644 index 000000000..58c960936 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/DeadVariables.cs @@ -0,0 +1,75 @@ +using System; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + +namespace Mono.Linker.Tests.Cases.UnreachableBlock +{ + [SetupCSharpCompilerToUse ("csc")] + [SetupCompileArgument ("/optimize+")] + public class DeadVariables + { + public static void Main () + { + Test_1 (); + Test_2 (4); + Test_3 (); + } + + [Kept] + [ExpectBodyModified] + [ExpectedLocalsSequence (new string [0])] + static void Test_1 () + { + if (!AlwaysTrue) { + int var = 1; + Console.WriteLine (var); + } + } + + [Kept] + [ExpectBodyModified] + [ExpectedLocalsSequence (new string [] { "System.Object", "System.Int32" })] + static int Test_2 (int arg) + { + if (!AlwaysTrue) { + long var = 3; + Console.WriteLine (var++); + return (int) var; + } + + { + int b = arg; + Console.WriteLine (b++); + return b; + } + } + + [Kept] + [ExpectBodyModified] + [ExpectedLocalsSequence (new string [] { "System.Int32", "System.DateTime", "System.DateTimeOffset", "System.DateTimeOffset" })] + static int Test_3 () + { + var b = 3; + var c = new DateTime (); + var d = new DateTimeOffset (); + var e = new DateTimeOffset (); + + if (!AlwaysTrue) { + int a = b; + ref int var = ref a; + } + + Console.WriteLine (b.ToString (), c, d, e); + + return 2; + } + + [Kept] + static bool AlwaysTrue { + [Kept] + get { + return true; + } + } + } +}
\ No newline at end of file |