diff options
Diffstat (limited to 'tests')
17 files changed, 1214 insertions, 0 deletions
diff --git a/tests/src/AllTestProjects.sln b/tests/src/AllTestProjects.sln index d8647d26ae..42cee6836c 100644 --- a/tests/src/AllTestProjects.sln +++ b/tests/src/AllTestProjects.sln @@ -145,6 +145,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Inline", "Inline", "{8C7543 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inline", "JIT\opt\Inline\Inline.csproj", "{757F1684-39BD-4705-91F1-FE16BD5B1523}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Fields", "Fields", "{469D4D65-45B3-4641-9C04-480102731EF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fields", "JIT\Generics\Fields\Fields.csproj", "{F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -423,6 +427,16 @@ Global {757F1684-39BD-4705-91F1-FE16BD5B1523}.Release|Mixed Platforms.Build.0 = Release|x64 {757F1684-39BD-4705-91F1-FE16BD5B1523}.Release|x64.ActiveCfg = Release|x64 {757F1684-39BD-4705-91F1-FE16BD5B1523}.Release|x64.Build.0 = Release|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Debug|Any CPU.ActiveCfg = Debug|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Debug|Mixed Platforms.Build.0 = Debug|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Debug|x64.ActiveCfg = Debug|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Debug|x64.Build.0 = Debug|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Release|Any CPU.ActiveCfg = Release|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Release|Mixed Platforms.Build.0 = Release|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Release|x64.ActiveCfg = Release|x64 + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -478,6 +492,7 @@ Global {BEED6C21-79A9-4E53-A362-74F0F53592C9} = {3AC4E363-B239-4D48-AEB8-A9177554E156} {472DA1F4-C446-434B-906C-A0F2899C279B} = {BA784A0F-E788-40CC-A76D-EB4041808897} {C3F22F91-FE0E-4181-864B-D7EE7225382D} = {4528D9E6-C6F8-448E-BD36-5E5DAAFE90D3} + {469D4D65-45B3-4641-9C04-480102731EF9} = {4528D9E6-C6F8-448E-BD36-5E5DAAFE90D3} {C5825007-742C-4F16-BAB5-09D6EAF2AEF6} = {C3F22F91-FE0E-4181-864B-D7EE7225382D} {1E8B3DDB-15DC-4BB9-BAFB-8252848A8784} = {C3F22F91-FE0E-4181-864B-D7EE7225382D} {A1C4D795-DE5B-4CB0-BFF6-13E1D5A787FD} = {C5825007-742C-4F16-BAB5-09D6EAF2AEF6} @@ -490,5 +505,6 @@ Global {6992FF33-4A44-4788-9A39-7A8760AA54A5} = {7C6A86B2-9A8D-489B-A79B-A5721B0AAB62} {8C754381-F489-4B5F-885A-415D323D88BF} = {0957EF12-6D74-4438-BAD1-D720433C2162} {757F1684-39BD-4705-91F1-FE16BD5B1523} = {8C754381-F489-4B5F-885A-415D323D88BF} + {F40B2B5B-4C42-4BD8-8CAF-8C96856BAC0F} = {469D4D65-45B3-4641-9C04-480102731EF9} EndGlobalSection EndGlobal diff --git a/tests/src/JIT/Generics/Fields/Fields.csproj b/tests/src/JIT/Generics/Fields/Fields.csproj new file mode 100644 index 0000000000..33b2928ebc --- /dev/null +++ b/tests/src/JIT/Generics/Fields/Fields.csproj @@ -0,0 +1,19 @@ +<?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" /> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <Target Name="Build"> + <ItemGroup> + <AllSourceFiles Include="$(MSBuildProjectDirectory)\*.cs" /> + </ItemGroup> + <PropertyGroup> + <GenerateRunScript>false</GenerateRunScript> + </PropertyGroup> + <MSBuild Projects="cs_template.proj" Properties="AssemblyName1=%(AllSourceFiles.FileName);AllowUnsafeBlocks=True;IntermediateOutputPath=$(IntermediateOutputPath)\%(AllSourceFiles.FileName)\" /> + </Target> +</Project> diff --git a/tests/src/JIT/Generics/Fields/app.config b/tests/src/JIT/Generics/Fields/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/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/Generics/Fields/cs_template.proj b/tests/src/JIT/Generics/Fields/cs_template.proj new file mode 100644 index 0000000000..adc2f21e14 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/cs_template.proj @@ -0,0 +1,42 @@ +<?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>$(AssemblyName1)</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> + <ItemGroup> + <Compile Include="$(AssemblyName1).cs" /> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/JIT/Generics/Fields/instance_assignment_class01.cs b/tests/src/JIT/Generics/Fields/instance_assignment_class01.cs new file mode 100644 index 0000000000..453ef868c8 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/instance_assignment_class01.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public class Gen<T> +{ + public T Fld1; + + public T Assign(T t) + { + Fld1 = t; + return Fld1; + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 1; + Eval(new Gen<int>().Assign(_int).Equals(_int)); + + double _double = 1; + Eval(new Gen<double>().Assign(_double).Equals(_double)); + + string _string = "string"; + Eval(new Gen<string>().Assign(_string).Equals(_string)); + + object _object = new object(); + Eval(new Gen<object>().Assign(_object).Equals(_object)); + + Guid _Guid = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Eval(new Gen<Guid>().Assign(_Guid).Equals(_Guid)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/instance_assignment_struct01.cs b/tests/src/JIT/Generics/Fields/instance_assignment_struct01.cs new file mode 100644 index 0000000000..afc1fa60d5 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/instance_assignment_struct01.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public struct Gen<T> +{ + public T Fld1; + + public T Assign(T t) + { + Fld1 = t; + return Fld1; + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 1; + Eval(new Gen<int>().Assign(_int).Equals(_int)); + + double _double = 1; + Eval(new Gen<double>().Assign(_double).Equals(_double)); + + string _string = "string"; + Eval(new Gen<string>().Assign(_string).Equals(_string)); + + object _object = new object(); + Eval(new Gen<object>().Assign(_object).Equals(_object)); + + Guid _Guid = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Eval(new Gen<Guid>().Assign(_Guid).Equals(_Guid)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/instance_equalnull_class01.cs b/tests/src/JIT/Generics/Fields/instance_equalnull_class01.cs new file mode 100644 index 0000000000..f9d372bf0b --- /dev/null +++ b/tests/src/JIT/Generics/Fields/instance_equalnull_class01.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public class Gen<T> +{ + public T Fld1; + + public bool EqualNull(T t) + { + Fld1 = t; + return ((object)Fld1 == null); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 0; + Eval(false == new Gen<int>().EqualNull(_int)); + + double _double = 0; + Eval(false == new Gen<double>().EqualNull(_double)); + + Guid _Guid = new Guid(); + Eval(false == new Gen<Guid>().EqualNull(_Guid)); + + string _string = "string"; + Eval(false == new Gen<string>().EqualNull(_string)); + Eval(true == new Gen<string>().EqualNull(null)); + + object _object = new object(); + Eval(false == new Gen<object>().EqualNull(_string)); + Eval(true == new Gen<object>().EqualNull(null)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/instance_equalnull_struct01.cs b/tests/src/JIT/Generics/Fields/instance_equalnull_struct01.cs new file mode 100644 index 0000000000..22538434c5 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/instance_equalnull_struct01.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public struct Gen<T> +{ + public T Fld1; + + public bool EqualNull(T t) + { + Fld1 = t; + return ((object)Fld1 == null); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 0; + Eval(false == new Gen<int>().EqualNull(_int)); + + double _double = 0; + Eval(false == new Gen<double>().EqualNull(_double)); + + Guid _Guid = new Guid(); + Eval(false == new Gen<Guid>().EqualNull(_Guid)); + + string _string = "string"; + Eval(false == new Gen<string>().EqualNull(_string)); + Eval(true == new Gen<string>().EqualNull(null)); + + object _object = new object(); + Eval(false == new Gen<object>().EqualNull(_string)); + Eval(true == new Gen<object>().EqualNull(null)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/instance_passing_class01.cs b/tests/src/JIT/Generics/Fields/instance_passing_class01.cs new file mode 100644 index 0000000000..3a5925188c --- /dev/null +++ b/tests/src/JIT/Generics/Fields/instance_passing_class01.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public class Gen<T> +{ + public T Fld1; + public T Fld2; + + public T PassAsIn(T t) + { + return t; + } + + public T PassAsRef(ref T t) + { + T temp = t; + t = Fld2; + return temp; + } + + public void PassAsOut(out T t) + { + t = Fld2; + } + public void PassAsParameter(T t1, T t2) + { + Fld1 = t1; + Fld2 = t2; + + T temp = t1; + + Test.Eval(Fld1.Equals(PassAsIn(temp))); + Test.Eval(Fld1.Equals(PassAsRef(ref temp))); + Test.Eval(Fld2.Equals(temp)); + temp = t1; + PassAsOut(out temp); + Test.Eval(Fld2.Equals(temp)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int1 = 1; + int _int2 = -1; + new Gen<int>().PassAsParameter(_int1, _int2); + + double _double1 = 1; + double _double2 = -1; + new Gen<double>().PassAsParameter(_double1, _double2); + + string _string1 = "string1"; + string _string2 = "string2"; + new Gen<string>().PassAsParameter(_string1, _string2); + + object _object1 = (object)_string1; + object _object2 = (object)_string2; + new Gen<object>().PassAsParameter(_object1, _object2); + + Guid _Guid1 = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Guid _Guid2 = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + new Gen<Guid>().PassAsParameter(_Guid1, _Guid2); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/instance_passing_struct01.cs b/tests/src/JIT/Generics/Fields/instance_passing_struct01.cs new file mode 100644 index 0000000000..2620fd6e0a --- /dev/null +++ b/tests/src/JIT/Generics/Fields/instance_passing_struct01.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public struct Gen<T> +{ + public T Fld1; + public T Fld2; + + public T PassAsIn(T t) + { + return t; + } + + public T PassAsRef(ref T t) + { + T temp = t; + t = Fld2; + return temp; + } + + public void PassAsOut(out T t) + { + t = Fld2; + } + public void PassAsParameter(T t1, T t2) + { + Fld1 = t1; + Fld2 = t2; + + T temp = t1; + + Test.Eval(Fld1.Equals(PassAsIn(temp))); + Test.Eval(Fld1.Equals(PassAsRef(ref temp))); + Test.Eval(Fld2.Equals(temp)); + temp = t1; + PassAsOut(out temp); + Test.Eval(Fld2.Equals(temp)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int1 = 1; + int _int2 = -1; + new Gen<int>().PassAsParameter(_int1, _int2); + + double _double1 = 1; + double _double2 = -1; + new Gen<double>().PassAsParameter(_double1, _double2); + + string _string1 = "string1"; + string _string2 = "string2"; + new Gen<string>().PassAsParameter(_string1, _string2); + + object _object1 = (object)_string1; + object _object2 = (object)_string2; + new Gen<object>().PassAsParameter(_object1, _object2); + + Guid _Guid1 = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Guid _Guid2 = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + new Gen<Guid>().PassAsParameter(_Guid1, _Guid2); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/packages.config b/tests/src/JIT/Generics/Fields/packages.config new file mode 100644 index 0000000000..06d3d11ead --- /dev/null +++ b/tests/src/JIT/Generics/Fields/packages.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="System.Console" version="4.0.0-beta-22405" /> + <package id="System.Runtime" version="4.0.20-beta-22405" /> + <package id="System.Runtime.Extensions" version="4.0.10-beta-22412" /> +</packages> diff --git a/tests/src/JIT/Generics/Fields/static_assignment_class01.cs b/tests/src/JIT/Generics/Fields/static_assignment_class01.cs new file mode 100644 index 0000000000..a3b782e052 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/static_assignment_class01.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public class Gen<T> +{ + public static T Fld1; + + public T Assign(T t) + { + Fld1 = t; + return Fld1; + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 1; + Eval(new Gen<int>().Assign(_int).Equals(_int)); + + double _double = 1; + Eval(new Gen<double>().Assign(_double).Equals(_double)); + + string _string = "string"; + Eval(new Gen<string>().Assign(_string).Equals(_string)); + + object _object = new object(); + Eval(new Gen<object>().Assign(_object).Equals(_object)); + + Guid _Guid = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Eval(new Gen<Guid>().Assign(_Guid).Equals(_Guid)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/static_assignment_struct01.cs b/tests/src/JIT/Generics/Fields/static_assignment_struct01.cs new file mode 100644 index 0000000000..c096460a9f --- /dev/null +++ b/tests/src/JIT/Generics/Fields/static_assignment_struct01.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public struct Gen<T> +{ + public static T Fld1; + + public T Assign(T t) + { + Fld1 = t; + return Fld1; + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 1; + Eval(new Gen<int>().Assign(_int).Equals(_int)); + + double _double = 1; + Eval(new Gen<double>().Assign(_double).Equals(_double)); + + string _string = "string"; + Eval(new Gen<string>().Assign(_string).Equals(_string)); + + object _object = new object(); + Eval(new Gen<object>().Assign(_object).Equals(_object)); + + Guid _Guid = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Eval(new Gen<Guid>().Assign(_Guid).Equals(_Guid)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/static_equalnull_class01.cs b/tests/src/JIT/Generics/Fields/static_equalnull_class01.cs new file mode 100644 index 0000000000..ac248a7e96 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/static_equalnull_class01.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public class Gen<T> +{ + public static T Fld1; + + public bool EqualNull(T t) + { + Fld1 = t; + return ((object)Fld1 == null); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 0; + Eval(false == new Gen<int>().EqualNull(_int)); + + double _double = 0; + Eval(false == new Gen<double>().EqualNull(_double)); + + Guid _Guid = new Guid(); + Eval(false == new Gen<Guid>().EqualNull(_Guid)); + + string _string = "string"; + Eval(false == new Gen<string>().EqualNull(_string)); + Eval(true == new Gen<string>().EqualNull(null)); + + object _object = new object(); + Eval(false == new Gen<object>().EqualNull(_string)); + Eval(true == new Gen<object>().EqualNull(null)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/static_equalnull_struct01.cs b/tests/src/JIT/Generics/Fields/static_equalnull_struct01.cs new file mode 100644 index 0000000000..33aad4d738 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/static_equalnull_struct01.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public struct Gen<T> +{ + public static T Fld1; + + public bool EqualNull(T t) + { + Fld1 = t; + return ((object)Fld1 == null); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int = 0; + Eval(false == new Gen<int>().EqualNull(_int)); + + double _double = 0; + Eval(false == new Gen<double>().EqualNull(_double)); + + Guid _Guid = new Guid(); + Eval(false == new Gen<Guid>().EqualNull(_Guid)); + + string _string = "string"; + Eval(false == new Gen<string>().EqualNull(_string)); + Eval(true == new Gen<string>().EqualNull(null)); + + object _object = new object(); + Eval(false == new Gen<object>().EqualNull(_string)); + Eval(true == new Gen<object>().EqualNull(null)); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/static_passing_class01.cs b/tests/src/JIT/Generics/Fields/static_passing_class01.cs new file mode 100644 index 0000000000..07f6e33077 --- /dev/null +++ b/tests/src/JIT/Generics/Fields/static_passing_class01.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public class Gen<T> +{ + public static T Fld1; + public static T Fld2; + + public T PassAsIn(T t) + { + return t; + } + + public T PassAsRef(ref T t) + { + T temp = t; + t = Fld2; + return temp; + } + + public void PassAsOut(out T t) + { + t = Fld2; + } + public void PassAsParameter(T t1, T t2) + { + Fld1 = t1; + Fld2 = t2; + + T temp = t1; + + Test.Eval(Fld1.Equals(PassAsIn(temp))); + Test.Eval(Fld1.Equals(PassAsRef(ref temp))); + Test.Eval(Fld2.Equals(temp)); + temp = t1; + PassAsOut(out temp); + Test.Eval(Fld2.Equals(temp)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int1 = 1; + int _int2 = -1; + new Gen<int>().PassAsParameter(_int1, _int2); + + double _double1 = 1; + double _double2 = -1; + new Gen<double>().PassAsParameter(_double1, _double2); + + string _string1 = "string1"; + string _string2 = "string2"; + new Gen<string>().PassAsParameter(_string1, _string2); + + object _object1 = (object)_string1; + object _object2 = (object)_string2; + new Gen<object>().PassAsParameter(_object1, _object2); + + Guid _Guid1 = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Guid _Guid2 = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + new Gen<Guid>().PassAsParameter(_Guid1, _Guid2); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Fields/static_passing_struct01.cs b/tests/src/JIT/Generics/Fields/static_passing_struct01.cs new file mode 100644 index 0000000000..5a413f9e1a --- /dev/null +++ b/tests/src/JIT/Generics/Fields/static_passing_struct01.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; + +public struct ValX0 { } +public struct ValY0 { } +public struct ValX1<T> { } +public struct ValY1<T> { } +public struct ValX2<T, U> { } +public struct ValY2<T, U> { } +public struct ValX3<T, U, V> { } +public struct ValY3<T, U, V> { } +public class RefX0 { } +public class RefY0 { } +public class RefX1<T> { } +public class RefY1<T> { } +public class RefX2<T, U> { } +public class RefY2<T, U> { } +public class RefX3<T, U, V> { } +public class RefY3<T, U, V> { } + + +public struct Gen<T> +{ + public static T Fld1; + public static T Fld2; + + public T PassAsIn(T t) + { + return t; + } + + public T PassAsRef(ref T t) + { + T temp = t; + t = Fld2; + return temp; + } + + public void PassAsOut(out T t) + { + t = Fld2; + } + public void PassAsParameter(T t1, T t2) + { + Fld1 = t1; + Fld2 = t2; + + T temp = t1; + + Test.Eval(Fld1.Equals(PassAsIn(temp))); + Test.Eval(Fld1.Equals(PassAsRef(ref temp))); + Test.Eval(Fld2.Equals(temp)); + temp = t1; + PassAsOut(out temp); + Test.Eval(Fld2.Equals(temp)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + int _int1 = 1; + int _int2 = -1; + new Gen<int>().PassAsParameter(_int1, _int2); + + double _double1 = 1; + double _double2 = -1; + new Gen<double>().PassAsParameter(_double1, _double2); + + string _string1 = "string1"; + string _string2 = "string2"; + new Gen<string>().PassAsParameter(_string1, _string2); + + object _object1 = (object)_string1; + object _object2 = (object)_string2; + new Gen<object>().PassAsParameter(_object1, _object2); + + Guid _Guid1 = new Guid(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + Guid _Guid2 = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + new Gen<Guid>().PassAsParameter(_Guid1, _Guid2); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} |