Skip to content

Commit c2452c0

Browse files
committed
Add more test cases for shared generics
1 parent 1f7d680 commit c2452c0

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

src/tests/JIT/Intrinsics/TypeIntrinsics.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,15 @@ private static void IsGenericTypeTests()
229229
IsFalse(typeof(int*).IsGenericType);
230230
IsFalse(typeof(void*).IsGenericType);
231231
IsFalse(typeof(delegate*<int>).IsGenericType);
232-
IsFalse(new ClassUsingIsGenericTypeOnT<char>().IsGenericType()));
233-
IsFalse(new ClassUsingIsGenericTypeOnT<string>().IsGenericType()));
234-
IsFalse(new ClassUsingIsGenericTypeOnT<object>().IsGenericType()));
235-
IsFalse(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericType()));
236-
IsFalse(new ClassUsingIsGenericTypeOnT<RuntimeArgumentHandle>().IsGenericType()));
237-
IsFalse(new ClassUsingIsGenericTypeOnT<Action>().IsGenericType()));
232+
IsFalse(new ClassUsingIsGenericTypeOnT<char>().IsGenericType());
233+
IsFalse(new ClassUsingIsGenericTypeOnT<string>().IsGenericType());
234+
IsFalse(new ClassUsingIsGenericTypeOnT<object>().IsGenericType());
235+
IsFalse(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericType());
236+
IsFalse(new ClassUsingIsGenericTypeOnT<RuntimeArgumentHandle>().IsGenericType());
237+
IsFalse(new ClassUsingIsGenericTypeOnT<char>().IsGenericTypeFromArray());
238+
IsFalse(new ClassUsingIsGenericTypeOnT<string>().IsGenericTypeFromArray());
239+
IsFalse(new ClassUsingIsGenericTypeOnT<object>().IsGenericTypeFromArray());
240+
IsFalse(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericTypeFromArray());
238241

239242
IsTrue(typeof(GenericSimpleClass<int>).IsGenericType);
240243
IsTrue(typeof(GenericSimpleClass<>).IsGenericType);
@@ -258,11 +261,19 @@ private static void IsGenericTypeTests()
258261
IsTrue(typeof(Action<string>).IsGenericType);
259262
IsTrue(typeof(Func<string, int>).IsGenericType);
260263
IsTrue(typeof(Func<,>).IsGenericType);
261-
IsTrue(new ClassUsingIsGenericTypeOnT<List<string>>().IsGenericType()));
262-
IsTrue(new ClassUsingIsGenericTypeOnT<List<object>>().IsGenericType()));
263-
IsTrue(new ClassUsingIsGenericTypeOnT<GenericSimpleClass<int>>().IsGenericType()));
264-
IsTrue(new ClassUsingIsGenericTypeOnT<int?>().IsGenericType()));
265-
IsTrue(new ClassUsingIsGenericTypeOnT<Action<string>>().IsGenericType()));
264+
IsTrue(new ClassUsingIsGenericTypeOnT<List<string>>().IsGenericType());
265+
IsTrue(new ClassUsingIsGenericTypeOnT<List<object>>().IsGenericType());
266+
IsTrue(new ClassUsingIsGenericTypeOnT<GenericSimpleClass<int>>().IsGenericType());
267+
IsTrue(new ClassUsingIsGenericTypeOnT<int?>().IsGenericType());
268+
IsTrue(new ClassUsingIsGenericTypeOnT<Action<string>>().IsGenericType());
269+
IsFalse(new ClassUsingIsGenericTypeOnT<GenericSimpleClass<int>>().IsGenericTypeFromArray());
270+
IsFalse(new ClassUsingIsGenericTypeOnT<IGenericInterface<string>>().IsGenericTypeFromArray());
271+
IsFalse(new ClassUsingIsGenericTypeOnT<List<object>>().IsGenericTypeFromArray());
272+
IsFalse(new ClassUsingIsGenericTypeOnT<Action<string>>().IsGenericTypeFromArray());
273+
IsTrue(new ClassUsingIsGenericTypeOnT<char>().IsGenericTypeFromOtherGenericType());
274+
IsTrue(new ClassUsingIsGenericTypeOnT<string>().IsGenericTypeFromOtherGenericType());
275+
IsTrue(new ClassUsingIsGenericTypeOnT<object>().IsGenericTypeFromOtherGenericType());
276+
IsTrue(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericTypeFromOtherGenericType());
266277
}
267278

268279
private static int _varInt = 42;
@@ -340,6 +351,10 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil
340351
public class ClassUsingIsGenericTypeOnT<T>
341352
{
342353
public bool IsGenericType() => typeof(T).IsGenericType;
354+
355+
public bool IsGenericTypeFromArray() => typeof(T[]).IsGenericType;
356+
357+
public bool IsGenericTypeFromOtherGenericType() => typeof(GenericSimpleClass<T>).IsGenericType;
343358
}
344359

345360
public class GenericSimpleClass<T>

0 commit comments

Comments
 (0)