diff options
author | Bengu Li <beli@microsoft.com> | 2015-04-27 11:33:49 -0700 |
---|---|---|
committer | Bengu Li <beli@microsoft.com> | 2015-04-27 11:33:49 -0700 |
commit | e3d15f17ccf274cff9a90a4a48cc83623d28d2ab (patch) | |
tree | 2421bd1ef344701012b2daed98a6f80810b33f47 /tests | |
parent | 7fc9feeedbabd0f7991aa519271bdc7bd2f740e0 (diff) | |
download | coreclr-e3d15f17ccf274cff9a90a4a48cc83623d28d2ab.tar.gz coreclr-e3d15f17ccf274cff9a90a4a48cc83623d28d2ab.tar.bz2 coreclr-e3d15f17ccf274cff9a90a4a48cc83623d28d2ab.zip |
Add Generic/Exceptions test cases for JIT
Add Generic/Exceptions test cases for JIT. Related proj, config files
added. Solution file update is delayed to later PRs for parallel working.
Passed build, buildtest, runtest.
Diffstat (limited to 'tests')
16 files changed, 2110 insertions, 0 deletions
diff --git a/tests/src/JIT/Generics/Exceptions/Exceptions.csproj b/tests/src/JIT/Generics/Exceptions/Exceptions.csproj new file mode 100644 index 0000000000..33b2928ebc --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/Exceptions.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/Exceptions/app.config b/tests/src/JIT/Generics/Exceptions/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/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/Exceptions/cs_template.proj b/tests/src/JIT/Generics/Exceptions/cs_template.proj new file mode 100644 index 0000000000..adc2f21e14 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/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/Exceptions/general_class_instance01.cs b/tests/src/JIT/Generics/Exceptions/general_class_instance01.cs new file mode 100644 index 0000000000..a12b1b5a80 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/general_class_instance01.cs @@ -0,0 +1,158 @@ +// 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 GenException<T> : Exception { } +public class Gen<T> +{ + public bool ExceptionTest(bool throwException) + { + string ExceptionClass = typeof(GenException<T>).ToString(); + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (Exception E) + { + string EText = E.ToString(); + // Ensure the type of the Exception --> this is currently broken + if ((EText != null) && (EText.IndexOf(ExceptionClass) >= 0)) + { + //Ensure we can correctly downcast the Exception to it's original type + try + { + GenException<T> tmp = (GenException<T>)E; + return true; + } + catch + { + Console.WriteLine("Failed to downcast Exception object for: " + typeof(Gen<T>)); + return false; + } + } + Console.WriteLine("Failed to detect " + ExceptionClass + " in Exception class string"); + return false; + } + } +} + +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() + { + Eval(new Gen<int>().ExceptionTest(true)); + Eval(new Gen<double>().ExceptionTest(true)); + Eval(new Gen<string>().ExceptionTest(true)); + Eval(new Gen<object>().ExceptionTest(true)); + Eval(new Gen<Guid>().ExceptionTest(true)); + + Eval(new Gen<int[]>().ExceptionTest(true)); + Eval(new Gen<double[,]>().ExceptionTest(true)); + Eval(new Gen<string[][][]>().ExceptionTest(true)); + Eval(new Gen<object[, , ,]>().ExceptionTest(true)); + Eval(new Gen<Guid[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<ValX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>>().ExceptionTest(true)); + Eval(new Gen<RefX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<RefX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<int>>().ExceptionTest(true)); + Eval(new Gen<ValX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<ValX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/general_class_static01.cs b/tests/src/JIT/Generics/Exceptions/general_class_static01.cs new file mode 100644 index 0000000000..e296afa71a --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/general_class_static01.cs @@ -0,0 +1,158 @@ +// 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 GenException<T> : Exception { } +public class Gen<T> +{ + public static bool ExceptionTest(bool throwException) + { + string ExceptionClass = typeof(GenException<T>).ToString(); + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (Exception E) + { + string EText = E.ToString(); + // Ensure the type of the Exception --> this is currently broken + if ((EText != null) && (EText.IndexOf(ExceptionClass) >= 0)) + { + //Ensure we can correctly downcast the Exception to it's original type + try + { + GenException<T> tmp = (GenException<T>)E; + return true; + } + catch + { + Console.WriteLine("Failed to downcast Exception object for: " + typeof(Gen<T>)); + return false; + } + } + Console.WriteLine("Failed to detect " + ExceptionClass + " in Exception class string"); + return false; + } + } +} + +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() + { + Eval(Gen<int>.ExceptionTest(true)); + Eval(Gen<double>.ExceptionTest(true)); + Eval(Gen<string>.ExceptionTest(true)); + Eval(Gen<object>.ExceptionTest(true)); + Eval(Gen<Guid>.ExceptionTest(true)); + + Eval(Gen<int[]>.ExceptionTest(true)); + Eval(Gen<double[,]>.ExceptionTest(true)); + Eval(Gen<string[][][]>.ExceptionTest(true)); + Eval(Gen<object[, , ,]>.ExceptionTest(true)); + Eval(Gen<Guid[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>[]>.ExceptionTest(true)); + Eval(Gen<RefX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX1<Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<RefX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<RefX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<ValX1<int>[]>.ExceptionTest(true)); + Eval(Gen<ValX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX1<Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<ValX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<ValX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>>.ExceptionTest(true)); + Eval(Gen<RefX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX2<int, string>>.ExceptionTest(true)); + Eval(Gen<RefX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<string>>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<int>>.ExceptionTest(true)); + Eval(Gen<ValX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX2<int, string>>.ExceptionTest(true)); + Eval(Gen<ValX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<string>>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/general_struct_instance01.cs b/tests/src/JIT/Generics/Exceptions/general_struct_instance01.cs new file mode 100644 index 0000000000..a771b5fb24 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/general_struct_instance01.cs @@ -0,0 +1,158 @@ +// 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 GenException<T> : Exception { } +public struct Gen<T> +{ + public bool ExceptionTest(bool throwException) + { + string ExceptionClass = typeof(GenException<T>).ToString(); + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (Exception E) + { + string EText = E.ToString(); + // Ensure the type of the Exception --> this is currently broken + if ((EText != null) && (EText.IndexOf(ExceptionClass) >= 0)) + { + //Ensure we can correctly downcast the Exception to it's original type + try + { + GenException<T> tmp = (GenException<T>)E; + return true; + } + catch + { + Console.WriteLine("Failed to downcast Exception object for: " + typeof(Gen<T>)); + return false; + } + } + Console.WriteLine("Failed to detect " + ExceptionClass + " in Exception class string"); + return false; + } + } +} + +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() + { + Eval(new Gen<int>().ExceptionTest(true)); + Eval(new Gen<double>().ExceptionTest(true)); + Eval(new Gen<string>().ExceptionTest(true)); + Eval(new Gen<object>().ExceptionTest(true)); + Eval(new Gen<Guid>().ExceptionTest(true)); + + Eval(new Gen<int[]>().ExceptionTest(true)); + Eval(new Gen<double[,]>().ExceptionTest(true)); + Eval(new Gen<string[][][]>().ExceptionTest(true)); + Eval(new Gen<object[, , ,]>().ExceptionTest(true)); + Eval(new Gen<Guid[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<ValX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>>().ExceptionTest(true)); + Eval(new Gen<RefX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<RefX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<int>>().ExceptionTest(true)); + Eval(new Gen<ValX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<ValX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/general_struct_static01.cs b/tests/src/JIT/Generics/Exceptions/general_struct_static01.cs new file mode 100644 index 0000000000..4ce258b1ac --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/general_struct_static01.cs @@ -0,0 +1,158 @@ +// 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 GenException<T> : Exception { } +public struct Gen<T> +{ + public static bool ExceptionTest(bool throwException) + { + string ExceptionClass = typeof(GenException<T>).ToString(); + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (Exception E) + { + string EText = E.ToString(); + // Ensure the type of the Exception --> this is currently broken + if ((EText != null) && (EText.IndexOf(ExceptionClass) >= 0)) + { + //Ensure we can correctly downcast the Exception to it's original type + try + { + GenException<T> tmp = (GenException<T>)E; + return true; + } + catch + { + Console.WriteLine("Failed to downcast Exception object for: " + typeof(Gen<T>)); + return false; + } + } + Console.WriteLine("Failed to detect " + ExceptionClass + " in Exception class string"); + return false; + } + } +} + +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() + { + Eval(Gen<int>.ExceptionTest(true)); + Eval(Gen<double>.ExceptionTest(true)); + Eval(Gen<string>.ExceptionTest(true)); + Eval(Gen<object>.ExceptionTest(true)); + Eval(Gen<Guid>.ExceptionTest(true)); + + Eval(Gen<int[]>.ExceptionTest(true)); + Eval(Gen<double[,]>.ExceptionTest(true)); + Eval(Gen<string[][][]>.ExceptionTest(true)); + Eval(Gen<object[, , ,]>.ExceptionTest(true)); + Eval(Gen<Guid[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>[]>.ExceptionTest(true)); + Eval(Gen<RefX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX1<Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<RefX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<RefX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<ValX1<int>[]>.ExceptionTest(true)); + Eval(Gen<ValX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX1<Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<ValX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<ValX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>>.ExceptionTest(true)); + Eval(Gen<RefX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX2<int, string>>.ExceptionTest(true)); + Eval(Gen<RefX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<string>>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<int>>.ExceptionTest(true)); + Eval(Gen<ValX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX2<int, string>>.ExceptionTest(true)); + Eval(Gen<ValX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<string>>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/packages.config b/tests/src/JIT/Generics/Exceptions/packages.config new file mode 100644 index 0000000000..06d3d11ead --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/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/Exceptions/specific_class_instance01.cs b/tests/src/JIT/Generics/Exceptions/specific_class_instance01.cs new file mode 100644 index 0000000000..44f5b8dec8 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_class_instance01.cs @@ -0,0 +1,145 @@ +// 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 GenException<T> : Exception { } +public class Gen<T> +{ + public bool ExceptionTest(bool throwException) + { + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (GenException<T>) + { + return true; + } + catch + { + Console.WriteLine("Caught Wrong Exception"); + return false; + } + } +} + +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() + { + Eval(new Gen<int>().ExceptionTest(true)); + Eval(new Gen<double>().ExceptionTest(true)); + Eval(new Gen<string>().ExceptionTest(true)); + Eval(new Gen<object>().ExceptionTest(true)); + Eval(new Gen<Guid>().ExceptionTest(true)); + + Eval(new Gen<int[]>().ExceptionTest(true)); + Eval(new Gen<double[,]>().ExceptionTest(true)); + Eval(new Gen<string[][][]>().ExceptionTest(true)); + Eval(new Gen<object[, , ,]>().ExceptionTest(true)); + Eval(new Gen<Guid[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<ValX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>>().ExceptionTest(true)); + Eval(new Gen<RefX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<RefX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<int>>().ExceptionTest(true)); + Eval(new Gen<ValX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<ValX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_class_instance02.cs b/tests/src/JIT/Generics/Exceptions/specific_class_instance02.cs new file mode 100644 index 0000000000..beaa9f52bc --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_class_instance02.cs @@ -0,0 +1,201 @@ +// 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 GenException<T> : Exception { } +public class Gen<T> +{ + public bool ExceptionTest(bool throwException) + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } +} +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + counter++; + + } + + public static int Main() + { + int cLabel = 0; + + while (cLabel < 50) + { + try + { + switch (cLabel) + { + case 0: cLabel++; new Gen<int>().ExceptionTest(true); break; + case 1: cLabel++; new Gen<double>().ExceptionTest(true); break; + case 2: cLabel++; new Gen<string>().ExceptionTest(true); break; + case 3: cLabel++; new Gen<object>().ExceptionTest(true); break; + case 4: cLabel++; new Gen<Guid>().ExceptionTest(true); break; + + case 5: cLabel++; new Gen<int[]>().ExceptionTest(true); break; + case 6: cLabel++; new Gen<double[,]>().ExceptionTest(true); break; + case 7: cLabel++; new Gen<string[][][]>().ExceptionTest(true); break; + case 8: cLabel++; new Gen<object[, , ,]>().ExceptionTest(true); break; + case 9: cLabel++; new Gen<Guid[][, , ,][]>().ExceptionTest(true); break; + + case 10: cLabel++; new Gen<RefX1<int>[]>().ExceptionTest(true); break; + case 11: cLabel++; new Gen<RefX1<double>[,]>().ExceptionTest(true); break; + case 12: cLabel++; new Gen<RefX1<string>[][][]>().ExceptionTest(true); break; + case 13: cLabel++; new Gen<RefX1<object>[, , ,]>().ExceptionTest(true); break; + case 14: cLabel++; new Gen<RefX1<Guid>[][, , ,][]>().ExceptionTest(true); break; + case 15: cLabel++; new Gen<RefX2<int, int>[]>().ExceptionTest(true); break; + case 16: cLabel++; new Gen<RefX2<double, double>[,]>().ExceptionTest(true); break; + case 17: cLabel++; new Gen<RefX2<string, string>[][][]>().ExceptionTest(true); break; + case 18: cLabel++; new Gen<RefX2<object, object>[, , ,]>().ExceptionTest(true); break; + case 19: cLabel++; new Gen<RefX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true); break; + case 20: cLabel++; new Gen<ValX1<int>[]>().ExceptionTest(true); break; + case 21: cLabel++; new Gen<ValX1<double>[,]>().ExceptionTest(true); break; + case 22: cLabel++; new Gen<ValX1<string>[][][]>().ExceptionTest(true); break; + case 23: cLabel++; new Gen<ValX1<object>[, , ,]>().ExceptionTest(true); break; + case 24: cLabel++; new Gen<ValX1<Guid>[][, , ,][]>().ExceptionTest(true); break; + + case 25: cLabel++; new Gen<ValX2<int, int>[]>().ExceptionTest(true); break; + case 26: cLabel++; new Gen<ValX2<double, double>[,]>().ExceptionTest(true); break; + case 27: cLabel++; new Gen<ValX2<string, string>[][][]>().ExceptionTest(true); break; + case 28: cLabel++; new Gen<ValX2<object, object>[, , ,]>().ExceptionTest(true); break; + case 29: cLabel++; new Gen<ValX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true); break; + + case 30: cLabel++; new Gen<RefX1<int>>().ExceptionTest(true); break; + case 31: cLabel++; new Gen<RefX1<ValX1<int>>>().ExceptionTest(true); break; + case 32: cLabel++; new Gen<RefX2<int, string>>().ExceptionTest(true); break; + case 33: cLabel++; new Gen<RefX3<int, string, Guid>>().ExceptionTest(true); break; + + case 34: cLabel++; new Gen<RefX1<RefX1<int>>>().ExceptionTest(true); break; + case 35: cLabel++; new Gen<RefX1<RefX1<RefX1<string>>>>().ExceptionTest(true); break; + case 36: cLabel++; new Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>().ExceptionTest(true); break; + + case 37: cLabel++; new Gen<RefX1<RefX2<int, string>>>().ExceptionTest(true); break; + case 38: cLabel++; new Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>().ExceptionTest(true); break; + case 39: cLabel++; new Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true); break; + + case 40: cLabel++; new Gen<ValX1<int>>().ExceptionTest(true); break; + case 41: cLabel++; new Gen<ValX1<RefX1<int>>>().ExceptionTest(true); break; + case 42: cLabel++; new Gen<ValX2<int, string>>().ExceptionTest(true); break; + case 43: cLabel++; new Gen<ValX3<int, string, Guid>>().ExceptionTest(true); break; + + case 44: cLabel++; new Gen<ValX1<ValX1<int>>>().ExceptionTest(true); break; + case 45: cLabel++; new Gen<ValX1<ValX1<ValX1<string>>>>().ExceptionTest(true); break; + case 46: cLabel++; new Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>().ExceptionTest(true); break; + + case 47: cLabel++; new Gen<ValX1<ValX2<int, string>>>().ExceptionTest(true); break; + case 48: cLabel++; new Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>().ExceptionTest(true); break; + case 49: cLabel++; new Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true); break; + } + } + + catch (GenException<int>) { Eval(cLabel == 1); } + catch (GenException<double>) { Eval(cLabel == 2); } + catch (GenException<string>) { Eval(cLabel == 3); } + catch (GenException<object>) { Eval(cLabel == 4); } + catch (GenException<Guid>) { Eval(cLabel == 5); } + + catch (GenException<int[]>) { Eval(cLabel == 6); } + catch (GenException<double[,]>) { Eval(cLabel == 7); } + catch (GenException<string[][][]>) { Eval(cLabel == 8); } + catch (GenException<object[, , ,]>) { Eval(cLabel == 9); } + catch (GenException<Guid[][, , ,][]>) { Eval(cLabel == 10); } + + catch (GenException<RefX1<int>[]>) { Eval(cLabel == 11); } + catch (GenException<RefX1<double>[,]>) { Eval(cLabel == 12); } + catch (GenException<RefX1<string>[][][]>) { Eval(cLabel == 13); } + catch (GenException<RefX1<object>[, , ,]>) { Eval(cLabel == 14); } + catch (GenException<RefX1<Guid>[][, , ,][]>) { Eval(cLabel == 15); } + catch (GenException<RefX2<int, int>[]>) { Eval(cLabel == 16); } + catch (GenException<RefX2<double, double>[,]>) { Eval(cLabel == 17); } + catch (GenException<RefX2<string, string>[][][]>) { Eval(cLabel == 18); } + catch (GenException<RefX2<object, object>[, , ,]>) { Eval(cLabel == 19); } + catch (GenException<RefX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 20); } + catch (GenException<ValX1<int>[]>) { Eval(cLabel == 21); } + catch (GenException<ValX1<double>[,]>) { Eval(cLabel == 22); } + catch (GenException<ValX1<string>[][][]>) { Eval(cLabel == 23); } + catch (GenException<ValX1<object>[, , ,]>) { Eval(cLabel == 24); } + catch (GenException<ValX1<Guid>[][, , ,][]>) { Eval(cLabel == 25); } + + catch (GenException<ValX2<int, int>[]>) { Eval(cLabel == 26); } + catch (GenException<ValX2<double, double>[,]>) { Eval(cLabel == 27); } + catch (GenException<ValX2<string, string>[][][]>) { Eval(cLabel == 28); } + catch (GenException<ValX2<object, object>[, , ,]>) { Eval(cLabel == 29); } + catch (GenException<ValX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 30); } + + catch (GenException<RefX1<int>>) { Eval(cLabel == 31); } + catch (GenException<RefX1<ValX1<int>>>) { Eval(cLabel == 32); } + catch (GenException<RefX2<int, string>>) { Eval(cLabel == 33); } + catch (GenException<RefX3<int, string, Guid>>) { Eval(cLabel == 34); } + + catch (GenException<RefX1<RefX1<int>>>) { Eval(cLabel == 35); } + catch (GenException<RefX1<RefX1<RefX1<string>>>>) { Eval(cLabel == 36); } + catch (GenException<RefX1<RefX1<RefX1<RefX1<Guid>>>>>) { Eval(cLabel == 37); } + + catch (GenException<RefX1<RefX2<int, string>>>) { Eval(cLabel == 38); } + catch (GenException<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>) { Eval(cLabel == 39); } + catch (GenException<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 40); } + + catch (GenException<ValX1<int>>) { Eval(cLabel == 41); } + catch (GenException<ValX1<RefX1<int>>>) { Eval(cLabel == 42); } + catch (GenException<ValX2<int, string>>) { Eval(cLabel == 43); } + catch (GenException<ValX3<int, string, Guid>>) { Eval(cLabel == 44); } + + catch (GenException<ValX1<ValX1<int>>>) { Eval(cLabel == 45); } + catch (GenException<ValX1<ValX1<ValX1<string>>>>) { Eval(cLabel == 46); } + catch (GenException<ValX1<ValX1<ValX1<ValX1<Guid>>>>>) { Eval(cLabel == 47); } + + catch (GenException<ValX1<ValX2<int, string>>>) { Eval(cLabel == 48); } + catch (GenException<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>) { Eval(cLabel == 49); } + catch (GenException<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 50); } + } + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_class_static01.cs b/tests/src/JIT/Generics/Exceptions/specific_class_static01.cs new file mode 100644 index 0000000000..5a2faa5d00 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_class_static01.cs @@ -0,0 +1,145 @@ +// 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 GenException<T> : Exception { } +public class Gen<T> +{ + public static bool ExceptionTest(bool throwException) + { + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (GenException<T>) + { + return true; + } + catch + { + Console.WriteLine("Caught Wrong Exception"); + return false; + } + } +} + +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() + { + Eval(Gen<int>.ExceptionTest(true)); + Eval(Gen<double>.ExceptionTest(true)); + Eval(Gen<string>.ExceptionTest(true)); + Eval(Gen<object>.ExceptionTest(true)); + Eval(Gen<Guid>.ExceptionTest(true)); + + Eval(Gen<int[]>.ExceptionTest(true)); + Eval(Gen<double[,]>.ExceptionTest(true)); + Eval(Gen<string[][][]>.ExceptionTest(true)); + Eval(Gen<object[, , ,]>.ExceptionTest(true)); + Eval(Gen<Guid[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>[]>.ExceptionTest(true)); + Eval(Gen<RefX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX1<Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<RefX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<RefX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<ValX1<int>[]>.ExceptionTest(true)); + Eval(Gen<ValX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX1<Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<ValX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<ValX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>>.ExceptionTest(true)); + Eval(Gen<RefX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX2<int, string>>.ExceptionTest(true)); + Eval(Gen<RefX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<string>>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<int>>.ExceptionTest(true)); + Eval(Gen<ValX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX2<int, string>>.ExceptionTest(true)); + Eval(Gen<ValX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<string>>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_class_static02.cs b/tests/src/JIT/Generics/Exceptions/specific_class_static02.cs new file mode 100644 index 0000000000..fdbdde2227 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_class_static02.cs @@ -0,0 +1,201 @@ +// 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 GenException<T> : Exception { } +public class Gen<T> +{ + public static bool ExceptionTest(bool throwException) + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } +} +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + counter++; + + } + + public static int Main() + { + int cLabel = 0; + + while (cLabel < 50) + { + try + { + switch (cLabel) + { + case 0: cLabel++; Gen<int>.ExceptionTest(true); break; + case 1: cLabel++; Gen<double>.ExceptionTest(true); break; + case 2: cLabel++; Gen<string>.ExceptionTest(true); break; + case 3: cLabel++; Gen<object>.ExceptionTest(true); break; + case 4: cLabel++; Gen<Guid>.ExceptionTest(true); break; + + case 5: cLabel++; Gen<int[]>.ExceptionTest(true); break; + case 6: cLabel++; Gen<double[,]>.ExceptionTest(true); break; + case 7: cLabel++; Gen<string[][][]>.ExceptionTest(true); break; + case 8: cLabel++; Gen<object[, , ,]>.ExceptionTest(true); break; + case 9: cLabel++; Gen<Guid[][, , ,][]>.ExceptionTest(true); break; + + case 10: cLabel++; Gen<RefX1<int>[]>.ExceptionTest(true); break; + case 11: cLabel++; Gen<RefX1<double>[,]>.ExceptionTest(true); break; + case 12: cLabel++; Gen<RefX1<string>[][][]>.ExceptionTest(true); break; + case 13: cLabel++; Gen<RefX1<object>[, , ,]>.ExceptionTest(true); break; + case 14: cLabel++; Gen<RefX1<Guid>[][, , ,][]>.ExceptionTest(true); break; + case 15: cLabel++; Gen<RefX2<int, int>[]>.ExceptionTest(true); break; + case 16: cLabel++; Gen<RefX2<double, double>[,]>.ExceptionTest(true); break; + case 17: cLabel++; Gen<RefX2<string, string>[][][]>.ExceptionTest(true); break; + case 18: cLabel++; Gen<RefX2<object, object>[, , ,]>.ExceptionTest(true); break; + case 19: cLabel++; Gen<RefX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true); break; + case 20: cLabel++; Gen<ValX1<int>[]>.ExceptionTest(true); break; + case 21: cLabel++; Gen<ValX1<double>[,]>.ExceptionTest(true); break; + case 22: cLabel++; Gen<ValX1<string>[][][]>.ExceptionTest(true); break; + case 23: cLabel++; Gen<ValX1<object>[, , ,]>.ExceptionTest(true); break; + case 24: cLabel++; Gen<ValX1<Guid>[][, , ,][]>.ExceptionTest(true); break; + + case 25: cLabel++; Gen<ValX2<int, int>[]>.ExceptionTest(true); break; + case 26: cLabel++; Gen<ValX2<double, double>[,]>.ExceptionTest(true); break; + case 27: cLabel++; Gen<ValX2<string, string>[][][]>.ExceptionTest(true); break; + case 28: cLabel++; Gen<ValX2<object, object>[, , ,]>.ExceptionTest(true); break; + case 29: cLabel++; Gen<ValX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true); break; + + case 30: cLabel++; Gen<RefX1<int>>.ExceptionTest(true); break; + case 31: cLabel++; Gen<RefX1<ValX1<int>>>.ExceptionTest(true); break; + case 32: cLabel++; Gen<RefX2<int, string>>.ExceptionTest(true); break; + case 33: cLabel++; Gen<RefX3<int, string, Guid>>.ExceptionTest(true); break; + + case 34: cLabel++; Gen<RefX1<RefX1<int>>>.ExceptionTest(true); break; + case 35: cLabel++; Gen<RefX1<RefX1<RefX1<string>>>>.ExceptionTest(true); break; + case 36: cLabel++; Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>.ExceptionTest(true); break; + + case 37: cLabel++; Gen<RefX1<RefX2<int, string>>>.ExceptionTest(true); break; + case 38: cLabel++; Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>.ExceptionTest(true); break; + case 39: cLabel++; Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true); break; + + case 40: cLabel++; Gen<ValX1<int>>.ExceptionTest(true); break; + case 41: cLabel++; Gen<ValX1<RefX1<int>>>.ExceptionTest(true); break; + case 42: cLabel++; Gen<ValX2<int, string>>.ExceptionTest(true); break; + case 43: cLabel++; Gen<ValX3<int, string, Guid>>.ExceptionTest(true); break; + + case 44: cLabel++; Gen<ValX1<ValX1<int>>>.ExceptionTest(true); break; + case 45: cLabel++; Gen<ValX1<ValX1<ValX1<string>>>>.ExceptionTest(true); break; + case 46: cLabel++; Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>.ExceptionTest(true); break; + + case 47: cLabel++; Gen<ValX1<ValX2<int, string>>>.ExceptionTest(true); break; + case 48: cLabel++; Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>.ExceptionTest(true); break; + case 49: cLabel++; Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true); break; + } + } + + catch (GenException<int>) { Eval(cLabel == 1); } + catch (GenException<double>) { Eval(cLabel == 2); } + catch (GenException<string>) { Eval(cLabel == 3); } + catch (GenException<object>) { Eval(cLabel == 4); } + catch (GenException<Guid>) { Eval(cLabel == 5); } + + catch (GenException<int[]>) { Eval(cLabel == 6); } + catch (GenException<double[,]>) { Eval(cLabel == 7); } + catch (GenException<string[][][]>) { Eval(cLabel == 8); } + catch (GenException<object[, , ,]>) { Eval(cLabel == 9); } + catch (GenException<Guid[][, , ,][]>) { Eval(cLabel == 10); } + + catch (GenException<RefX1<int>[]>) { Eval(cLabel == 11); } + catch (GenException<RefX1<double>[,]>) { Eval(cLabel == 12); } + catch (GenException<RefX1<string>[][][]>) { Eval(cLabel == 13); } + catch (GenException<RefX1<object>[, , ,]>) { Eval(cLabel == 14); } + catch (GenException<RefX1<Guid>[][, , ,][]>) { Eval(cLabel == 15); } + catch (GenException<RefX2<int, int>[]>) { Eval(cLabel == 16); } + catch (GenException<RefX2<double, double>[,]>) { Eval(cLabel == 17); } + catch (GenException<RefX2<string, string>[][][]>) { Eval(cLabel == 18); } + catch (GenException<RefX2<object, object>[, , ,]>) { Eval(cLabel == 19); } + catch (GenException<RefX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 20); } + catch (GenException<ValX1<int>[]>) { Eval(cLabel == 21); } + catch (GenException<ValX1<double>[,]>) { Eval(cLabel == 22); } + catch (GenException<ValX1<string>[][][]>) { Eval(cLabel == 23); } + catch (GenException<ValX1<object>[, , ,]>) { Eval(cLabel == 24); } + catch (GenException<ValX1<Guid>[][, , ,][]>) { Eval(cLabel == 25); } + + catch (GenException<ValX2<int, int>[]>) { Eval(cLabel == 26); } + catch (GenException<ValX2<double, double>[,]>) { Eval(cLabel == 27); } + catch (GenException<ValX2<string, string>[][][]>) { Eval(cLabel == 28); } + catch (GenException<ValX2<object, object>[, , ,]>) { Eval(cLabel == 29); } + catch (GenException<ValX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 30); } + + catch (GenException<RefX1<int>>) { Eval(cLabel == 31); } + catch (GenException<RefX1<ValX1<int>>>) { Eval(cLabel == 32); } + catch (GenException<RefX2<int, string>>) { Eval(cLabel == 33); } + catch (GenException<RefX3<int, string, Guid>>) { Eval(cLabel == 34); } + + catch (GenException<RefX1<RefX1<int>>>) { Eval(cLabel == 35); } + catch (GenException<RefX1<RefX1<RefX1<string>>>>) { Eval(cLabel == 36); } + catch (GenException<RefX1<RefX1<RefX1<RefX1<Guid>>>>>) { Eval(cLabel == 37); } + + catch (GenException<RefX1<RefX2<int, string>>>) { Eval(cLabel == 38); } + catch (GenException<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>) { Eval(cLabel == 39); } + catch (GenException<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 40); } + + catch (GenException<ValX1<int>>) { Eval(cLabel == 41); } + catch (GenException<ValX1<RefX1<int>>>) { Eval(cLabel == 42); } + catch (GenException<ValX2<int, string>>) { Eval(cLabel == 43); } + catch (GenException<ValX3<int, string, Guid>>) { Eval(cLabel == 44); } + + catch (GenException<ValX1<ValX1<int>>>) { Eval(cLabel == 45); } + catch (GenException<ValX1<ValX1<ValX1<string>>>>) { Eval(cLabel == 46); } + catch (GenException<ValX1<ValX1<ValX1<ValX1<Guid>>>>>) { Eval(cLabel == 47); } + + catch (GenException<ValX1<ValX2<int, string>>>) { Eval(cLabel == 48); } + catch (GenException<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>) { Eval(cLabel == 49); } + catch (GenException<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 50); } + } + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_struct_instance01.cs b/tests/src/JIT/Generics/Exceptions/specific_struct_instance01.cs new file mode 100644 index 0000000000..a90b082c66 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_struct_instance01.cs @@ -0,0 +1,145 @@ +// 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 GenException<T> : Exception { } +public struct Gen<T> +{ + public bool ExceptionTest(bool throwException) + { + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (GenException<T>) + { + return true; + } + catch + { + Console.WriteLine("Caught Wrong Exception"); + return false; + } + } +} + +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() + { + Eval(new Gen<int>().ExceptionTest(true)); + Eval(new Gen<double>().ExceptionTest(true)); + Eval(new Gen<string>().ExceptionTest(true)); + Eval(new Gen<object>().ExceptionTest(true)); + Eval(new Gen<Guid>().ExceptionTest(true)); + + Eval(new Gen<int[]>().ExceptionTest(true)); + Eval(new Gen<double[,]>().ExceptionTest(true)); + Eval(new Gen<string[][][]>().ExceptionTest(true)); + Eval(new Gen<object[, , ,]>().ExceptionTest(true)); + Eval(new Gen<Guid[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX1<Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<RefX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<RefX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<RefX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX1<double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX1<object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX1<Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<ValX2<int, int>[]>().ExceptionTest(true)); + Eval(new Gen<ValX2<double, double>[,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<string, string>[][][]>().ExceptionTest(true)); + Eval(new Gen<ValX2<object, object>[, , ,]>().ExceptionTest(true)); + Eval(new Gen<ValX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true)); + + Eval(new Gen<RefX1<int>>().ExceptionTest(true)); + Eval(new Gen<RefX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<RefX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<RefX1<RefX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<int>>().ExceptionTest(true)); + Eval(new Gen<ValX1<RefX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<int, string>>().ExceptionTest(true)); + Eval(new Gen<ValX3<int, string, Guid>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX1<int>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<string>>>>().ExceptionTest(true)); + Eval(new Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>().ExceptionTest(true)); + + Eval(new Gen<ValX1<ValX2<int, string>>>().ExceptionTest(true)); + Eval(new Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>().ExceptionTest(true)); + Eval(new Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_struct_instance02.cs b/tests/src/JIT/Generics/Exceptions/specific_struct_instance02.cs new file mode 100644 index 0000000000..3c73d1d7b1 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_struct_instance02.cs @@ -0,0 +1,201 @@ +// 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 GenException<T> : Exception { } +public struct Gen<T> +{ + public bool ExceptionTest(bool throwException) + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } +} +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + counter++; + + } + + public static int Main() + { + int cLabel = 0; + + while (cLabel < 50) + { + try + { + switch (cLabel) + { + case 0: cLabel++; new Gen<int>().ExceptionTest(true); break; + case 1: cLabel++; new Gen<double>().ExceptionTest(true); break; + case 2: cLabel++; new Gen<string>().ExceptionTest(true); break; + case 3: cLabel++; new Gen<object>().ExceptionTest(true); break; + case 4: cLabel++; new Gen<Guid>().ExceptionTest(true); break; + + case 5: cLabel++; new Gen<int[]>().ExceptionTest(true); break; + case 6: cLabel++; new Gen<double[,]>().ExceptionTest(true); break; + case 7: cLabel++; new Gen<string[][][]>().ExceptionTest(true); break; + case 8: cLabel++; new Gen<object[, , ,]>().ExceptionTest(true); break; + case 9: cLabel++; new Gen<Guid[][, , ,][]>().ExceptionTest(true); break; + + case 10: cLabel++; new Gen<RefX1<int>[]>().ExceptionTest(true); break; + case 11: cLabel++; new Gen<RefX1<double>[,]>().ExceptionTest(true); break; + case 12: cLabel++; new Gen<RefX1<string>[][][]>().ExceptionTest(true); break; + case 13: cLabel++; new Gen<RefX1<object>[, , ,]>().ExceptionTest(true); break; + case 14: cLabel++; new Gen<RefX1<Guid>[][, , ,][]>().ExceptionTest(true); break; + case 15: cLabel++; new Gen<RefX2<int, int>[]>().ExceptionTest(true); break; + case 16: cLabel++; new Gen<RefX2<double, double>[,]>().ExceptionTest(true); break; + case 17: cLabel++; new Gen<RefX2<string, string>[][][]>().ExceptionTest(true); break; + case 18: cLabel++; new Gen<RefX2<object, object>[, , ,]>().ExceptionTest(true); break; + case 19: cLabel++; new Gen<RefX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true); break; + case 20: cLabel++; new Gen<ValX1<int>[]>().ExceptionTest(true); break; + case 21: cLabel++; new Gen<ValX1<double>[,]>().ExceptionTest(true); break; + case 22: cLabel++; new Gen<ValX1<string>[][][]>().ExceptionTest(true); break; + case 23: cLabel++; new Gen<ValX1<object>[, , ,]>().ExceptionTest(true); break; + case 24: cLabel++; new Gen<ValX1<Guid>[][, , ,][]>().ExceptionTest(true); break; + + case 25: cLabel++; new Gen<ValX2<int, int>[]>().ExceptionTest(true); break; + case 26: cLabel++; new Gen<ValX2<double, double>[,]>().ExceptionTest(true); break; + case 27: cLabel++; new Gen<ValX2<string, string>[][][]>().ExceptionTest(true); break; + case 28: cLabel++; new Gen<ValX2<object, object>[, , ,]>().ExceptionTest(true); break; + case 29: cLabel++; new Gen<ValX2<Guid, Guid>[][, , ,][]>().ExceptionTest(true); break; + + case 30: cLabel++; new Gen<RefX1<int>>().ExceptionTest(true); break; + case 31: cLabel++; new Gen<RefX1<ValX1<int>>>().ExceptionTest(true); break; + case 32: cLabel++; new Gen<RefX2<int, string>>().ExceptionTest(true); break; + case 33: cLabel++; new Gen<RefX3<int, string, Guid>>().ExceptionTest(true); break; + + case 34: cLabel++; new Gen<RefX1<RefX1<int>>>().ExceptionTest(true); break; + case 35: cLabel++; new Gen<RefX1<RefX1<RefX1<string>>>>().ExceptionTest(true); break; + case 36: cLabel++; new Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>().ExceptionTest(true); break; + + case 37: cLabel++; new Gen<RefX1<RefX2<int, string>>>().ExceptionTest(true); break; + case 38: cLabel++; new Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>().ExceptionTest(true); break; + case 39: cLabel++; new Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true); break; + + case 40: cLabel++; new Gen<ValX1<int>>().ExceptionTest(true); break; + case 41: cLabel++; new Gen<ValX1<RefX1<int>>>().ExceptionTest(true); break; + case 42: cLabel++; new Gen<ValX2<int, string>>().ExceptionTest(true); break; + case 43: cLabel++; new Gen<ValX3<int, string, Guid>>().ExceptionTest(true); break; + + case 44: cLabel++; new Gen<ValX1<ValX1<int>>>().ExceptionTest(true); break; + case 45: cLabel++; new Gen<ValX1<ValX1<ValX1<string>>>>().ExceptionTest(true); break; + case 46: cLabel++; new Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>().ExceptionTest(true); break; + + case 47: cLabel++; new Gen<ValX1<ValX2<int, string>>>().ExceptionTest(true); break; + case 48: cLabel++; new Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>().ExceptionTest(true); break; + case 49: cLabel++; new Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>().ExceptionTest(true); break; + } + } + + catch (GenException<int>) { Eval(cLabel == 1); } + catch (GenException<double>) { Eval(cLabel == 2); } + catch (GenException<string>) { Eval(cLabel == 3); } + catch (GenException<object>) { Eval(cLabel == 4); } + catch (GenException<Guid>) { Eval(cLabel == 5); } + + catch (GenException<int[]>) { Eval(cLabel == 6); } + catch (GenException<double[,]>) { Eval(cLabel == 7); } + catch (GenException<string[][][]>) { Eval(cLabel == 8); } + catch (GenException<object[, , ,]>) { Eval(cLabel == 9); } + catch (GenException<Guid[][, , ,][]>) { Eval(cLabel == 10); } + + catch (GenException<RefX1<int>[]>) { Eval(cLabel == 11); } + catch (GenException<RefX1<double>[,]>) { Eval(cLabel == 12); } + catch (GenException<RefX1<string>[][][]>) { Eval(cLabel == 13); } + catch (GenException<RefX1<object>[, , ,]>) { Eval(cLabel == 14); } + catch (GenException<RefX1<Guid>[][, , ,][]>) { Eval(cLabel == 15); } + catch (GenException<RefX2<int, int>[]>) { Eval(cLabel == 16); } + catch (GenException<RefX2<double, double>[,]>) { Eval(cLabel == 17); } + catch (GenException<RefX2<string, string>[][][]>) { Eval(cLabel == 18); } + catch (GenException<RefX2<object, object>[, , ,]>) { Eval(cLabel == 19); } + catch (GenException<RefX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 20); } + catch (GenException<ValX1<int>[]>) { Eval(cLabel == 21); } + catch (GenException<ValX1<double>[,]>) { Eval(cLabel == 22); } + catch (GenException<ValX1<string>[][][]>) { Eval(cLabel == 23); } + catch (GenException<ValX1<object>[, , ,]>) { Eval(cLabel == 24); } + catch (GenException<ValX1<Guid>[][, , ,][]>) { Eval(cLabel == 25); } + + catch (GenException<ValX2<int, int>[]>) { Eval(cLabel == 26); } + catch (GenException<ValX2<double, double>[,]>) { Eval(cLabel == 27); } + catch (GenException<ValX2<string, string>[][][]>) { Eval(cLabel == 28); } + catch (GenException<ValX2<object, object>[, , ,]>) { Eval(cLabel == 29); } + catch (GenException<ValX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 30); } + + catch (GenException<RefX1<int>>) { Eval(cLabel == 31); } + catch (GenException<RefX1<ValX1<int>>>) { Eval(cLabel == 32); } + catch (GenException<RefX2<int, string>>) { Eval(cLabel == 33); } + catch (GenException<RefX3<int, string, Guid>>) { Eval(cLabel == 34); } + + catch (GenException<RefX1<RefX1<int>>>) { Eval(cLabel == 35); } + catch (GenException<RefX1<RefX1<RefX1<string>>>>) { Eval(cLabel == 36); } + catch (GenException<RefX1<RefX1<RefX1<RefX1<Guid>>>>>) { Eval(cLabel == 37); } + + catch (GenException<RefX1<RefX2<int, string>>>) { Eval(cLabel == 38); } + catch (GenException<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>) { Eval(cLabel == 39); } + catch (GenException<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 40); } + + catch (GenException<ValX1<int>>) { Eval(cLabel == 41); } + catch (GenException<ValX1<RefX1<int>>>) { Eval(cLabel == 42); } + catch (GenException<ValX2<int, string>>) { Eval(cLabel == 43); } + catch (GenException<ValX3<int, string, Guid>>) { Eval(cLabel == 44); } + + catch (GenException<ValX1<ValX1<int>>>) { Eval(cLabel == 45); } + catch (GenException<ValX1<ValX1<ValX1<string>>>>) { Eval(cLabel == 46); } + catch (GenException<ValX1<ValX1<ValX1<ValX1<Guid>>>>>) { Eval(cLabel == 47); } + + catch (GenException<ValX1<ValX2<int, string>>>) { Eval(cLabel == 48); } + catch (GenException<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>) { Eval(cLabel == 49); } + catch (GenException<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 50); } + } + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_struct_static01.cs b/tests/src/JIT/Generics/Exceptions/specific_struct_static01.cs new file mode 100644 index 0000000000..28d00baaeb --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_struct_static01.cs @@ -0,0 +1,145 @@ +// 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 GenException<T> : Exception { } +public struct Gen<T> +{ + public static bool ExceptionTest(bool throwException) + { + try + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } + catch (GenException<T>) + { + return true; + } + catch + { + Console.WriteLine("Caught Wrong Exception"); + return false; + } + } +} + +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() + { + Eval(Gen<int>.ExceptionTest(true)); + Eval(Gen<double>.ExceptionTest(true)); + Eval(Gen<string>.ExceptionTest(true)); + Eval(Gen<object>.ExceptionTest(true)); + Eval(Gen<Guid>.ExceptionTest(true)); + + Eval(Gen<int[]>.ExceptionTest(true)); + Eval(Gen<double[,]>.ExceptionTest(true)); + Eval(Gen<string[][][]>.ExceptionTest(true)); + Eval(Gen<object[, , ,]>.ExceptionTest(true)); + Eval(Gen<Guid[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>[]>.ExceptionTest(true)); + Eval(Gen<RefX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX1<Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<RefX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<RefX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<RefX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<RefX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<RefX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + Eval(Gen<ValX1<int>[]>.ExceptionTest(true)); + Eval(Gen<ValX1<double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX1<string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX1<object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX1<Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<ValX2<int, int>[]>.ExceptionTest(true)); + Eval(Gen<ValX2<double, double>[,]>.ExceptionTest(true)); + Eval(Gen<ValX2<string, string>[][][]>.ExceptionTest(true)); + Eval(Gen<ValX2<object, object>[, , ,]>.ExceptionTest(true)); + Eval(Gen<ValX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true)); + + Eval(Gen<RefX1<int>>.ExceptionTest(true)); + Eval(Gen<RefX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX2<int, string>>.ExceptionTest(true)); + Eval(Gen<RefX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<string>>>>.ExceptionTest(true)); + Eval(Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<RefX1<RefX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<int>>.ExceptionTest(true)); + Eval(Gen<ValX1<RefX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX2<int, string>>.ExceptionTest(true)); + Eval(Gen<ValX3<int, string, Guid>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX1<int>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<string>>>>.ExceptionTest(true)); + Eval(Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>.ExceptionTest(true)); + + Eval(Gen<ValX1<ValX2<int, string>>>.ExceptionTest(true)); + Eval(Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>.ExceptionTest(true)); + Eval(Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true)); + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/JIT/Generics/Exceptions/specific_struct_static02.cs b/tests/src/JIT/Generics/Exceptions/specific_struct_static02.cs new file mode 100644 index 0000000000..063ce57968 --- /dev/null +++ b/tests/src/JIT/Generics/Exceptions/specific_struct_static02.cs @@ -0,0 +1,201 @@ +// 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 GenException<T> : Exception { } +public struct Gen<T> +{ + public static bool ExceptionTest(bool throwException) + { + if (throwException) + { + throw new GenException<T>(); + } + else + { + return true; + } + } +} +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + counter++; + + } + + public static int Main() + { + int cLabel = 0; + + while (cLabel < 50) + { + try + { + switch (cLabel) + { + case 0: cLabel++; Gen<int>.ExceptionTest(true); break; + case 1: cLabel++; Gen<double>.ExceptionTest(true); break; + case 2: cLabel++; Gen<string>.ExceptionTest(true); break; + case 3: cLabel++; Gen<object>.ExceptionTest(true); break; + case 4: cLabel++; Gen<Guid>.ExceptionTest(true); break; + + case 5: cLabel++; Gen<int[]>.ExceptionTest(true); break; + case 6: cLabel++; Gen<double[,]>.ExceptionTest(true); break; + case 7: cLabel++; Gen<string[][][]>.ExceptionTest(true); break; + case 8: cLabel++; Gen<object[, , ,]>.ExceptionTest(true); break; + case 9: cLabel++; Gen<Guid[][, , ,][]>.ExceptionTest(true); break; + + case 10: cLabel++; Gen<RefX1<int>[]>.ExceptionTest(true); break; + case 11: cLabel++; Gen<RefX1<double>[,]>.ExceptionTest(true); break; + case 12: cLabel++; Gen<RefX1<string>[][][]>.ExceptionTest(true); break; + case 13: cLabel++; Gen<RefX1<object>[, , ,]>.ExceptionTest(true); break; + case 14: cLabel++; Gen<RefX1<Guid>[][, , ,][]>.ExceptionTest(true); break; + case 15: cLabel++; Gen<RefX2<int, int>[]>.ExceptionTest(true); break; + case 16: cLabel++; Gen<RefX2<double, double>[,]>.ExceptionTest(true); break; + case 17: cLabel++; Gen<RefX2<string, string>[][][]>.ExceptionTest(true); break; + case 18: cLabel++; Gen<RefX2<object, object>[, , ,]>.ExceptionTest(true); break; + case 19: cLabel++; Gen<RefX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true); break; + case 20: cLabel++; Gen<ValX1<int>[]>.ExceptionTest(true); break; + case 21: cLabel++; Gen<ValX1<double>[,]>.ExceptionTest(true); break; + case 22: cLabel++; Gen<ValX1<string>[][][]>.ExceptionTest(true); break; + case 23: cLabel++; Gen<ValX1<object>[, , ,]>.ExceptionTest(true); break; + case 24: cLabel++; Gen<ValX1<Guid>[][, , ,][]>.ExceptionTest(true); break; + + case 25: cLabel++; Gen<ValX2<int, int>[]>.ExceptionTest(true); break; + case 26: cLabel++; Gen<ValX2<double, double>[,]>.ExceptionTest(true); break; + case 27: cLabel++; Gen<ValX2<string, string>[][][]>.ExceptionTest(true); break; + case 28: cLabel++; Gen<ValX2<object, object>[, , ,]>.ExceptionTest(true); break; + case 29: cLabel++; Gen<ValX2<Guid, Guid>[][, , ,][]>.ExceptionTest(true); break; + + case 30: cLabel++; Gen<RefX1<int>>.ExceptionTest(true); break; + case 31: cLabel++; Gen<RefX1<ValX1<int>>>.ExceptionTest(true); break; + case 32: cLabel++; Gen<RefX2<int, string>>.ExceptionTest(true); break; + case 33: cLabel++; Gen<RefX3<int, string, Guid>>.ExceptionTest(true); break; + + case 34: cLabel++; Gen<RefX1<RefX1<int>>>.ExceptionTest(true); break; + case 35: cLabel++; Gen<RefX1<RefX1<RefX1<string>>>>.ExceptionTest(true); break; + case 36: cLabel++; Gen<RefX1<RefX1<RefX1<RefX1<Guid>>>>>.ExceptionTest(true); break; + + case 37: cLabel++; Gen<RefX1<RefX2<int, string>>>.ExceptionTest(true); break; + case 38: cLabel++; Gen<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>.ExceptionTest(true); break; + case 39: cLabel++; Gen<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true); break; + + case 40: cLabel++; Gen<ValX1<int>>.ExceptionTest(true); break; + case 41: cLabel++; Gen<ValX1<RefX1<int>>>.ExceptionTest(true); break; + case 42: cLabel++; Gen<ValX2<int, string>>.ExceptionTest(true); break; + case 43: cLabel++; Gen<ValX3<int, string, Guid>>.ExceptionTest(true); break; + + case 44: cLabel++; Gen<ValX1<ValX1<int>>>.ExceptionTest(true); break; + case 45: cLabel++; Gen<ValX1<ValX1<ValX1<string>>>>.ExceptionTest(true); break; + case 46: cLabel++; Gen<ValX1<ValX1<ValX1<ValX1<Guid>>>>>.ExceptionTest(true); break; + + case 47: cLabel++; Gen<ValX1<ValX2<int, string>>>.ExceptionTest(true); break; + case 48: cLabel++; Gen<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>.ExceptionTest(true); break; + case 49: cLabel++; Gen<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>.ExceptionTest(true); break; + } + } + + catch (GenException<int>) { Eval(cLabel == 1); } + catch (GenException<double>) { Eval(cLabel == 2); } + catch (GenException<string>) { Eval(cLabel == 3); } + catch (GenException<object>) { Eval(cLabel == 4); } + catch (GenException<Guid>) { Eval(cLabel == 5); } + + catch (GenException<int[]>) { Eval(cLabel == 6); } + catch (GenException<double[,]>) { Eval(cLabel == 7); } + catch (GenException<string[][][]>) { Eval(cLabel == 8); } + catch (GenException<object[, , ,]>) { Eval(cLabel == 9); } + catch (GenException<Guid[][, , ,][]>) { Eval(cLabel == 10); } + + catch (GenException<RefX1<int>[]>) { Eval(cLabel == 11); } + catch (GenException<RefX1<double>[,]>) { Eval(cLabel == 12); } + catch (GenException<RefX1<string>[][][]>) { Eval(cLabel == 13); } + catch (GenException<RefX1<object>[, , ,]>) { Eval(cLabel == 14); } + catch (GenException<RefX1<Guid>[][, , ,][]>) { Eval(cLabel == 15); } + catch (GenException<RefX2<int, int>[]>) { Eval(cLabel == 16); } + catch (GenException<RefX2<double, double>[,]>) { Eval(cLabel == 17); } + catch (GenException<RefX2<string, string>[][][]>) { Eval(cLabel == 18); } + catch (GenException<RefX2<object, object>[, , ,]>) { Eval(cLabel == 19); } + catch (GenException<RefX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 20); } + catch (GenException<ValX1<int>[]>) { Eval(cLabel == 21); } + catch (GenException<ValX1<double>[,]>) { Eval(cLabel == 22); } + catch (GenException<ValX1<string>[][][]>) { Eval(cLabel == 23); } + catch (GenException<ValX1<object>[, , ,]>) { Eval(cLabel == 24); } + catch (GenException<ValX1<Guid>[][, , ,][]>) { Eval(cLabel == 25); } + + catch (GenException<ValX2<int, int>[]>) { Eval(cLabel == 26); } + catch (GenException<ValX2<double, double>[,]>) { Eval(cLabel == 27); } + catch (GenException<ValX2<string, string>[][][]>) { Eval(cLabel == 28); } + catch (GenException<ValX2<object, object>[, , ,]>) { Eval(cLabel == 29); } + catch (GenException<ValX2<Guid, Guid>[][, , ,][]>) { Eval(cLabel == 30); } + + catch (GenException<RefX1<int>>) { Eval(cLabel == 31); } + catch (GenException<RefX1<ValX1<int>>>) { Eval(cLabel == 32); } + catch (GenException<RefX2<int, string>>) { Eval(cLabel == 33); } + catch (GenException<RefX3<int, string, Guid>>) { Eval(cLabel == 34); } + + catch (GenException<RefX1<RefX1<int>>>) { Eval(cLabel == 35); } + catch (GenException<RefX1<RefX1<RefX1<string>>>>) { Eval(cLabel == 36); } + catch (GenException<RefX1<RefX1<RefX1<RefX1<Guid>>>>>) { Eval(cLabel == 37); } + + catch (GenException<RefX1<RefX2<int, string>>>) { Eval(cLabel == 38); } + catch (GenException<RefX2<RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>, RefX2<RefX1<int>, RefX3<int, string, RefX1<RefX2<int, string>>>>>>) { Eval(cLabel == 39); } + catch (GenException<RefX3<RefX1<int[][, , ,]>, RefX2<object[, , ,][][], Guid[][][]>, RefX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 40); } + + catch (GenException<ValX1<int>>) { Eval(cLabel == 41); } + catch (GenException<ValX1<RefX1<int>>>) { Eval(cLabel == 42); } + catch (GenException<ValX2<int, string>>) { Eval(cLabel == 43); } + catch (GenException<ValX3<int, string, Guid>>) { Eval(cLabel == 44); } + + catch (GenException<ValX1<ValX1<int>>>) { Eval(cLabel == 45); } + catch (GenException<ValX1<ValX1<ValX1<string>>>>) { Eval(cLabel == 46); } + catch (GenException<ValX1<ValX1<ValX1<ValX1<Guid>>>>>) { Eval(cLabel == 47); } + + catch (GenException<ValX1<ValX2<int, string>>>) { Eval(cLabel == 48); } + catch (GenException<ValX2<ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>, ValX2<ValX1<int>, ValX3<int, string, ValX1<ValX2<int, string>>>>>>) { Eval(cLabel == 49); } + catch (GenException<ValX3<ValX1<int[][, , ,]>, ValX2<object[, , ,][][], Guid[][][]>, ValX3<double[, , , , , , , , , ,], Guid[][][][, , , ,][, , , ,][][][], string[][][][][][][][][][][]>>>) { Eval(cLabel == 50); } + } + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} |