Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable double-to-integer conversion tests #74980

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider changing CheckDouble so that it has an overload that takes two arguments: expected framework and expected core? That may make the callsite code a bit cleaner.

Copy link
Member Author

@jjonescz jjonescz Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be done but at the price of having to do many more code changes - the CheckDouble/CheckSingle methods are defined in each test separately (so either we would have to change the tests to share them or update the method in each of these tests), I'm not sure that's worth it.


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
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
Loading