Skip to content

Commit 42423ef

Browse files
Run TypeIntrinsics tests with native AOT (#112477)
I don't think the `CreateDynamic` flavors test anything interesting from codegen perspective. The `IsValueType` and `IsValueTypeObj` methods are going to be called using reflection, but nothing interesting will happen in the method body (it's a very regular method body). All the `dynamic` keyword is doing there is that a ton of reflection is going to happen before we execute the regular method body.
1 parent 87959c6 commit 42423ef

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

src/tests/JIT/Intrinsics/TypeIntrinsics.GetEnumUnderlyingType.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ public static void TestGetEnumUnderlyingType()
2121
AssertEquals(typeof(long), typeof(LongEnum).GetEnumUnderlyingType());
2222
AssertEquals(typeof(ulong), typeof(ULongEnum).GetEnumUnderlyingType());
2323

24-
AssertEquals(typeof(char), typeof(CharEnum).GetEnumUnderlyingType());
25-
AssertEquals(typeof(bool), typeof(BoolEnum).GetEnumUnderlyingType());
26-
AssertEquals(typeof(float), typeof(FloatEnum).GetEnumUnderlyingType());
27-
AssertEquals(typeof(double), typeof(DoubleEnum).GetEnumUnderlyingType());
28-
AssertEquals(typeof(nint), typeof(IntPtrEnum).GetEnumUnderlyingType());
29-
AssertEquals(typeof(nuint), typeof(UIntPtrEnum).GetEnumUnderlyingType());
24+
if (TestLibrary.PlatformDetection.IsRareEnumsSupported)
25+
{
26+
AssertEquals(typeof(char), typeof(CharEnum).GetEnumUnderlyingType());
27+
AssertEquals(typeof(bool), typeof(BoolEnum).GetEnumUnderlyingType());
28+
AssertEquals(typeof(float), typeof(FloatEnum).GetEnumUnderlyingType());
29+
AssertEquals(typeof(double), typeof(DoubleEnum).GetEnumUnderlyingType());
30+
AssertEquals(typeof(nint), typeof(IntPtrEnum).GetEnumUnderlyingType());
31+
AssertEquals(typeof(nuint), typeof(UIntPtrEnum).GetEnumUnderlyingType());
32+
}
3033

3134
AssertThrowsArgumentException(() => typeof(int).GetEnumUnderlyingType());
3235
AssertThrowsArgumentException(() => typeof(nint).GetEnumUnderlyingType());
@@ -43,12 +46,15 @@ public static void TestGetEnumUnderlyingType()
4346
AssertEquals(typeof(long), NoInline(typeof(LongEnum).GetEnumUnderlyingType()));
4447
AssertEquals(typeof(ulong), NoInline(typeof(ULongEnum).GetEnumUnderlyingType()));
4548

46-
AssertEquals(typeof(char), NoInline(typeof(CharEnum).GetEnumUnderlyingType()));
47-
AssertEquals(typeof(bool), NoInline(typeof(BoolEnum).GetEnumUnderlyingType()));
48-
AssertEquals(typeof(float), NoInline(typeof(FloatEnum).GetEnumUnderlyingType()));
49-
AssertEquals(typeof(double), NoInline(typeof(DoubleEnum).GetEnumUnderlyingType()));
50-
AssertEquals(typeof(nint), NoInline(typeof(IntPtrEnum).GetEnumUnderlyingType()));
51-
AssertEquals(typeof(nuint), NoInline(typeof(UIntPtrEnum).GetEnumUnderlyingType()));
49+
if (TestLibrary.PlatformDetection.IsRareEnumsSupported)
50+
{
51+
AssertEquals(typeof(char), NoInline(typeof(CharEnum).GetEnumUnderlyingType()));
52+
AssertEquals(typeof(bool), NoInline(typeof(BoolEnum).GetEnumUnderlyingType()));
53+
AssertEquals(typeof(float), NoInline(typeof(FloatEnum).GetEnumUnderlyingType()));
54+
AssertEquals(typeof(double), NoInline(typeof(DoubleEnum).GetEnumUnderlyingType()));
55+
AssertEquals(typeof(nint), NoInline(typeof(IntPtrEnum).GetEnumUnderlyingType()));
56+
AssertEquals(typeof(nuint), NoInline(typeof(UIntPtrEnum).GetEnumUnderlyingType()));
57+
}
5258

