Skip to content

Updated tests regarding issue #48119#52994

Merged
jeffhandley merged 4 commits intodotnet:mainfrom
ayousuf23:issue-48119
Oct 22, 2021
Merged

Updated tests regarding issue #48119#52994
jeffhandley merged 4 commits intodotnet:mainfrom
ayousuf23:issue-48119

Conversation

@ayousuf23
Copy link
Copy Markdown
Contributor

Added more tests cases for parsing floating-point types (single, double, half, decimal). Related to issue #48119. Note that this PR request is for checking why an "AmbigiousMatchException" is thrown when running the tests.

@ghost
Copy link
Copy Markdown

ghost commented May 19, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dnfadmin
Copy link
Copy Markdown

dnfadmin commented May 19, 2021

CLA assistant check
All CLA requirements met.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

ayousuf23 commented May 19, 2021

@pgovind Here is my pull request regarding issue #48119.

@ghost
Copy link
Copy Markdown

ghost commented May 28, 2021

Tagging subscribers to this area: @tannergooding
See info in area-owners.md if you want to be subscribed.

Issue Details

Added more tests cases for parsing floating-point types (single, double, half, decimal). Related to issue #48119. Note that this PR request is for checking why an "AmbigiousMatchException" is thrown when running the tests.

Author: ayousuf23
Assignees: -
Labels:

area-System.Runtime

Milestone: -

@danmoseley danmoseley requested a review from pgovind June 22, 2021 15:57
Comment thread src/libraries/System.Runtime/tests/System/DoubleTests.cs Outdated
Comment thread src/libraries/System.Runtime/System.Runtime.sln Outdated
@danmoseley
Copy link
Copy Markdown
Member

@ayousuf23 I apologize that we did not review this one promptly. It does not normally take this long. I left one comment otherwise it looks good once you resolve the conflicts.

Copy link
Copy Markdown

@pgovind pgovind Jun 22, 2021

Choose a reason for hiding this comment

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

I think you should replace Decimal.Parse(inputForDecimalWithDotAtMaxDigit) with 61111...111.m. That is because this unit test is called by the Parse method here: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime/tests/System/DecimalTests.cs#L814. If you look at the implementation of that method, it calls decimal.TryParse(value) and check if the returned out result is equal to expected on the next line (Line 824). With

yield return new object[] { inputForDecimalWithDotAtMaxDigit, defaultStyle, null, Decimal.Parse(inputForDecimalWithDotAtMaxDigit) };

value will be inputForDecimalWithDotAtMaxDigit and expected will be Decimal.Parse(inputForDecimalWithDotAtMaxDigit). So, we will end up checking Assert.Equal(Decimal.Parse(inputForDecimalWithDotAtMaxDigit), Decimal.Parse(inputForDecimalWithDotAtMaxDigit)) which means that we are not really testing result with a known correct expected value. So, the way to fix this is to specify expected directly as a decimal value. That way we actually test the Parse implementation.

Similar comments for double, single and half!

Copy link
Copy Markdown

@pgovind pgovind left a comment

Choose a reason for hiding this comment

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

The test cases themselves are good. Just needs 3 things:

  1. Fix the comment I left so we actually test the Parse routine
  2. Remove the changes to the sln file.
  3. You should rebase this PR on top of the current dotnet:main (or merge dotnet:main in to your branch) so you don't have merge conflicts anymore. Let me know if you need help here!

@ayousuf23
Copy link
Copy Markdown
Contributor Author

@pgovind I updated the test cases and removed the change in the sln file (this was caused by Visual Studio).

@terrajobst terrajobst added the community-contribution Indicates that the PR has been added by a community member label Jul 19, 2021
@pgovind
Copy link
Copy Markdown

pgovind commented Jul 21, 2021

I updated the test cases and removed the change in the sln file

Are you sure you pushed your latest commit? I still see the changes to the sln file.

This PR is almost ready. If you could just revert the changes to the sln file, I will approve it!!

@jeffhandley
Copy link
Copy Markdown
Member

@pgovind This PR is assigned to you for follow-up/decision before the RC1 snap.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

I'm so sorry, I didn't see your comment until now. I will check the sln file to ensure the line added by Visual Studio was removed.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

@pgovind I removed the lines from the sln file. It should be good to go!

Comment thread src/libraries/System.Runtime/System.Runtime.sln Outdated
Copy link
Copy Markdown

@pgovind pgovind left a comment

Choose a reason for hiding this comment

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

Still seeing changes to Runtime.sln. If you revert them so it doesn't even appear in the Files Changes tab, I can approve.

@pgovind
Copy link
Copy Markdown

pgovind commented Jul 29, 2021

I tried to clean up your commits, but it looks like you merged master into your branch? So there's a lot of history. If you find it hard to revert the changes to Runtime.sln, my suggestion is to just create a new branch off of current upstream/main and copy only the changes to the *.Tests.cs file.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

@pgovind Thanks for the suggestion! I copied the changes to the tests and reset the branch to dotnet/main and then added the changes to the tests. Sorry for the trouble. The file changed tab now shows only the lines added to the files for decimal/double/single/half.

@pgovind
Copy link
Copy Markdown

pgovind commented Aug 2, 2021

Weird, CI is failing now @ayousuf23.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

I tried to adjust the values for the string length for testing parsing a string with '.' at or after half/single max digit count. I'm just trying to see if the checks pass now.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

@pgovind I'm not sure why the checks are failing.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

ayousuf23 commented Aug 9, 2021

@pgovind I looked through the checks, and it seems like the tests are failing to parse ".234" which is expected to have the value 0.234.

@jeffhandley jeffhandley added this to the 7.0.0 milestone Aug 19, 2021
Copy link
Copy Markdown

@pgovind pgovind left a comment

Choose a reason for hiding this comment

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

The test changes LGTM. I do see a lot of weird CI errors though. I'll rerun CI and see if they reproduce. Thanks for the great work and patience here @ayousuf23

@tannergooding
Copy link
Copy Markdown
Member

@ayousuf23 it looks like there is at least one legitimate failure Test System.Tests.HalfTests.Parse_Span_Valid has failed.

Could you please take a look and address this or let us know if you need assistance? Doing a merge with upstream/main would likely also help with a few things in CI.

@jeffhandley
Copy link
Copy Markdown
Member

Failures are unrelated, as noted by the runfoapp bot.

@ayousuf23
Copy link
Copy Markdown
Contributor Author

@jeffhandley Thanks for the commit! @tannergooding I am sorry I did not respond earlier. Unfortunately, I do not have access to the computer I used previously to write the code and work on the project.

@jeffhandley
Copy link
Copy Markdown
Member

No worries, @ayousuf23; thanks for the contribution. It'll be nice to get this merged. 🙂

@ayousuf23
Copy link
Copy Markdown
Contributor Author

Thank you everyone for your help! This was my first PR and I learned a lot from it!

@danmoseley
Copy link
Copy Markdown
Member

@ayousuf23 thank you, and you would be welcome to offer another contribution if you are interested! There are lots of issues, many marked-up-for-grabs, and we can help find something matching your interests.

@jeffhandley jeffhandley merged commit ad5a46a into dotnet:main Oct 22, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Runtime community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants