Skip to content

Commit

Permalink
Add more test cases for shared generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Mar 12, 2024
1 parent 1f7d680 commit c2452c0
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/tests/JIT/Intrinsics/TypeIntrinsics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,15 @@ private static void IsGenericTypeTests()
IsFalse(typeof(int*).IsGenericType);
IsFalse(typeof(void*).IsGenericType);
IsFalse(typeof(delegate*<int>).IsGenericType);
IsFalse(new ClassUsingIsGenericTypeOnT<char>().IsGenericType()));
IsFalse(new ClassUsingIsGenericTypeOnT<string>().IsGenericType()));
IsFalse(new ClassUsingIsGenericTypeOnT<object>().IsGenericType()));
IsFalse(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericType()));
IsFalse(new ClassUsingIsGenericTypeOnT<RuntimeArgumentHandle>().IsGenericType()));
IsFalse(new ClassUsingIsGenericTypeOnT<Action>().IsGenericType()));
IsFalse(new ClassUsingIsGenericTypeOnT<char>().IsGenericType());
IsFalse(new ClassUsingIsGenericTypeOnT<string>().IsGenericType());
IsFalse(new ClassUsingIsGenericTypeOnT<object>().IsGenericType());
IsFalse(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericType());
IsFalse(new ClassUsingIsGenericTypeOnT<RuntimeArgumentHandle>().IsGenericType());
IsFalse(new ClassUsingIsGenericTypeOnT<char>().IsGenericTypeFromArray());
IsFalse(new ClassUsingIsGenericTypeOnT<string>().IsGenericTypeFromArray());
IsFalse(new ClassUsingIsGenericTypeOnT<object>().IsGenericTypeFromArray());
IsFalse(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericTypeFromArray());

IsTrue(typeof(GenericSimpleClass<int>).IsGenericType);
IsTrue(typeof(GenericSimpleClass<>).IsGenericType);
Expand All @@ -258,11 +261,19 @@ private static void IsGenericTypeTests()
IsTrue(typeof(Action<string>).IsGenericType);
IsTrue(typeof(Func<string, int>).IsGenericType);
IsTrue(typeof(Func<,>).IsGenericType);
IsTrue(new ClassUsingIsGenericTypeOnT<List<string>>().IsGenericType()));
IsTrue(new ClassUsingIsGenericTypeOnT<List<object>>().IsGenericType()));
IsTrue(new ClassUsingIsGenericTypeOnT<GenericSimpleClass<int>>().IsGenericType()));
IsTrue(new ClassUsingIsGenericTypeOnT<int?>().IsGenericType()));
IsTrue(new ClassUsingIsGenericTypeOnT<Action<string>>().IsGenericType()));
IsTrue(new ClassUsingIsGenericTypeOnT<List<string>>().IsGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<List<object>>().IsGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<GenericSimpleClass<int>>().IsGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<int?>().IsGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<Action<string>>().IsGenericType());
IsFalse(new ClassUsingIsGenericTypeOnT<GenericSimpleClass<int>>().IsGenericTypeFromArray());
IsFalse(new ClassUsingIsGenericTypeOnT<IGenericInterface<string>>().IsGenericTypeFromArray());
IsFalse(new ClassUsingIsGenericTypeOnT<List<object>>().IsGenericTypeFromArray());
IsFalse(new ClassUsingIsGenericTypeOnT<Action<string>>().IsGenericTypeFromArray());
IsTrue(new ClassUsingIsGenericTypeOnT<char>().IsGenericTypeFromOtherGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<string>().IsGenericTypeFromOtherGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<object>().IsGenericTypeFromOtherGenericType());
IsTrue(new ClassUsingIsGenericTypeOnT<int[]>().IsGenericTypeFromOtherGenericType());
}

private static int _varInt = 42;
Expand Down Expand Up @@ -340,6 +351,10 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil
public class ClassUsingIsGenericTypeOnT<T>
{
public bool IsGenericType() => typeof(T).IsGenericType;

public bool IsGenericTypeFromArray() => typeof(T[]).IsGenericType;

public bool IsGenericTypeFromOtherGenericType() => typeof(GenericSimpleClass<T>).IsGenericType;
}

public class GenericSimpleClass<T>
Expand Down

0 comments on commit c2452c0

Please sign in to comment.