Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Reapply VB Operator fixes#32459

Merged
danmoseley merged 2 commits intodotnet:masterfrom
hughbe:reapply-vb
Nov 22, 2018
Merged

Reapply VB Operator fixes#32459
danmoseley merged 2 commits intodotnet:masterfrom
hughbe:reapply-vb

Conversation

@hughbe
Copy link

@hughbe hughbe commented Sep 25, 2018

There seems to have been a regression with the printing of 0/-0 (maybe this was a deliberate change??)

Anyway, fixed

@danmoseley
Copy link
Member

Yes @tannergooding changed the behavior related to negative zero to be IEE754 compliant.

How are you dealing with this difference between Core and Desktop? Is that this 187ad6c ?

{
if (expected is double expectedDouble && actual is double actualDouble)
{
Assert.Equal(expected.ToString(), actual.ToString());
Copy link
Member

Choose a reason for hiding this comment

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

Why are you comparing equality using strings? That will not do what you expect for inputs that only differ in the 16th or 17th digit?

This should probably be doing:

if (double.IsNaN(expectedDouble))
{
    Assert.True(double.IsNaN(actualDouble));   
}
else
{
    Assert.Equal(BitConverter.DoubleToInt64Bits(expectedDouble), BitConverter.DoubleToInt64Bits(actualDouble));
}

Copy link
Author

Choose a reason for hiding this comment

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

This required a bunch of updating the expected test results but I actually just ended up with a simple assert.equal for float/double because if your condition works, then the doubles are necessarily equal, and the results are easier to view due to xunit printing the expected/actual values on failure

End If
Else
tc1 = conv1.GetTypeCode()
End If
Copy link

@cston cston Oct 19, 2018

Choose a reason for hiding this comment

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

When does this give a different result than the current implementation?

Never mind, it looks like this change reverts the implementation of this method so it matches the reference source.

}
else
{
Assert.Equal(expected.ToString(), actual.ToString());
Copy link
Member

Choose a reason for hiding this comment

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

As from before, this shouldn't be doing a string comparison, as that will end up truncating bits and doing a relative comparison.

Copy link
Author

Choose a reason for hiding this comment

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

Comment on an outdated commit, just look at the second commit now

@tannergooding
Copy link
Member

Which part of this is acommodating the the printing -0.0 change? This seems to be more generally involved than just that.

@hughbe
Copy link
Author

hughbe commented Oct 24, 2018

Which part of this is acommodating the the printing -0.0 change? This seems to be more generally involved than just that.

Commit 1 reapplies the reverted PR
Commit 2 fixes the PR not to compare strings and to support -0.0

else if (expected is float expectedFloat && actual is float actualFloat)
{
Assert.Equal(expected.ToString(), actual.ToString());
Assert.Equal(expectedFloat, actualFloat, 10);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think xUnit has an Assert.Equal overload that takes a float, so this will be converting to double and comparing those.

10 digits is also more than needed. System.Single has approx. 6-9 digits of precision, and you need at most 9 to uniquely represent every value.

if (expected is double expectedDouble && actual is double actualDouble)
{
Assert.Equal(expected.ToString(), actual.ToString());
Assert.Equal(expectedDouble, actualDouble, 10);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem right, on all platforms the results for these simple operations should be deterministic.

We were previously correct for 15 digits, so I would expect the same here (at a minimum). Ideally we would be comparing to the full 17 digits, however (or just doing a bit comparison).

Copy link

Choose a reason for hiding this comment

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

@hughbe, can we simply use Assert.Equal(expected, actual) in all cases?

Copy link

Choose a reason for hiding this comment

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

@hughbe, can we use Assert.Equal()? Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

This comment is out-of-date

* Add VB operator tests

* Delete dead code from VB operators

* Add comparison operator tests

* Add more tests

* Fix VB handling of DBNull.Value

* Do all number parsing in the invariant culture

* Workaround https://github.com/dotnet/coreclr/issues/8648
@hughbe
Copy link
Author

hughbe commented Nov 18, 2018

@dotnet-bot Test Linux x64 Release Build (System.Net.Http.Functional.Tests failed)

@hughbe
Copy link
Author

hughbe commented Nov 19, 2018

@dotnet-bot Test Linux x64 Release Build

@hughbe
Copy link
Author

hughbe commented Nov 22, 2018

Good to merge? :)

@danmoseley danmoseley merged commit 1c34aea into dotnet:master Nov 22, 2018
@hughbe hughbe deleted the reapply-vb branch November 22, 2018 17:27
jlennox pushed a commit to jlennox/corefx that referenced this pull request Dec 16, 2018
* Add more VB operator tests (dotnet#31320)

* Add VB operator tests

* Delete dead code from VB operators

* Add comparison operator tests

* Add more tests

* Fix VB handling of DBNull.Value

* Do all number parsing in the invariant culture

* Workaround https://github.com/dotnet/coreclr/issues/8648

* Accomodate for -0.0 change and fix test comparisons
@karelz karelz added this to the 3.0 milestone Dec 21, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Add more VB operator tests (dotnet/corefx#31320)

* Add VB operator tests

* Delete dead code from VB operators

* Add comparison operator tests

* Add more tests

* Fix VB handling of DBNull.Value

* Do all number parsing in the invariant culture

* Workaround https://github.com/dotnet/coreclr/issues/8648

* Accomodate for -0.0 change and fix test comparisons


Commit migrated from dotnet/corefx@1c34aea
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants