Closed johnynek closed 9 years ago
We do something similar in Spire with Discipline (https://github.com/non/spire/tree/master/scalacheck-binding/src/main/scala/spire/laws) - I think @non was going to copy these tests over or follow a similar strategy.
Yes, definitely. My plan is to port over the discipline laws (assuming we are OK with a test dependency on Discipline). I was going to wait until we had hammered out exactly what we wanted, but obviously (as we saw) that allows bug to creep through, so I can also do it now.
One tricky thing is that since this project doesn't currently supply type class instances, we'd need "sample implementations" of those in order to test. What are people's thoughts about this?
I was thinking we could have a separate sub-project of "sample instances" that people could choose to use. That would allow us to use those for tests, and also to allow projects to share instances if they wanted. What do you all think?
Yeah, something like algebra-std
? You still need some toy instances though (see https://github.com/non/spire/blob/master/tests/src/test/scala/spire/laws/D3.scala)
+1 to algebra-std (or even algebra-standard to be a bit more verbose).
I'm starting to set this up. The basic project structure so far is:
core
builds the algebra
jarstd
builds the algebra-std
jarlaws
builds the algebra-laws
jar and also tests core
and std
for conformance.How does this sound? I went with std for brevity (mild preference) but if that is a pain I can extend it to standard.
Also are folks alright with ScalaTest, ScalaCheck, and Discipline being used for testing and law-checking?
+1 to all of this. Perfect.
One thing we did in algebird was make an algebird-test package. Here we defined thinks like
def monoidLaws[T: Arbitrary: Monoid]: Prop
so users could easily test their monoids just by making an Arbitrary for their type.It would be really nice to have something like this. If we want to generalize:
Then we could test triples like:
List(MonoidLaw, ListMonoid, implicitly[Arbitrary[List[Int]]], ...)