summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRuben Ayrapetyan <ruben-ayrapetyan@users.noreply.github.com>2017-06-27 21:31:03 +0300
committerJan Kotas <jkotas@microsoft.com>2017-06-27 11:31:03 -0700
commit3951920cbd825c2b2251ba3572ca354f887d6033 (patch)
tree0245d94927f56736b6f4adf1f630c2639bb28686 /tests
parentf1499d2214d0d8d630bff30045ce520b73d4356c (diff)
downloadcoreclr-3951920cbd825c2b2251ba3572ca354f887d6033.tar.gz
coreclr-3951920cbd825c2b2251ba3572ca354f887d6033.tar.bz2
coreclr-3951920cbd825c2b2251ba3572ca354f887d6033.zip
Implement JIT_NewArr1_R2R as R2R wrapper for JIT_NewArr1 to support both MethodTable-based and TypeDesc-based helpers. (#12475)
Related issue: #12463
Diffstat (limited to 'tests')
-rw-r--r--tests/src/readytorun/tests/newarray.cs126
-rw-r--r--tests/src/readytorun/tests/newarray.csproj32
2 files changed, 158 insertions, 0 deletions
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<int>();
+
+ Assert.AreEqual(arr.GetType().ToString(), "System.Int32[]");
+ }
+
+ static void RunTest4()
+ {
+ string [] arr = new_array_generic<string>();
+
+ Assert.AreEqual(arr.GetType().ToString(), "System.String[]");
+ }
+
+ static void RunTest5()
+ {
+ object [] arr = new_array_generic<object>();
+
+ Assert.AreEqual(arr.GetType().ToString(), "System.Object[]");
+ }
+
+ static void RunTest6()
+ {
+ GenericClass1<int> [] arr = new GenericClass1<int>[ARRAY_SIZE];
+
+ Assert.AreEqual(arr.GetType().ToString(), "GenericClass1`1[System.Int32][]");
+ }
+
+ static void RunTest7()
+ {
+ GenericClass1<object> [] arr = new_array_generic<GenericClass1<object>>();
+
+ Assert.AreEqual(arr.GetType().ToString(), "GenericClass1`1[System.Object][]");
+ }
+
+ static void RunTest8()
+ {
+ genericclass1_object_array_field = new_array_generic<GenericClass2<object>>();
+
+ Assert.AreEqual(genericclass1_object_array_field.GetType().ToString(), "GenericClass2`1[System.Object][]");
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static T[] new_array_generic<T>()
+ {
+ return new T[ARRAY_SIZE];
+ }
+
+ static volatile GenericClass1<object> [] genericclass1_object_array_field;
+}
+
+class GenericClass1<T>
+{
+}
+
+class GenericClass2<T> : GenericClass1<T>
+{
+}
+
+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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <AssemblyName>newarray</AssemblyName>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{8DDE6EB9-7CAE-4DD1-B2CC-8D756855EF78}</ProjectGuid>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Compile Include="newarray.cs" />
+ </ItemGroup>
+
+
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>