sorellabs / claire

[Unmaintained: please use jsverify instead] A property-based testing library for clearly specifying code invariants and behaviour.
MIT License
79 stars 4 forks source link

Make invariants return true by default? #15

Open robotlolita opened 11 years ago

robotlolita commented 11 years ago

This would allow a better integration with testing libraries. Right now, if you don't return anything from your property, the property fails. This is cool if you're doing comparisons in your property, since you're always returning a value anyways, but assertion libraries don't usually return a value, and as such you have to end all your properties with return true, which makes it not obvious what's being tested.

kennknowles commented 11 years ago

Perhaps a warning or just an informative failure message for properties that return undefined, since that is unlikely to occur in Claire's style. Maybe an implicit classifier of test cases into which falsey value they return.

robotlolita commented 11 years ago

Hm. Currently Claire uses null to signal that a test case was ignored. I can construct a disjoint type to handle this better and have Ignored <reason> | Success <value> | Rejected <value> | Failed <reason>. That way I believe it should be easy to provide a better reasoning for properties that are rejected with a falsy value.