kowainik / tomland

🏝 Bidirectional TOML serialization
https://kowainik.github.io/posts/2019-01-14-tomland
Mozilla Public License 2.0
122 stars 39 forks source link

Add property-based tests for `BiMap` #119

Closed chshersh closed 5 years ago

chshersh commented 6 years ago

I would like to have hedgehog roundript tests for our BiMap because now they contain non-trivial logic.

astynax commented 6 years ago

I take this one. It seems like a good opportunity to play with hedgehog!

jiegillet commented 5 years ago

I've been working on this, and I have an interesting problem. My test tripping x (forward bimap) (join . fmap (backward bimap)) for _Double fails, because apparently

ghci> 0/0 == (0/0 :: Double)
False

What to do? :)

EDIT: I found a (ugly) way using isNaN.

chshersh commented 5 years ago

@jiegillet Trick with isNan is used for Eq instance for Value as well:

I guess it's okay to violate semantic for NaN in our case.