diff options
author | Richard L Ford <richford@microsoft.com> | 2015-11-09 15:42:12 -0800 |
---|---|---|
committer | Richard L Ford <richford@microsoft.com> | 2015-11-09 16:30:45 -0800 |
commit | b5a1f6e5ef4ae180087d22958620012e524b57c1 (patch) | |
tree | 4a521ad5d5d99a7eb02b253d3c09b83c209f3023 /tests/src/JIT/Directed/gettypetypeof | |
parent | 077d5cb53bf9c0339cca6e2dc64e1d523987098d (diff) | |
download | coreclr-b5a1f6e5ef4ae180087d22958620012e524b57c1.tar.gz coreclr-b5a1f6e5ef4ae180087d22958620012e524b57c1.tar.bz2 coreclr-b5a1f6e5ef4ae180087d22958620012e524b57c1.zip |
Add gettypetypeofmatrix test.
Ported the JIT/Directed/gettypetypeof/gettypetypeofmatrix.cs
test from the desktop clr suite to coreclr.
Diffstat (limited to 'tests/src/JIT/Directed/gettypetypeof')
3 files changed, 269 insertions, 0 deletions
diff --git a/tests/src/JIT/Directed/gettypetypeof/app.config b/tests/src/JIT/Directed/gettypetypeof/app.config new file mode 100644 index 0000000000..8077c95440 --- /dev/null +++ b/tests/src/JIT/Directed/gettypetypeof/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.cs b/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.cs new file mode 100644 index 0000000000..aa014d5611 --- /dev/null +++ b/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +internal class Foo +{ +} + +internal class Test +{ + private static object s_null = null; + private static object s_object = new object(); + private static object[] s_objectArray = new object[10]; + private static Foo s_foo = new Foo(); + private static Foo[] s_fooArray = new Foo[10]; + + static public int Main() + { + int iReturn = 100; + try + { + IsObjectType(s_object, true); + IsObjectType(s_objectArray, false); + IsObjectType(s_foo, false); + IsObjectType(s_fooArray, false); + + IsObjectArrayType(s_object, false); + IsObjectArrayType(s_objectArray, true); + IsObjectArrayType(s_foo, false); + IsObjectArrayType(s_fooArray, false); + + IsFooType(s_object, false); + IsFooType(s_objectArray, false); + IsFooType(s_foo, true); + IsFooType(s_fooArray, false); + + IsFooArrayType(s_object, false); + IsFooArrayType(s_objectArray, false); + IsFooArrayType(s_foo, false); + IsFooArrayType(s_fooArray, true); + + IsObjectTypeNullRef(s_null); + IsObjectArrayTypeNullRef(s_null); + IsFooTypeNullRef(s_null); + IsFooArrayTypeNullRef(s_null); + + Console.WriteLine("\nTest SUCCESS"); + } + catch (Exception e) + { + Console.WriteLine(e); + Console.WriteLine("Test FAILED"); + + iReturn = 666; + } + + return iReturn; + } + + private static void IsResultCorrect(bool result, bool baseline) + { + if (result != baseline) + { + throw new Exception("Failed test"); + } + else + { + Console.WriteLine("Passed"); + } + } + + + private static void IsObjectTypeNullRef(object o) + { + Console.Write("Test: {0} == typeof(object) Expected: null ref exception...", o == null ? "null" : o.ToString()); + try + { + if (o.GetType() == typeof(object) || + o.GetType() != typeof(object)) + { + throw new Exception("Failed test"); + } + } + catch (NullReferenceException) + { + Console.WriteLine("Passed"); + } + catch (Exception) + { + throw new Exception("Failed test"); + } + } + + private static void IsObjectArrayTypeNullRef(object o) + { + Console.Write("Test: {0} == typeof(object[]) Expected: null ref exception...", o == null ? "null" : o.ToString()); + try + { + if (o.GetType() == typeof(object[]) || + o.GetType() != typeof(object[])) + { + throw new Exception("Failed test"); + } + } + catch (NullReferenceException) + { + Console.WriteLine("Passed"); + } + catch (Exception) + { + throw new Exception("Failed test"); + } + } + + private static void IsFooTypeNullRef(object o) + { + Console.Write("Test: {0} == typeof(Foo) Expected: null ref exception...", o == null ? "null" : o.ToString()); + try + { + if (o.GetType() == typeof(Foo) || + o.GetType() != typeof(Foo)) + { + throw new Exception("Failed test"); + } + } + catch (NullReferenceException) + { + Console.WriteLine("Passed"); + } + catch (Exception) + { + throw new Exception("Failed test"); + } + } + + private static void IsFooArrayTypeNullRef(object o) + { + Console.Write("Test: {0} == typeof(Foo[]) Expected: null ref exception...", o == null ? "null" : o.ToString()); + try + { + if (o.GetType() == typeof(Foo[]) || + o.GetType() != typeof(Foo[])) + { + throw new Exception("Failed test"); + } + } + catch (NullReferenceException) + { + Console.WriteLine("Passed"); + } + catch (Exception) + { + throw new Exception("Failed test"); + } + } + + private static void IsObjectType(object o, bool baseline) + { + Console.Write("Test: o_{0}.GetType() == typeof(object) Expected: {1}...", o.GetType(), baseline); + IsResultCorrect( + o.GetType() == typeof(object), + baseline); + } + + private static void IsObjectArrayType(object o, bool baseline) + { + Console.Write("Test: o_{0}.GetType() == typeof(object[]) Expected: {1}...", o.GetType(), baseline); + IsResultCorrect( + o.GetType() == typeof(object[]), + baseline); + } + + private static void IsFooType(object o, bool baseline) + { + Console.Write("Test: o_{0}.GetType() == typeof(Foo) Expected: {1}...", o.GetType(), baseline); + IsResultCorrect( + o.GetType() == typeof(Foo), + baseline); + } + + private static void IsFooArrayType(object o, bool baseline) + { + Console.Write("Test: o_{0}.GetType() == typeof(Foo[]) Expected: {1}...", o.GetType(), baseline); + IsResultCorrect( + o.GetType() == typeof(Foo[]), + baseline); + } +} diff --git a/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.csproj b/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.csproj new file mode 100644 index 0000000000..8a3bdfb75e --- /dev/null +++ b/tests/src/JIT/Directed/gettypetypeof/gettypetypeofmatrix.csproj @@ -0,0 +1,53 @@ +<?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> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <RestorePackages>true</RestorePackages> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> + <DebugType></DebugType> + + <!-- Set to 'True' if the Debug? column is marked in the spreadsheet, and 'False' otherwise. --> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Compile Include="gettypetypeofmatrix.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <PropertyGroup> + <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson> + <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> |