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 machinery for implicit functions #316

Merged
merged 12 commits into from
Nov 29, 2020
Merged

Test machinery for implicit functions #316

merged 12 commits into from
Nov 29, 2020

Conversation

isovector
Copy link
Contributor

@isovector isovector commented Nov 27, 2020

This PR adds quickcheck machinery for testing implicit functions. It:

  1. Adds Arbitrary generators using the public interface, so that we can generate random symbolic objects.
  2. Adds an Observe instance for each, saying that two symbolic objects are equal if their getImplicit functions agree at all points. Future work should also ensure they have equal getBoxes, but due to rotate3 being currently broken, this isn't true today.
  3. Uses the above to write property tests (equivalent to 1600 unit tests!) for rotation.

The property tests have some unhappy results; getBox (rotate3 z) is broken, and that rotate3 (x, y, z) for x, y, z not in {0, 1} doesn't seem to satisfy any compositional properties. Fortunately these should both be fixed in #314.

There's also quite a lot of implicit bug workarounds in the isValid functions, necessary for working around partiality (like #304 and #306) in the library.

------------------------------------------------------------------------------
-- | The number of decimal points we need to agree to assume two 'Double's are
-- equal.
epsilon :: Int
Copy link
Member

Choose a reason for hiding this comment

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

because of the nature of floating point, anything that looks at decimal position is going to be fragile. there's functions for taking the 'integer' part and the 'multiplier' part and examining those seperately, for cases like this.

Copy link
Member

Choose a reason for hiding this comment

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

https://hackage.haskell.org/package/ieee-0.7/docs/Numeric-IEEE.html

take a look at sameSignificandBits . i think. I'm good with merging this without this, it seems good enough already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to merge this as is, but wouldn't push back too strongly if you're keen on it.

@julialongtin
Copy link
Member

And just a general point: the addition of another test system means we should probably have a TESTING.md file, describing all of the different test systems.

@julialongtin julialongtin merged commit 0573146 into Haskell-Things:master Nov 29, 2020
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.

2 participants