Skip to content

Commit

Permalink
Add '__Canon' tests as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jun 17, 2024
1 parent 60c34f3 commit 2e92a52
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tests/JIT/Intrinsics/TypeIntrinsics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ private static void GetGenericTypeDefinitionTests()
AreEqual(typeof(Action<string>).GetGenericTypeDefinition(), typeof(Action<>));
AreEqual(typeof(Func<string, int>).GetGenericTypeDefinition(), typeof(Func<,>));
AreEqual(typeof(Func<,>).GetGenericTypeDefinition(), typeof(Func<,>));

// Test for __Canon
AreEqual(GetGenericTypeDefinition<GenericEnumClass<SimpleEnum>>(), typeof(GenericEnumClass<>));
AreEqual(GetGenericTypeDefinition<IGenericInterface<string>>(), typeof(IGenericInterface<>));
AreEqual(GetGenericTypeDefinition<GenericStruct<string>>(), typeof(GenericStruct<>));
AreEqual(GetGenericTypeDefinition<Dictionary<int,string>>(), typeof(Dictionary<,>));
AreEqual(GetGenericTypeDefinition<List<string>>(), typeof(List<>));
AreEqual(GetGenericTypeDefinition<Action<string>>(), typeof(Action<>));
AreEqual(GetGenericTypeDefinition<Func<string, int>>(), typeof(Func<,>));
}

private static int _varInt = 42;
Expand Down Expand Up @@ -334,6 +343,9 @@ private static void GetGenericTypeDefinitionTests()
[MethodImpl(MethodImplOptions.NoInlining)]
private static dynamic CreateDynamic2() => new { Name = "Test" };

[MethodImpl(MethodImplOptions.NoInlining)]
private static Type GetGenericTypeDefinition<T>() => typeof(T).GetGenericTypeDefinition();

[MethodImpl(MethodImplOptions.NoInlining)]
static void IsTrue(bool expression, [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
{
Expand Down

0 comments on commit 2e92a52

Please sign in to comment.