This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Remove broken test in TimeSpanTests.cs #33925
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These two tests are expecting buggy behavior and should be removed.
When TimeSpan.Parse() is given one more fractional digit than is expected, it sometimes multiplies the result by 10. This shouldn't be expected behavior. I've detailed this bug here:
You can see there's something off just eyeballing the source code and how the pattern breaks in the last line:
Perhaps, it might, in some bizarre way, seem reasonable for "0.1 ticks" to round up to 1 tick (that's what the final test is effectively checking for). But with a little investigation, it's clearly a bug. If you replace 1 with 2 could also be checking that 0.2 ticks "rounds up" to 2 ticks, and this would "pass" also:
This is not how numbers work.
Or you could check that 100000 ticks (0.01s) == 1000000 ticks (0.1s), and you'd find this to also pass. Here you can see this behavior in action
Eventually the test should be replaced with something checking for sane behavior. It should really be rounding the fractional digits in the same way that
decimal.Parse()works. Failing that, it should at least throw a "Format" or even an "Overflow" exception (though extra decimal places isn't really an overflow). However it's fixed, these two tests are checking for incorrect behavior and should be removed.There's more discussion of the bug, a patch for the immediate problem, and discussion of better possible ways to fix it at dotnet/coreclr#21077