Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 0093a35

Browse files
author
Fadi Hanna
authored
TypeSystem generics test cases (#6663)
TypeSystem generics test cases (TypeGenerator tests)
1 parent 6f645eb commit 0093a35

File tree

2,994 files changed

+4567063
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,994 files changed

+4567063
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
6+
using System;
7+
using System.Reflection;
8+
using System.Collections.Generic;
9+
using System.IO;
10+
11+
public class TestFramework
12+
{
13+
public static void MethodCallTest(string actualResult, string expectedResults, string invocationString)
14+
{
15+
Console.WriteLine(invocationString);
16+
Console.WriteLine(" -> EXPECTED: " + expectedResults);
17+
Console.WriteLine(" -> GOT: " + actualResult);
18+
19+
if (expectedResults != actualResult)
20+
{
21+
Console.WriteLine("Wrong method called when calling " + invocationString);
22+
throw new Exception("Wrong method called");
23+
}
24+
}
25+
26+
public static void MethodCallTest(string expectedResults, string constrainedCallerMethod, int count, params string[] actualResults)
27+
{
28+
Console.WriteLine(constrainedCallerMethod);
29+
30+
string[] expectedResultsArray = expectedResults.Split(new char[] { '#' });
31+
32+
Console.WriteLine(" # count = " + count);
33+
Console.WriteLine(" # expectedResultsArray.Length = " + (expectedResultsArray.Length - 1));
34+
for (int i = 0; i < expectedResultsArray.Length - 1; i++)
35+
Console.WriteLine(" # expectedResultsArray[" + i + "] = '" + expectedResultsArray[i] + "'");
36+
37+
38+
if ((expectedResults == "" && count != 0) || (expectedResults != "" && count == 0) || ((expectedResultsArray.Length - 1) != count) || (count > 0 && count != actualResults.Length))
39+
{
40+
Console.WriteLine("Error in method count in constrained caller [ " + constrainedCallerMethod + " ]");
41+
throw new Exception("Method count failure");
42+
}
43+
44+
bool success = true;
45+
for (int i = 0; i < count; i++)
46+
{
47+
Console.WriteLine(" -> EXPECTED: " + expectedResultsArray[i]);
48+
Console.WriteLine(" -> GOT: " + actualResults[i]);
49+
50+
if (expectedResultsArray[i] != actualResults[i])
51+
{
52+
Console.WriteLine("Wrong method called in constrained caller " + constrainedCallerMethod);
53+
success = false;
54+
}
55+
}
56+
if (!success) throw new Exception("Wrong method called");
57+
}
58+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<AssemblyName>TestFramework</AssemblyName>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<SchemaVersion>2.0</SchemaVersion>
9+
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
10+
<FileAlignment>512</FileAlignment>
11+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
12+
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
13+
<OutputType>Library</OutputType>
14+
<CLRTestKind>BuildOnly</CLRTestKind>
15+
<ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
16+
<CLRTestPriority>2</CLRTestPriority>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<Compile Include="TestFramework.cs" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<None Include="..\project.json" />
25+
<None Include="..\app.config" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
30+
</ItemGroup>
31+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
32+
</Project>
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
.assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 }
6+
.assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) }
7+
8+
//TYPES IN FORWARDER ASSEMBLIES:
9+
10+
//TEST ASSEMBLY:
11+
.assembly Generated0 { .hash algorithm 0x00008004 }
12+
.module Generated0.exe
13+
14+
.class public BaseClass0
15+
{
16+
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
17+
ldarg.0
18+
call instance void [mscorlib]System.Object::.ctor()
19+
ret
20+
}
21+
}
22+
.class public BaseClass1
23+
extends BaseClass0
24+
{
25+
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
26+
ldarg.0
27+
call instance void BaseClass0::.ctor()
28+
ret
29+
}
30+
}
31+
.class public sequential sealed MyStruct50`1<T0>
32+
extends [mscorlib]System.ValueType
33+
{
34+
.pack 0
35+
.size 1
36+
.method public hidebysig newslot instance string ClassMethod108() cil managed noinlining {
37+
ldstr "MyStruct50::ClassMethod108.403()"
38+
ret
39+
}
40+
.method public hidebysig newslot instance string ClassMethod109() cil managed noinlining {
41+
ldstr "MyStruct50::ClassMethod109.404()"
42+
ret
43+
}
44+
.method public hidebysig virtual instance bool Equals(object obj) cil managed { ldc.i4.0 ret }
45+
.method public hidebysig virtual instance int32 GetHashCode() cil managed { ldc.i4.0 ret }
46+
.method public hidebysig virtual instance string ToString() cil managed { ldstr "" ret }
47+
}
48+
.class private auto ansi beforefieldinit Framework {
49+
.method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed {
50+
.maxstack 5
51+
.locals init (string[] actualResults)
52+
ldc.i4.s 0
53+
newarr string
54+
stloc.s actualResults
55+
ldarg.1
56+
ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)"
57+
ldc.i4.s 0
58+
ldloc.s actualResults
59+
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
60+
ret
61+
}
62+
.method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed {
63+
.maxstack 5
64+
.locals init (string[] actualResults)
65+
ldc.i4.s 0
66+
newarr string
67+
stloc.s actualResults
68+
ldarg.1
69+
ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)"
70+
ldc.i4.s 0
71+
ldloc.s actualResults
72+
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
73+
ret
74+
}
75+
.method public hidebysig static void MethodCallingTest() cil managed
76+
{
77+
.maxstack 10
78+
.locals init (object V_0)
79+
ldstr "========================== Method Calling Test =========================="
80+
call void [mscorlib]System.Console::WriteLine(string)
81+
.locals init (valuetype MyStruct50`1<class BaseClass0> V_1)
82+
ldloca V_1
83+
initobj valuetype MyStruct50`1<class BaseClass0>
84+
ldloca V_1
85+
dup
86+
call instance string valuetype MyStruct50`1<class BaseClass0>::ClassMethod108()
87+
ldstr "MyStruct50::ClassMethod108.403()"
88+
ldstr "valuetype MyStruct50`1<class BaseClass0> on type MyStruct50"
89+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
90+
dup
91+
call instance string valuetype MyStruct50`1<class BaseClass0>::ClassMethod109()
92+
ldstr "MyStruct50::ClassMethod109.404()"
93+
ldstr "valuetype MyStruct50`1<class BaseClass0> on type MyStruct50"
94+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
95+
dup ldnull call instance bool valuetype MyStruct50`1<class BaseClass0>::Equals(object) pop
96+
dup call instance int32 valuetype MyStruct50`1<class BaseClass0>::GetHashCode() pop
97+
dup call instance string valuetype MyStruct50`1<class BaseClass0>::ToString() pop
98+
pop
99+
.locals init (valuetype MyStruct50`1<class BaseClass1> V_2)
100+
ldloca V_2
101+
initobj valuetype MyStruct50`1<class BaseClass1>
102+
ldloca V_2
103+
dup
104+
call instance string valuetype MyStruct50`1<class BaseClass1>::ClassMethod108()
105+
ldstr "MyStruct50::ClassMethod108.403()"
106+
ldstr "valuetype MyStruct50`1<class BaseClass1> on type MyStruct50"
107+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
108+
dup
109+
call instance string valuetype MyStruct50`1<class BaseClass1>::ClassMethod109()
110+
ldstr "MyStruct50::ClassMethod109.404()"
111+
ldstr "valuetype MyStruct50`1<class BaseClass1> on type MyStruct50"
112+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
113+
dup ldnull call instance bool valuetype MyStruct50`1<class BaseClass1>::Equals(object) pop
114+
dup call instance int32 valuetype MyStruct50`1<class BaseClass1>::GetHashCode() pop
115+
dup call instance string valuetype MyStruct50`1<class BaseClass1>::ToString() pop
116+
pop
117+
ldstr "========================================================================\n\n"
118+
call void [mscorlib]System.Console::WriteLine(string)
119+
ret
120+
}
121+
.method public hidebysig static void ConstrainedCallsTest() cil managed
122+
{
123+
.maxstack 10
124+
.locals init (object V_0)
125+
ldstr "========================== Constrained Calls Test =========================="
126+
call void [mscorlib]System.Console::WriteLine(string)
127+
.locals init (valuetype MyStruct50`1<class BaseClass0> V_3)
128+
ldloca V_3
129+
initobj valuetype MyStruct50`1<class BaseClass0>
130+
.locals init (valuetype MyStruct50`1<class BaseClass1> V_4)
131+
ldloca V_4
132+
initobj valuetype MyStruct50`1<class BaseClass1>
133+
ldstr "========================================================================\n\n"
134+
call void [mscorlib]System.Console::WriteLine(string)
135+
ret
136+
}
137+
.method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed
138+
{
139+
.maxstack 10
140+
ldstr "===================== Struct Constrained Interface Calls Test ====================="
141+
call void [mscorlib]System.Console::WriteLine(string)
142+
ldstr "========================================================================\n\n"
143+
call void [mscorlib]System.Console::WriteLine(string)
144+
ret
145+
}
146+
.method public hidebysig static void CalliTest() cil managed
147+
{
148+
.maxstack 10
149+
.locals init (object V_0)
150+
ldstr "========================== Method Calli Test =========================="
151+
call void [mscorlib]System.Console::WriteLine(string)
152+
.locals init (valuetype MyStruct50`1<class BaseClass0> V_5)
153+
ldloca V_5
154+
initobj valuetype MyStruct50`1<class BaseClass0>
155+
ldloc V_5
156+
box valuetype MyStruct50`1<class BaseClass0>
157+
ldloc V_5
158+
box valuetype MyStruct50`1<class BaseClass0>
159+
ldvirtftn instance string valuetype MyStruct50`1<class BaseClass0>::ClassMethod108()
160+
calli default string(object)
161+
ldstr "MyStruct50::ClassMethod108.403()"
162+
ldstr "valuetype MyStruct50`1<class BaseClass0> on type valuetype MyStruct50`1<class BaseClass0>"
163+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
164+
ldloc V_5
165+
box valuetype MyStruct50`1<class BaseClass0>
166+
ldloc V_5
167+
box valuetype MyStruct50`1<class BaseClass0>
168+
ldvirtftn instance string valuetype MyStruct50`1<class BaseClass0>::ClassMethod109()
169+
calli default string(object)
170+
ldstr "MyStruct50::ClassMethod109.404()"
171+
ldstr "valuetype MyStruct50`1<class BaseClass0> on type valuetype MyStruct50`1<class BaseClass0>"
172+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
173+
ldloc V_5 box valuetype MyStruct50`1<class BaseClass0> ldnull
174+
ldloc V_5 box valuetype MyStruct50`1<class BaseClass0>
175+
ldvirtftn instance bool valuetype MyStruct50`1<class BaseClass0>::Equals(object) calli default bool(object,object) pop
176+
ldloc V_5 box valuetype MyStruct50`1<class BaseClass0>
177+
ldloc V_5 box valuetype MyStruct50`1<class BaseClass0>
178+
ldvirtftn instance int32 valuetype MyStruct50`1<class BaseClass0>::GetHashCode() calli default int32(object) pop
179+
ldloc V_5 box valuetype MyStruct50`1<class BaseClass0>
180+
ldloc V_5 box valuetype MyStruct50`1<class BaseClass0>
181+
ldvirtftn instance string valuetype MyStruct50`1<class BaseClass0>::ToString() calli default string(object) pop
182+
.locals init (valuetype MyStruct50`1<class BaseClass1> V_6)
183+
ldloca V_6
184+
initobj valuetype MyStruct50`1<class BaseClass1>
185+
ldloc V_6
186+
box valuetype MyStruct50`1<class BaseClass1>
187+
ldloc V_6
188+
box valuetype MyStruct50`1<class BaseClass1>
189+
ldvirtftn instance string valuetype MyStruct50`1<class BaseClass1>::ClassMethod108()
190+
calli default string(object)
191+
ldstr "MyStruct50::ClassMethod108.403()"
192+
ldstr "valuetype MyStruct50`1<class BaseClass1> on type valuetype MyStruct50`1<class BaseClass1>"
193+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
194+
ldloc V_6
195+
box valuetype MyStruct50`1<class BaseClass1>
196+
ldloc V_6
197+
box valuetype MyStruct50`1<class BaseClass1>
198+
ldvirtftn instance string valuetype MyStruct50`1<class BaseClass1>::ClassMethod109()
199+
calli default string(object)
200+
ldstr "MyStruct50::ClassMethod109.404()"
201+
ldstr "valuetype MyStruct50`1<class BaseClass1> on type valuetype MyStruct50`1<class BaseClass1>"
202+
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
203+
ldloc V_6 box valuetype MyStruct50`1<class BaseClass1> ldnull
204+
ldloc V_6 box valuetype MyStruct50`1<class BaseClass1>
205+
ldvirtftn instance bool valuetype MyStruct50`1<class BaseClass1>::Equals(object) calli default bool(object,object) pop
206+
ldloc V_6 box valuetype MyStruct50`1<class BaseClass1>
207+
ldloc V_6 box valuetype MyStruct50`1<class BaseClass1>
208+
ldvirtftn instance int32 valuetype MyStruct50`1<class BaseClass1>::GetHashCode() calli default int32(object) pop
209+
ldloc V_6 box valuetype MyStruct50`1<class BaseClass1>
210+
ldloc V_6 box valuetype MyStruct50`1<class BaseClass1>
211+
ldvirtftn instance string valuetype MyStruct50`1<class BaseClass1>::ToString() calli default string(object) pop
212+
ldstr "========================================================================\n\n"
213+
call void [mscorlib]System.Console::WriteLine(string)
214+
ret
215+
}
216+
.method public hidebysig static int32 Main() cil managed
217+
{
218+
.entrypoint
219+
.maxstack 10
220+
call void Framework::MethodCallingTest()
221+
call void Framework::ConstrainedCallsTest()
222+
call void Framework::StructConstrainedInterfaceCallsTest()
223+
call void Framework::CalliTest()
224+
ldc.i4 100
225+
ret
226+
}
227+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<AssemblyName>Generated0</AssemblyName>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<SchemaVersion>2.0</SchemaVersion>
9+
<ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
10+
<FileAlignment>512</FileAlignment>
11+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
12+
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
13+
<ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
14+
<OutputType>Exe</OutputType>
15+
<CLRTestKind>BuildAndRun</CLRTestKind>
16+
<CLRTestPriority>2</CLRTestPriority>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<Compile Include="Generated0.il" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<None Include="..\app.config" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
33+
</ItemGroup>
34+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
35+
</Project>

0 commit comments

Comments
 (0)