diff --git a/build.sbt b/build.sbt index b9ccdee4..134c159d 100644 --- a/build.sbt +++ b/build.sbt @@ -123,7 +123,7 @@ val circeParser = "io.circe" %% "circe-parser" % circeV val jsonschema = "com.github.andyglow" %% "scala-jsonschema" % "0.7.11" val scalacheck = "org.scalacheck" %% "scalacheck" % "1.17.0" % "test" -val scalacheckShapeless = "com.github.alexarchambault" %% "scalacheck-shapeless_1.15" % "1.3.0" +val scalacheckMagnolify = "com.spotify" % "magnolify-scalacheck" % "0.6.4" val scalacheckDerived = "io.github.martinhh" %% "scalacheck-derived" % "0.4.2" val scalacheckEnumeratum = "com.beachape" %% "enumeratum-scalacheck" % "1.7.3" @@ -262,10 +262,9 @@ lazy val jsonschemaSettings = commonSettings ++ Seq( lazy val scalacheckSettings = commonSettings ++ Seq( libraryDependencies += scalacheck.cross(CrossVersion.for3Use2_13), libraryDependencies += scalacheckEnumeratum.cross(CrossVersion.for3Use2_13), - libraryDependencies += scalacheckShapeless.cross(CrossVersion.for3Use2_13), ) ++ Seq( libraryDependencies ++= (if (scalaVersion.value.startsWith("3")) Seq(scalacheckDerived) - else Nil)) + else Nil)) ++ Seq(libraryDependencies ++= (if(scalaVersion.value.startsWith("2")) Seq(scalacheckMagnolify.cross(CrossVersion.for3Use2_13)) else Nil)) lazy val taggedSettings = commonSettings ++ Seq( libraryDependencies += optionalSlick.cross(CrossVersion.for3Use2_13), diff --git a/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala b/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala index 6615a404..017a1cb3 100644 --- a/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala +++ b/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala @@ -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(_))) -} \ No newline at end of file + arb: Arbitrary[A] + ): Arbitrary[T] = Arbitrary(arb.arbitrary.map(rep.apply(_))) + +} diff --git a/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/ScalacheckInstancesSupport.scala b/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/ScalacheckInstancesSupport.scala new file mode 100644 index 00000000..0bd74bc1 --- /dev/null +++ b/scalacheck/src/main/scala-2/pl/iterators/kebs/scalacheck/ScalacheckInstancesSupport.scala @@ -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] +} \ No newline at end of file diff --git a/scalacheck/src/main/scala-3/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala b/scalacheck/src/main/scala-3/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala index db3b40bb..b15c7153 100644 --- a/scalacheck/src/main/scala-3/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala +++ b/scalacheck/src/main/scala-3/pl/iterators/kebs/scalacheck/CommonArbitrarySupport.scala @@ -10,11 +10,11 @@ import java.util.concurrent.TimeUnit import scala.reflect.ClassTag import scala.util.Random import io.github.martinhh.derived.scalacheck.given -import enumeratum.ScalacheckInstances -trait CommonArbitrarySupport extends ScalacheckInstances { +import enumeratum.{ScalacheckInstances => EnumScalacheckInstances} +trait CommonArbitrarySupport extends EnumScalacheckInstances { implicit def caseClass1RepArbitraryPredef[T, A]( implicit rep: CaseClass1Rep[T, A], arbitrary: Arbitrary[A] ): Arbitrary[T] = Arbitrary(arbitrary.arbitrary.map(rep.apply(_))) -} \ No newline at end of file +} diff --git a/scalacheck/src/main/scala/pl/iterators/kebs/scalacheck/ArbitrarySupport.scala b/scalacheck/src/main/scala/pl/iterators/kebs/scalacheck/ArbitrarySupport.scala index d00c6ce4..d0a5c940 100644 --- a/scalacheck/src/main/scala/pl/iterators/kebs/scalacheck/ArbitrarySupport.scala +++ b/scalacheck/src/main/scala/pl/iterators/kebs/scalacheck/ArbitrarySupport.scala @@ -1,8 +1,6 @@ package pl.iterators.kebs.scalacheck -import enumeratum.ScalacheckInstances -import org.scalacheck.{Arbitrary, Gen, ScalacheckShapeless} -import pl.iterators.kebs.macros.CaseClass1Rep +import org.scalacheck.{Arbitrary, Gen} import java.net.{URI, URL} import java.time.temporal.ChronoUnit @@ -93,10 +91,10 @@ trait KebsArbitraryPredefs { implicit val arbUri: Arbitrary[URI] = Arbitrary { for { - protocol <- Gen.oneOf("http", "https", "ftp", "file") - domain <- Gen.alphaNumStr + protocol <- Gen.oneOf("http", "https", "ftp", "file") + domain <- Gen.alphaNumStr subdomain <- Gen.alphaNumStr - path <- Gen.alphaNumStr + path <- Gen.alphaNumStr } yield new URI(s"$protocol://$subdomain.$domain.test/$path") }