-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from theiterators/kebs-scalacheck-magnolia-#327
Kebs-scalacheck - derive Arbitrary instance using Magnolia instead of Shapeless
- Loading branch information
Showing
5 changed files
with
24 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
22 changes: 8 additions & 14 deletions
22
scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
package pl.iterators.kebs.scalacheck | ||
|
||
import enumeratum.ScalacheckInstances | ||
import org.scalacheck.{Arbitrary, Gen, ScalacheckShapeless} | ||
import enumeratum.{ScalacheckInstances => EnumScalacheckInstances} | ||
import org.scalacheck.Arbitrary | ||
import pl.iterators.kebs.macros.CaseClass1Rep | ||
|
||
import java.net.{URI, URL} | ||
import java.time.temporal.ChronoUnit | ||
import java.time._ | ||
import java.util.concurrent.TimeUnit | ||
import scala.reflect.ClassTag | ||
import scala.util.Random | ||
|
||
trait CommonArbitrarySupport extends ScalacheckShapeless with ScalacheckInstances { | ||
trait CommonArbitrarySupport extends EnumScalacheckInstances with ScalacheckInstancesSupport { | ||
|
||
implicit def caseClass1RepArbitraryPredef[T, A]( | ||
implicit rep: CaseClass1Rep[T, A], | ||
arbitrary: Arbitrary[A] | ||
): Arbitrary[T] = | ||
Arbitrary(arbitrary.arbitrary.map(rep.apply(_))) | ||
} | ||
arb: Arbitrary[A] | ||
): Arbitrary[T] = Arbitrary(arb.arbitrary.map(rep.apply(_))) | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/ScalacheckInstancesSupport.scala
This file contains 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
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] | ||
} |
This file contains 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
This file contains 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