From c2452c052e66ef97d55a414b716bb7269d466aa8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 12 Mar 2024 13:42:23 -0700 Subject: [PATCH] Add more test cases for shared generics --- src/tests/JIT/Intrinsics/TypeIntrinsics.cs | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs index 7f05c07a58eed6..0c9f985283d59b 100644 --- a/src/tests/JIT/Intrinsics/TypeIntrinsics.cs +++ b/src/tests/JIT/Intrinsics/TypeIntrinsics.cs @@ -229,12 +229,15 @@ private static void IsGenericTypeTests() IsFalse(typeof(int*).IsGenericType); IsFalse(typeof(void*).IsGenericType); IsFalse(typeof(delegate*).IsGenericType); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType())); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromArray()); IsTrue(typeof(GenericSimpleClass).IsGenericType); IsTrue(typeof(GenericSimpleClass<>).IsGenericType); @@ -258,11 +261,19 @@ private static void IsGenericTypeTests() IsTrue(typeof(Action).IsGenericType); IsTrue(typeof(Func).IsGenericType); IsTrue(typeof(Func<,>).IsGenericType); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericType())); - IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType())); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT>().IsGenericType()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsFalse(new ClassUsingIsGenericTypeOnT>().IsGenericTypeFromArray()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); + IsTrue(new ClassUsingIsGenericTypeOnT().IsGenericTypeFromOtherGenericType()); } private static int _varInt = 42; @@ -340,6 +351,10 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil public class ClassUsingIsGenericTypeOnT { public bool IsGenericType() => typeof(T).IsGenericType; + + public bool IsGenericTypeFromArray() => typeof(T[]).IsGenericType; + + public bool IsGenericTypeFromOtherGenericType() => typeof(GenericSimpleClass).IsGenericType; } public class GenericSimpleClass