From 03816d24af297553dc4fc0fe7433c752d62e0ed1 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Tue, 8 Aug 2023 16:30:43 +0300 Subject: [PATCH] [tests] Attempt to enable test (#89498) --- .../tests/System/TypedReferenceTests.cs | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System/TypedReferenceTests.cs b/src/libraries/System.Runtime/tests/System/TypedReferenceTests.cs index 20d72358a6584..f70176eee3cc1 100644 --- a/src/libraries/System.Runtime/tests/System/TypedReferenceTests.cs +++ b/src/libraries/System.Runtime/tests/System/TypedReferenceTests.cs @@ -78,34 +78,31 @@ public static void MakeTypedReference_ToObjectTests() Assert.Equal(structObj, TypedReference.ToObject(reference)); } - // These tests are currently crashing the Mono AOT compiler, so commenting them out (skipping them isn't enough) - //[Fact] - //[ActiveIssue("https://github.com/dotnet/runtime/issues/70091", TestRuntimes.Mono)] - //public static unsafe void MakeTypedReference_ToObjectTests_WithPointer() - //{ - // float* pointer = (float*)(nuint)0x12345678; - // TypedReference reference = __makeref(pointer); - // object obj = TypedReference.ToObject(reference); - // - // // TypedReference-s over pointers use the UIntPtr type when boxing - // Assert.NotNull(obj); - // Assert.IsType(obj); - // Assert.Equal((nuint)0x12345678, (nuint)obj); - //} - // - //[Fact] - //[ActiveIssue("https://github.com/dotnet/runtime/issues/70091", TestRuntimes.Mono)] - //public static unsafe void MakeTypedReference_ToObjectTests_WithFunctionPointer() - //{ - // delegate* pointer = (delegate*)(void*)(nuint)0x12345678; - // TypedReference reference = __makeref(pointer); - // object obj = TypedReference.ToObject(reference); - // - // // TypedReference-s over function pointers use the UIntPtr type when boxing - // Assert.NotNull(obj); - // Assert.IsType(obj); - // Assert.Equal((nuint)0x12345678, (nuint)obj); - //} + [Fact] + public static unsafe void MakeTypedReference_ToObjectTests_WithPointer() + { + float* pointer = (float*)(nuint)0x12345678; + TypedReference reference = __makeref(pointer); + object obj = TypedReference.ToObject(reference); + + // TypedReference-s over pointers use the UIntPtr type when boxing + Assert.NotNull(obj); + Assert.IsType(obj); + Assert.Equal((nuint)0x12345678, (nuint)obj); + } + + [Fact] + public static unsafe void MakeTypedReference_ToObjectTests_WithFunctionPointer() + { + delegate* pointer = (delegate*)(void*)(nuint)0x12345678; + TypedReference reference = __makeref(pointer); + object obj = TypedReference.ToObject(reference); + + // TypedReference-s over function pointers use the UIntPtr type when boxing + Assert.NotNull(obj); + Assert.IsType(obj); + Assert.Equal((nuint)0x12345678, (nuint)obj); + } [Fact] public static void MakeTypedReference_ReadOnlyField_Succeeds()