5359
AssertThrowsArgumentException(() => NoInline(typeof(int).GetEnumUnderlyingType()));
5460
AssertThrowsArgumentException(() => NoInline(typeof(nint).GetEnumUnderlyingType()));

src/tests/JIT/Intrinsics/TypeIntrinsics.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public static int TestEntryPoint()
6767
IsTrue (IsValueType<GenericStruct<int>>(default));
6868
IsTrue (IsValueType<GenericStruct<string>>(default));
6969
IsTrue (IsValueType(SimpleEnum.B));
70-
IsTrue (IsValueType(CreateDynamic1()));
71-
IsFalse(IsValueType(CreateDynamic2()));
7270

7371
IsTrue (IsValueTypeObj(42));
7472
IsTrue (IsValueTypeObj(new Nullable<int>(42)));
@@ -80,8 +78,6 @@ public static int TestEntryPoint()
8078
IsTrue (IsValueTypeObj(new GenericStruct<int>()));
8179
IsTrue (IsValueTypeObj(new GenericStruct<string>()));
8280
IsTrue (IsValueTypeObj(SimpleEnum.B));
83-
IsTrue (IsValueTypeObj(CreateDynamic1()));
84-
IsFalse(IsValueTypeObj(CreateDynamic2()));
8581

8682
IsTrue (IsValueTypeRef(ref _varInt));
8783
IsTrue (IsValueTypeRef(ref _varNullableInt));
@@ -342,12 +338,6 @@ private static void GetGenericTypeDefinitionTests()
342338
[MethodImpl(MethodImplOptions.NoInlining)]
343339
private static bool IsValueTypeObj(object val) => val.GetType().IsValueType;
344340

345-
[MethodImpl(MethodImplOptions.NoInlining)]
346-
private static dynamic CreateDynamic1() => 42;
347-
348-
[MethodImpl(MethodImplOptions.NoInlining)]
349-
private static dynamic CreateDynamic2() => new { Name = "Test" };
350-
351341
[MethodImpl(MethodImplOptions.NoInlining)]
352342
private static Type GetGenericTypeDefinition<T>() => typeof(T).GetGenericTypeDefinition();
353343

src/tests/JIT/Intrinsics/TypeIntrinsics_r.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<Compile Include="TypeIntrinsics.IsAssignableTo.cs" />
1515
<Compile Include="TypeIntrinsics.GetEnumUnderlyingType.cs" />
1616
</ItemGroup>
17+
<ItemGroup>
18+
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
19+
</ItemGroup>
1720
</Project>

src/tests/JIT/Intrinsics/TypeIntrinsics_ro.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<Compile Include="TypeIntrinsics.IsAssignableTo.cs" />
1515
<Compile Include="TypeIntrinsics.GetEnumUnderlyingType.cs" />
1616
</ItemGroup>
17+
<ItemGroup>
18+
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
19+
</ItemGroup>
1720
</Project>

src/tests/issues.targets

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,6 @@
680680
<ExcludeList Include="$(XunitTestBinBase)/JIT/Directed/debugging/debuginfo/tester/*">
681681
<Issue>Just-in-time compilation test</Issue>
682682
</ExcludeList>
683-
<ExcludeList Include="$(XunitTestBinBase)/JIT/Intrinsics/TypeIntrinsics_r/*">
684-
<Issue>Not compatible with multifile testing.</Issue>
685-
</ExcludeList>
686-
<ExcludeList Include="$(XunitTestBinBase)/JIT/Intrinsics/TypeIntrinsics_ro/*">
687-
<Issue>Not compatible with multifile testing.</Issue>
688-
</ExcludeList>
689683
<ExcludeList Include="$(XunitTestBinBase)/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException/*">
690684
<Issue>https://github.com/dotnet/runtimelab/issues/155: Wrapping non-exception throws</Issue>
691685
</ExcludeList>

0 commit comments

Comments
 (0)