From 3951920cbd825c2b2251ba3572ca354f887d6033 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Tue, 27 Jun 2017 21:31:03 +0300 Subject: Implement JIT_NewArr1_R2R as R2R wrapper for JIT_NewArr1 to support both MethodTable-based and TypeDesc-based helpers. (#12475) Related issue: #12463 --- tests/src/readytorun/tests/newarray.cs | 126 +++++++++++++++++++++++++++++ tests/src/readytorun/tests/newarray.csproj | 32 ++++++++ 2 files changed, 158 insertions(+) create mode 100644 tests/src/readytorun/tests/newarray.cs create mode 100644 tests/src/readytorun/tests/newarray.csproj (limited to 'tests') diff --git a/tests/src/readytorun/tests/newarray.cs b/tests/src/readytorun/tests/newarray.cs new file mode 100644 index 0000000000..66917abf65 --- /dev/null +++ b/tests/src/readytorun/tests/newarray.cs @@ -0,0 +1,126 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; + +class Program +{ + const int ARRAY_SIZE = 1024; + + static int Main() + { + // Run all tests 3x times to exercise both slow and fast paths work + for (int i = 0; i < 3; i++) + RunAllTests(); + + Console.WriteLine(Assert.HasAssertFired ? "FAILED" : "PASSED"); + return Assert.HasAssertFired ? 1 : 100; + } + + static void RunAllTests() + { + RunTest1(); + RunTest2(); + RunTest3(); + RunTest4(); + RunTest5(); + RunTest6(); + RunTest7(); + RunTest8(); + } + + static void RunTest1() + { + int [] arr = new int[ARRAY_SIZE]; + + Assert.AreEqual(arr.GetType().ToString(), "System.Int32[]"); + } + + static void RunTest2() + { + object [] arr = new object[ARRAY_SIZE]; + + Assert.AreEqual(arr.GetType().ToString(), "System.Object[]"); + } + + static void RunTest3() + { + int [] arr = new_array_generic(); + + Assert.AreEqual(arr.GetType().ToString(), "System.Int32[]"); + } + + static void RunTest4() + { + string [] arr = new_array_generic(); + + Assert.AreEqual(arr.GetType().ToString(), "System.String[]"); + } + + static void RunTest5() + { + object [] arr = new_array_generic(); + + Assert.AreEqual(arr.GetType().ToString(), "System.Object[]"); + } + + static void RunTest6() + { + GenericClass1 [] arr = new GenericClass1[ARRAY_SIZE]; + + Assert.AreEqual(arr.GetType().ToString(), "GenericClass1`1[System.Int32][]"); + } + + static void RunTest7() + { + GenericClass1 [] arr = new_array_generic>(); + + Assert.AreEqual(arr.GetType().ToString(), "GenericClass1`1[System.Object][]"); + } + + static void RunTest8() + { + genericclass1_object_array_field = new_array_generic>(); + + Assert.AreEqual(genericclass1_object_array_field.GetType().ToString(), "GenericClass2`1[System.Object][]"); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static T[] new_array_generic() + { + return new T[ARRAY_SIZE]; + } + + static volatile GenericClass1 [] genericclass1_object_array_field; +} + +class GenericClass1 +{ +} + +class GenericClass2 : GenericClass1 +{ +} + +public static class Assert +{ + public static bool HasAssertFired; + + public static void AreEqual(Object actual, Object expected) + { + if (!(actual == null && expected == null) && !actual.Equals(expected)) + { + Console.WriteLine("Not equal!"); + Console.WriteLine("actual = " + actual.ToString()); + Console.WriteLine("expected = " + expected.ToString()); + HasAssertFired = true; + } + } +} diff --git a/tests/src/readytorun/tests/newarray.csproj b/tests/src/readytorun/tests/newarray.csproj new file mode 100644 index 0000000000..21acf8128b --- /dev/null +++ b/tests/src/readytorun/tests/newarray.csproj @@ -0,0 +1,32 @@ + + + + + newarray + Debug + AnyCPU + 2.0 + {8DDE6EB9-7CAE-4DD1-B2CC-8D756855EF78} + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + Exe + BuildAndRun + 0 + + + + + False + + + + + + + + + + + + + -- cgit v1.2.3