summaryrefslogtreecommitdiff
path: root/tests/src/Loader/classloader/generics/Instantiation/Positive/NestedBaseClass02.cs
blob: 48c52b14aee017fafa4288bf9cf80ba2f34cda09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more 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 GenOuter<U>
{
	public class GenBase<T>
	{
		public T Fld1;
	
		public GenBase(T fld1)
		{
			Fld1 =  fld1;
		}

		public bool InstVerify(System.Type t1)
		{
			bool result = true;	

			if (!(Fld1.GetType().Equals(t1)))
			{	
				result = false;
				Console.WriteLine("Failed to verify type of Fld1 in: " + typeof(GenBase<T>) );
			}
			
			return result;
		}
	}
}

public class GenInt : GenOuter<int>.GenBase<int>
{	
	public GenInt() : base(1) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(int));	
	}
}

public class GenDouble: GenOuter<int>.GenBase<double>
{	
	public GenDouble() : base(1) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(double));	
	}
}

public class GenString : GenOuter<string>.GenBase<String>
{	
	public GenString() : base("string") {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(string));	
	}
}

public class GenObject : GenOuter<string>.GenBase<object>
{	
	public GenObject() : base(new object()) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(object));	
	}
}

public class GenGuid : GenOuter<object>.GenBase<Guid>
{	
	public GenGuid() : base(new Guid()) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(Guid));	
	}
}

public class GenConstructedReference : GenOuter<object>.GenBase<RefX1<int>>
{	
	public GenConstructedReference() : base(new RefX1<int>()) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(RefX1<int>));	
	}
}

public class GenConstructedValue: GenOuter<double>.GenBase<ValX1<string>>
{	
	public GenConstructedValue() : base(new ValX1<string>()) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(ValX1<string>));	
	}
}


public class GenInt1DArray : GenOuter<double>.GenBase<int[]>
{	
	public GenInt1DArray() : base(new int[1]) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(int[]));	
	}
}

public class GenString2DArray : GenOuter<Guid>.GenBase<string[,]>
{	
	public GenString2DArray() : base(new string[1,1]) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(string[,]));	
	}
}

public class GenIntJaggedArray : GenOuter<Guid>.GenBase<int[][]>
{	
	public GenIntJaggedArray() : base(new int[1][]) {}

	public bool InstVerify()
	{
		return base.InstVerify(typeof(int[][]));	
	}
}


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 GenInt().InstVerify());
		Eval(new GenDouble().InstVerify());
		Eval(new GenString().InstVerify());
		Eval(new GenObject().InstVerify());
		Eval(new GenGuid().InstVerify());
		Eval(new GenConstructedReference().InstVerify());
		Eval(new GenConstructedValue().InstVerify());
		Eval(new GenInt1DArray().InstVerify());
		Eval(new GenString2DArray().InstVerify());
		Eval(new GenIntJaggedArray().InstVerify());
		
		if (result)
		{
			Console.WriteLine("Test Passed");
			return 100;
		}
		else
		{
			Console.WriteLine("Test Failed");
			return 1;
		}
	}
		
}