Skip to content

Instantly share code, notes, and snippets.

@Daenyth
Created March 1, 2022 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daenyth/42a5bfefb9049835bb9551a691d51b4c to your computer and use it in GitHub Desktop.
Save Daenyth/42a5bfefb9049835bb9551a691d51b4c to your computer and use it in GitHub Desktop.
munit-discipline cats law testing example
import cats.kernel.laws.discipline.SemigroupTests
import cats.syntax.all._
import munit.DisciplineSuite
import org.scalacheck.Arbitrary
case class MyInt(value: Int)
object MyInt {
implicit val semigroupMyInt: Semigroup[MyInt] = Semigroup.instance((x1, x2) => MyInt(x1.value + x2.value))
}
class BatchStateSpec extends DisciplineSuite {
implicit val arbMyInt: Arbitrary[MyInt] = Arbitrary(Arbitrary.arbitrary[Int].map(MyInt(_)))
implicit val eqMyInt: Eq[MyInt] = Eq.fromUniversalEquals
checkAll("Semigroup[MyInt]", SemigroupTests[MyInt].semigroup)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment