forked from dotnet/coreclr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Bengu Li
committed
Apr 27, 2015
1 parent
7fc9fee
commit e3d15f1
Showing
16 changed files
with
2,110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
158 changes: 158 additions & 0 deletions
158
tests/src/JIT/Generics/Exceptions/general_class_instance01.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.