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

fix undef var in conversion in rounding modes in MPFR #31258

Merged
merged 1 commit into from
Mar 29, 2019

Conversation

KristofferC
Copy link
Member

No description provided.

@martinholters
Copy link
Member

Worth a test?

@simonbyrne
Copy link
Contributor

(the change was only in 1.1, so doesn't need to be backported before that)

@StefanKarpinski StefanKarpinski added the needs tests Unit tests are required for this change label Mar 5, 2019
@simonbyrne
Copy link
Contributor

I'm also not sure how one could test this. I guess use reinterpret to create an enum with an invalid value?

@martinholters
Copy link
Member

Yes, something like this:

bad_rounding_mode = reinterpret(Base.MPFR.MPFRRoundingMode, Int32(42))
@test_throws ArgumentError convert(RoundingMode,  bad_rounding_mode)

Doing the reinterpret outside @test_throws has the advantage that the test doesn't pass accidentally in case the reinterpret throws an ArgumentError.

@KristofferC
Copy link
Member Author

It seems really weird to have to do something like reinterpreting to an invalid enum to test something. In fact, it can be determined deterministically that the error path cannot happen. So I can change it to just error("this should not happen") if you want to.

@martinholters
Copy link
Member

Yes, I was wondering the same. It's more an assertion then an ArgumentError.

@KristofferC
Copy link
Member Author

Since this is unreachable code but more correct unreachable code, I'll just merge it.

@KristofferC KristofferC merged commit c214427 into master Mar 29, 2019
@KristofferC KristofferC deleted the KristofferC-patch-9 branch March 29, 2019 21:52
@KristofferC KristofferC removed the needs tests Unit tests are required for this change label Mar 29, 2019
KristofferC added a commit that referenced this pull request Apr 15, 2019
@KristofferC KristofferC mentioned this pull request Apr 15, 2019
39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants