Skip to content

Commit 6751a9d

Browse files
committed
Fix ConvertToIntegerTest and disable it on CoreCLR
IFloatingPoint.ConvertToInteger are always saturating. Jit fails this test because id doesn't follow the managed implementation, intrinsifying instead with non-saturating implementation.
1 parent be188e8 commit 6751a9d

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.GenericMath.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,18 @@ public static void op_InequalityTest()
346346

347347
[Fact]
348348
[SkipOnMono("https://github.com/dotnet/runtime/issues/100368")]
349-
[ActiveIssue("https://github.com/dotnet/runtime/issues/116823", typeof(PlatformDetection), nameof(PlatformDetection.IsCoreClrInterpreter))]
349+
// Passes on the interpreter, but interpreter configurations might still use jit fallback
350+
[ActiveIssue("https://github.com/dotnet/runtime/issues/116823", typeof(PlatformDetection), nameof(PlatformDetection.IsCoreCLR))]
350351
public static void ConvertToIntegerTest()
351352
{
352353
// Signed Values
353354

354-
Assert.Equal(0, FloatingPointHelper<double>.ConvertToInteger<short>(double.MinValue));
355+
Assert.Equal(short.MinValue, FloatingPointHelper<double>.ConvertToInteger<short>(double.MinValue));
355356
Assert.Equal(int.MinValue, FloatingPointHelper<double>.ConvertToInteger<int>(double.MinValue));
356357
Assert.Equal(long.MinValue, FloatingPointHelper<double>.ConvertToInteger<long>(double.MinValue));
357358
Assert.Equal(Int128.MinValue, FloatingPointHelper<double>.ConvertToInteger<Int128>(double.MinValue));
358359
Assert.Equal(nint.MinValue, FloatingPointHelper<double>.ConvertToInteger<nint>(double.MinValue));
359-
Assert.Equal(0, FloatingPointHelper<double>.ConvertToInteger<sbyte>(double.MinValue));
360+
Assert.Equal(sbyte.MinValue, FloatingPointHelper<double>.ConvertToInteger<sbyte>(double.MinValue));
360361

361362
Assert.Equal(2, FloatingPointHelper<double>.ConvertToInteger<short>(2.6));
362363
Assert.Equal(2, FloatingPointHelper<double>.ConvertToInteger<int>(2.6));
@@ -365,12 +366,12 @@ public static void ConvertToIntegerTest()
365366
Assert.Equal(2, FloatingPointHelper<double>.ConvertToInteger<nint>(2.6));
366367
Assert.Equal(2, FloatingPointHelper<double>.ConvertToInteger<sbyte>(2.6));
367368

368-
Assert.Equal(-1, FloatingPointHelper<double>.ConvertToInteger<short>(double.MaxValue));
369+
Assert.Equal(short.MaxValue, FloatingPointHelper<double>.ConvertToInteger<short>(double.MaxValue));
369370
Assert.Equal(int.MaxValue, FloatingPointHelper<double>.ConvertToInteger<int>(double.MaxValue));
370371
Assert.Equal(long.MaxValue, FloatingPointHelper<double>.ConvertToInteger<long>(double.MaxValue));
371372
Assert.Equal(Int128.MaxValue, FloatingPointHelper<double>.ConvertToInteger<Int128>(double.MaxValue));
372373
Assert.Equal(nint.MaxValue, FloatingPointHelper<double>.ConvertToInteger<nint>(double.MaxValue));
373-
Assert.Equal(-1, FloatingPointHelper<double>.ConvertToInteger<sbyte>(double.MaxValue));
374+
Assert.Equal(sbyte.MaxValue, FloatingPointHelper<double>.ConvertToInteger<sbyte>(double.MaxValue));
374375

375376
// Unsigned Values
376377

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/SingleTests.GenericMath.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,18 @@ public static void op_InequalityTest()
346346

347347
[Fact]
348348
[SkipOnMono("https://github.com/dotnet/runtime/issues/100368")]
349-
[ActiveIssue("https://github.com/dotnet/runtime/issues/116823", typeof(PlatformDetection), nameof(PlatformDetection.IsCoreClrInterpreter))]
349+
// Passes on the interpreter, but interpreter configurations might still use jit fallback
350+
[ActiveIssue("https://github.com/dotnet/runtime/issues/116823", typeof(PlatformDetection), nameof(PlatformDetection.IsCoreCLR))]
350351
public static void ConvertToIntegerTest()
351352
{
352353
// Signed Values
353354

354-
Assert.Equal(0, FloatingPointHelper<float>.ConvertToInteger<short>(float.MinValue));
355+
Assert.Equal(short.MinValue, FloatingPointHelper<float>.ConvertToInteger<short>(float.MinValue));
355356
Assert.Equal(int.MinValue, FloatingPointHelper<float>.ConvertToInteger<int>(float.MinValue));
356357
Assert.Equal(long.MinValue, FloatingPointHelper<float>.ConvertToInteger<long>(float.MinValue));
357358
Assert.Equal(Int128.MinValue, FloatingPointHelper<float>.ConvertToInteger<Int128>(float.MinValue));
358359
Assert.Equal(nint.MinValue, FloatingPointHelper<float>.ConvertToInteger<nint>(float.MinValue));
359-
Assert.Equal(0, FloatingPointHelper<float>.ConvertToInteger<sbyte>(float.MinValue));
360+
Assert.Equal(sbyte.MinValue, FloatingPointHelper<float>.ConvertToInteger<sbyte>(float.MinValue));
360361

361362
Assert.Equal(2, FloatingPointHelper<float>.ConvertToInteger<short>(2.6f));
362363
Assert.Equal(2, FloatingPointHelper<float>.ConvertToInteger<int>(2.6f));
@@ -365,12 +366,12 @@ public static void ConvertToIntegerTest()
365366
Assert.Equal(2, FloatingPointHelper<float>.ConvertToInteger<nint>(2.6f));
366367
Assert.Equal(2, FloatingPointHelper<float>.ConvertToInteger<sbyte>(2.6f));
367368

368-
Assert.Equal(-1, FloatingPointHelper<float>.ConvertToInteger<short>(float.MaxValue));
369+
Assert.Equal(short.MaxValue, FloatingPointHelper<float>.ConvertToInteger<short>(float.MaxValue));
369370
Assert.Equal(int.MaxValue, FloatingPointHelper<float>.ConvertToInteger<int>(float.MaxValue));
370371
Assert.Equal(long.MaxValue, FloatingPointHelper<float>.ConvertToInteger<long>(float.MaxValue));
371372
Assert.Equal(Int128.MaxValue, FloatingPointHelper<float>.ConvertToInteger<Int128>(float.MaxValue));
372373
Assert.Equal(nint.MaxValue, FloatingPointHelper<float>.ConvertToInteger<nint>(float.MaxValue));
373-
Assert.Equal(-1, FloatingPointHelper<float>.ConvertToInteger<sbyte>(float.MaxValue));
374+
Assert.Equal(sbyte.MaxValue, FloatingPointHelper<float>.ConvertToInteger<sbyte>(float.MaxValue));
374375

375376
// Unsigned Values
376377

0 commit comments

Comments
 (0)