NorfairKing / validity

Validity and validity-based testing
https://www.youtube.com/watch?v=eIs9qNh17SM
MIT License
156 stars 31 forks source link

Aeson tests don't validate toJSON and toEncoding agree #93

Closed dustin closed 1 year ago

dustin commented 2 years ago

It's recommended to implement toEncoding when instantiating ToJSON, but there's no validation ensuring it agrees with toJSON (which is a requirement since it doesn't go the other way).

A simple workaround might be to encode toJSON v and v both while testing round tripping. They don't need to end with identical representations, but the decoder needs to agree that they're equivalent.

NorfairKing commented 2 years ago

Sounds good!

NorfairKing commented 1 year ago

PR welcome