Created
March 1, 2022 14:41
-
-
Save Daenyth/42a5bfefb9049835bb9551a691d51b4c to your computer and use it in GitHub Desktop.
munit-discipline cats law testing example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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