regarding property-based testing: allow equality to only return Prop instead of Boolean
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
For some types, equality is not decidable, but it's still possible to find counterexamples to equality. One of the simpler examples is function application. Consider we introduce
trait PropEq[A] {
def eqv(left: A, right: A): Prop[Boolean]
}
Then we can use this for functions:
implicit class functionEq[A, B](f: A => B)(implicit arbitrary: Arbitrary[A], eq: PropEq[A]) extends PropEq[A => B] {
def env(left: A => B, right: A => B) = forall (x => eq.eqv(left(x), right(y)))
}
For Eq instances, the PropEq instance can be implicitly inferred. Then we can use them in places like ApplicativeTests: instead of requiring an implicit Eq[A] etc. we only require PropEq[A] (in the end the result of this equality is converted to a prop anyway by isEqToProp implicit).
This would make the typeclass laws more useful, because we could then also automatically test instances which are not deterministically comparable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ApplicativeTests references and the isEqToProp conversion mentioned in the issue, then trace how existing Eq instances are required by property-based laws. The work is complete when PropEq can support nondeterministic equality, including function values, and the affected laws accept it without requiring deterministic Eq instances.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100