Skip to content

Commit

Permalink
derive arbitrary instances using magnolify
Browse files Browse the repository at this point in the history
  • Loading branch information
pk044 committed Oct 30, 2023
1 parent 54ac330 commit 5fa88ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import java.util.concurrent.TimeUnit
import scala.reflect.ClassTag
import scala.util.Random
import magnolify.scalacheck.auto._
import magnolify.scalacheck.semiauto._

trait CommonArbitrarySupport extends ScalacheckInstances {
trait CommonArbitrarySupport extends ScalacheckInstances with ScalacheckInstancesSupport {

implicit def caseClass1RepArbitraryPredef[T, A](
implicit rep: CaseClass1Rep[T, A],
arb: Arbitrary[A]
): Arbitrary[T] = {
Arbitrary(arb.arbitrary.map(rep.apply(_)))
}
): Arbitrary[T] = Arbitrary(arb.arbitrary.map(rep.apply(_)))

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pl.iterators.kebs.scalacheck

import org.scalacheck._

trait ScalacheckInstancesSupport {
implicit def arb[T]: Arbitrary[T] = macro magnolify.scalacheck.auto.genArbitraryMacro[T]
}

0 comments on commit 5fa88ba

Please sign in to comment.