Skip to content

Commit

Permalink
Add all JIT/Generics test cases
Browse files Browse the repository at this point in the history
Add all remaining JIT/Generics test cases for JIT. Related proj, config,
and sln files added and updated. Passed build, buildtest, runtest.
  • Loading branch information
Bengu Li committed May 22, 2015
1 parent 2e7885d commit 9680e84
Show file tree
Hide file tree
Showing 143 changed files with 21,832 additions and 3 deletions.
229 changes: 226 additions & 3 deletions tests/src/AllTestProjects.sln

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions tests/src/JIT/Generics/ConstrainedCall/ConstrainedCall.csproj
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>
27 changes: 27 additions & 0 deletions tests/src/JIT/Generics/ConstrainedCall/app.config
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>
111 changes: 111 additions & 0 deletions tests/src/JIT/Generics/ConstrainedCall/class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System;
interface IncrDecr
{
void Incr(int a);
void Decr(int a);
int Val();
}
class MyInt : IncrDecr
{
int x;
public void Incr(int a) { x += a; }
public void Decr(int a) { x -= a; }
public int Val() { return x; }
}
class MyCounter<T> where T : IncrDecr, new()
{
T counter = new T();
T[] counters = new T[1];
public void Increment()
{
counter.Incr(100);
}
public void Decrement()
{
counter.Decr(100);
}
public void Increment(int index)
{
counters[index] = new T();
counters[index].Incr(100);
}
public void Decrement(int index)
{
counters[index].Decr(100);
}
public virtual void Increment2(T cnter)
{
cnter.Incr(100);
counter = cnter;
}
public virtual void Decrement2(T cnter)
{
cnter.Decr(100);
counter = cnter;
}
public int Val()
{
return counter.Val();
}
public int Val(int index)
{
return counters[index].Val();
}
}
class test
{
public static int Main()
{
MyCounter<MyInt> mc = new MyCounter<MyInt>();
mc.Increment();
if (mc.Val() != 100)
{
Console.WriteLine("FAILED 1");
Console.WriteLine("Expected: 100, Actual: {0}", mc.Val());
return 1;
}
mc.Decrement();
if (mc.Val() != 0)
{
Console.WriteLine("FAILED 2");
Console.WriteLine("Expected: 0, Actual: {0}", mc.Val());
return 2;
}
mc.Increment(0);
if (mc.Val(0) != 100)
{
Console.WriteLine("FAILED 3");
Console.WriteLine("Expected: 100, Actual: {0}", mc.Val(0));
return 3;
}
mc.Decrement(0);
if (mc.Val(0) != 0)
{
Console.WriteLine("FAILED 4");
Console.WriteLine("Expected: 0, Actual: {0}", mc.Val(0));
return 4;
}
MyInt mi = new MyInt();
mc.Increment2(mi);
if (mc.Val() != 100)
{
Console.WriteLine("FAILED 5");
Console.WriteLine("Expected: 100, Actual: {0}", mc.Val());
return 5;
}
mc.Decrement2(mi);
if (mc.Val() != 0)
{
Console.WriteLine("FAILED 6");
Console.WriteLine("Expected: 0, Actual: {0}", mc.Val());
return 6;
}
Console.WriteLine("PASSED");
return 100;
}
}

120 changes: 120 additions & 0 deletions tests/src/JIT/Generics/ConstrainedCall/class2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System;
interface IncrDecr
{
void Incr(int a);
void Decr(int a);
int Val();
}
class MyInt : IncrDecr
{
int x;
public void Incr(int a) { x += a; }
public void Decr(int a) { x -= a; }
public int Val() { return x; }
}
class MyCounter<T> where T : IncrDecr, new()
{
T counter = new T();
T[] counters = new T[1];
public void Increment<T2>() where T2 : IncrDecr, new()
{
T2 cnter = new T2();
cnter.Incr(100);
counter = (T)(IncrDecr)cnter;
}
public void Decrement<T2>() where T2 : IncrDecr, new()
{
T2 cnter = (T2)(IncrDecr)counter;
cnter.Decr(100);
counter = (T)(IncrDecr)cnter;
}
public void Increment<T2>(int index) where T2 : IncrDecr, new()
{
T2[] cnters = new T2[1];
cnters[index] = new T2();
cnters[index].Incr(100);
counters[index] = (T)(IncrDecr)cnters[index];
}
public void Decrement<T2>(int index) where T2 : IncrDecr, new()
{
T2[] cnters = new T2[1];
cnters[index] = (T2)(IncrDecr)counters[index];
cnters[index].Decr(100);
counters[index] = (T)(IncrDecr)cnters[index]; ;
}
public virtual void Increment2<T2>(T2 cnter) where T2 : IncrDecr, new()
{
cnter.Incr(100);
counter = (T)(IncrDecr)cnter;
}
public virtual void Decrement2<T2>(T2 cnter) where T2 : IncrDecr, new()
{
cnter.Decr(100);
counter = (T)(IncrDecr)cnter;
}
public int Val()
{
return counter.Val();
}
public int Val(int index)
{
return counters[index].Val();
}
}
class test
{
public static int Main()
{
MyCounter<MyInt> mc = new MyCounter<MyInt>();
mc.Increment<MyInt>();
if (mc.Val() != 100)
{
Console.WriteLine("FAILED 1");
Console.WriteLine("Expected: 100, Actual: {0}", mc.Val());
return 1;
}
mc.Decrement<MyInt>();
if (mc.Val() != 0)
{
Console.WriteLine("FAILED 2");
Console.WriteLine("Expected: 0, Actual: {0}", mc.Val());
return 2;
}
mc.Increment<MyInt>(0);
if (mc.Val(0) != 100)
{
Console.WriteLine("FAILED 3");
Console.WriteLine("Expected: 100, Actual: {0}", mc.Val(0));
return 3;
}
mc.Decrement<MyInt>(0);
if (mc.Val(0) != 0)
{
Console.WriteLine("FAILED 4");
Console.WriteLine("Expected: 0, Actual: {0}", mc.Val(0));
return 4;
}
MyInt mi = new MyInt();
mc.Increment2(mi);
if (mc.Val() != 100)
{
Console.WriteLine("FAILED 5");
Console.WriteLine("Expected: 100, Actual: {0}", mc.Val());
return 5;
}
mc.Decrement2(mi);
if (mc.Val() != 0)
{
Console.WriteLine("FAILED 6");
Console.WriteLine("Expected: 0, Actual: {0}", mc.Val());
return 6;
}
Console.WriteLine("PASSED");
return 100;
}
}

42 changes: 42 additions & 0 deletions tests/src/JIT/Generics/ConstrainedCall/cs_template.proj
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>
6 changes: 6 additions & 0 deletions tests/src/JIT/Generics/ConstrainedCall/packages.config
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit 9680e84

Please sign in to comment.