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

[test] Fix FixedPointConversion tests #23220

Merged
merged 1 commit into from Mar 21, 2019

Conversation

drodriguez
Copy link
Collaborator

Fix several problems with FixedPointConversion generation code.

The first problem is that at some point repr(value) was being used,
which turn the number into a string. That was great for printing the
number, but make the test against the value of the number (like
testValue < otherMin always false. There were a number of tests that
were never performed, specifically the integer tests.

The second problem was using doubles in the Python code. For Float32 and
Float64 the tests were generated correctly, but in the case of Float80,
the test adding or removing a quantity to the maximum/minimum were
failing because of the lack of precission (Adding 0.1 to a very
big/small number is the same as not adding anything). Switching to
Decimal should keep enough precission for the tests.

Finally the last problem was that the bounds of the conversions are not
actually selfMin and selfMax, but the values returned by the utility
function getFtoIBounds. For example for unsigned types, the lower
bound is always -1, not zero (every value between -1 and zero is rounded
to zero, and doesn't fail).

/cc @ultramiraculous

@jrose-apple jrose-apple requested review from stephentyrone and removed request for gribozavr March 12, 2019 00:06
@stephentyrone
Copy link
Member

@swift-ci please test

Fix several problems with FixedPointConversion generation code.

The first problem is that at some point `repr(value)` was being used,
which turn the number into a string. That was great for printing the
number, but make the test against the value of the number (like
`testValue < otherMin` always false. There were a number of tests that
were never performed, specifically the integer tests.

The second problem was using doubles in the Python code. For Float32 and
Float64 the tests were generated correctly, but in the case of Float80,
the test adding or removing a quantity to the maximum/minimum were
failing because of the lack of precission (Adding 0.1 to a very
big/small number is the same as not adding anything). Switching to
Decimal should keep enough precission for the tests.

Finally the last problem was that the bounds of the conversions are not
actually `selfMin` and `selfMax`, but the values returned by the utility
function `getFtoIBounds`. For example for unsigned types, the lower
bound is always -1, not zero (every value between -1 and zero is rounded
to zero, and doesn't fail).

Instead of using nested gyb templates, use lit.cfg %target-ptrsize,
which should be faster, cleaner, and provides correct line-directive
output.

Remove a bunch of warnings in Swift when compiling the generated result
of FixedPointConversion.swift.gyb.

Co-authored-by: Gwynne Raskind <gwynne@users.noreply.github.com>
@drodriguez
Copy link
Collaborator Author

@stephentyrone : I think I incorporated all the changes from Gwynne in the other PR. Do you mind restarting the CI and reviewing? Thanks!

/cc @gwynne

@stephentyrone
Copy link
Member

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test Linux Platform
Git Sha - 1ae5d044b536bf6935e6a962d179e4e572d54f69

@gwynne
Copy link
Contributor

gwynne commented Mar 14, 2019

Looks great to me!

@gwynne
Copy link
Contributor

gwynne commented Mar 14, 2019

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - 1ae5d044b536bf6935e6a962d179e4e572d54f69

@drodriguez
Copy link
Collaborator Author

@stephentyrone: can I/you merge this if there’s no objections?

@stephentyrone
Copy link
Member

@drodriguez Yeah, I'll give it a more careful review at some point, but I'm OK with taking it now.

@stephentyrone stephentyrone merged commit 4dcf60c into apple:master Mar 21, 2019
@davezarzycki
Copy link
Collaborator

@stephentyrone – This change caused a 2.25x regression in ninja check-swift-validation performance on my workstation. In other words, the FixedPointConversion tests are now 2.25x longer than the next longest test. Can we break this test up into smaller tests or make it be a "long_test"?

@stephentyrone
Copy link
Member

@davezarzycki I'm fine with that, but I won't have a chance to do it today. If you want to put up a PR, I can review.

@drodriguez drodriguez deleted the fixed-point-conversion-tests branch April 8, 2019 20:31
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.

None yet

5 participants