Skip to content

Commit

Permalink
Re-enable double-to-integer conversion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Sep 3, 2024
1 parent c6a0795 commit 8bde0d3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 39 deletions.
60 changes: 30 additions & 30 deletions src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenExpression.vb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Class C1
CheckSingle(1.99F, 1)
CheckSingle(Integer.MaxValue - 65F, 2147483520)
' https://github.com/dotnet/roslyn/issues/74026
' CheckSingle(Integer.MaxValue - 64F, Integer.MinValue) ' overflow
' CheckSingle(Integer.MaxValue - 0F, Integer.MinValue) ' overflow
CheckSingle(Integer.MaxValue - 64F, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckSingle(Integer.MaxValue - 0F, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

CheckDouble(Integer.MinValue - 1D, Integer.MinValue) ' overflow
CheckDouble(Integer.MinValue - 0.01D, Integer.MinValue)
Expand All @@ -89,8 +89,8 @@ Class C1
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.99D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -597,8 +597,8 @@ Class C1
CheckSingle(1.99F, 1)
CheckSingle(Integer.MaxValue - 65F, 2147483520)
' https://github.com/dotnet/roslyn/issues/74026
' CheckSingle(Integer.MaxValue - 64F, Integer.MinValue) ' overflow
' CheckSingle(Integer.MaxValue - 0F, Integer.MinValue) ' overflow
CheckSingle(Integer.MaxValue - 64F, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckSingle(Integer.MaxValue - 0F, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

CheckDouble(Integer.MinValue - 1D, Integer.MinValue) ' overflow
CheckDouble(Integer.MinValue - 0.01D, Integer.MinValue)
Expand All @@ -611,8 +611,8 @@ Class C1
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.99D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -1099,8 +1099,8 @@ Class C1
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.99D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -1390,8 +1390,8 @@ Class C1
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.99D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -1679,10 +1679,10 @@ Class C1
CheckDouble(Integer.MaxValue - 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 0.01D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 0.99D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 0.01D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 0.99D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -1986,10 +1986,10 @@ Class C1
CheckDouble(Integer.MaxValue - 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 0.01D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 0.99D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 0.01D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 0.99D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -2295,8 +2295,8 @@ Class C1
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.99D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -2602,8 +2602,8 @@ Class C1
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.99D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
Console.WriteLine("done")
End Sub

Expand Down Expand Up @@ -2907,9 +2907,9 @@ Class C1
CheckDouble(Integer.MaxValue + 0D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 0.99D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 0.99D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down Expand Up @@ -3214,9 +3214,9 @@ Class C1
CheckDouble(Integer.MaxValue + 0D, Integer.MaxValue)
CheckDouble(Integer.MaxValue + 0.01D, Integer.MaxValue)
' https://github.com/dotnet/roslyn/issues/74026
' CheckDouble(Integer.MaxValue + 0.99D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 1D, Integer.MinValue) ' overflow
' CheckDouble(Integer.MaxValue + 2D, Integer.MinValue) ' overflow
CheckDouble(Integer.MaxValue + 0.99D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 1D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow
CheckDouble(Integer.MaxValue + 2D, ]]><%= If(ExecutionConditionUtil.IsMonoOrCoreClr, "Integer.MaxValue", "Integer.MinValue") %><![CDATA[) ' overflow

Console.WriteLine("done")
End Sub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<RootNamespace></RootNamespace>

<!-- Disabling on assumption -->
Expand Down
26 changes: 18 additions & 8 deletions src/Compilers/VisualBasic/Test/Semantic/Semantics/Conversions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,7 @@ End Class

Assert.True(gotException)

' Conditioned due to https://github.com/dotnet/roslyn/issues/74026
If numericType IsNot byteType AndAlso CType(mv.Value, Double) <> CDbl(&HF000000000000000UL) Then
Assert.Equal(UncheckedConvert(intermediate, numericType), resultValue.Value)
End If
Assert.Equal(UncheckedConvert(mv.Value, numericType), resultValue.Value)
End If
Else
Assert.NotNull(resultValue)
Expand Down Expand Up @@ -1293,10 +1290,7 @@ End Class

Assert.True(gotException)

' Conditioned due to https://github.com/dotnet/roslyn/issues/74026
If numericType IsNot byteType AndAlso CType(mv.Value, Double) <> CDbl(&HF000000000000000UL) Then
Assert.Equal(UncheckedConvert(intermediate, numericType), resultValue.Value)
End If
Assert.Equal(UncheckedConvert(mv.Value, numericType), resultValue.Value)
End If
Else
Assert.NotNull(resultValue)
Expand Down Expand Up @@ -1405,6 +1399,22 @@ End Class
Throw New NotSupportedException()
End Select

Case TypeCode.Single, TypeCode.Double
Dim val As Double = Convert.ToDouble(value)

Select Case type.SpecialType
Case System_Byte : Return UncheckedCByte(UncheckedCLng(val))
Case System_SByte : Return UncheckedCSByte(UncheckedCLng(val))
Case System_Int16 : Return UncheckedCShort(UncheckedCLng(val))
Case System_UInt16 : Return UncheckedCUShort(UncheckedCLng(val))
Case System_Int32 : Return UncheckedCInt(UncheckedCLng(val))
Case System_UInt32 : Return UncheckedCUInt(UncheckedCLng(val))
Case System_Int64 : Return UncheckedCLng(val)
Case System_UInt64 : Return UncheckedCULng(val)
Case Else
Throw New NotSupportedException()
End Select

Case Else
Throw New NotSupportedException()
End Select
Expand Down

0 comments on commit 8bde0d3

Please sign in to comment.