diff --git a/build.sbt b/build.sbt index 5f182d7..83c1d76 100644 --- a/build.sbt +++ b/build.sbt @@ -47,7 +47,6 @@ lazy val scalacheck = project ) .dependsOn(core) - lazy val playJson = project .in(file("modules/play-json")) .settings( @@ -58,7 +57,6 @@ lazy val playJson = project ) .dependsOn(core) - lazy val tests = project .in(file("modules/tests")) .settings( diff --git a/modules/play-json/src/test/scala/Main.scala b/modules/play-json/src/test/scala/Main.scala deleted file mode 100644 index c3eb187..0000000 --- a/modules/play-json/src/test/scala/Main.scala +++ /dev/null @@ -1,27 +0,0 @@ -package scalaz - -package schema - -package play.json - -import scalaz.schema.TestMain -import testz.Harness -import testz.runner.Runner - -import scala.concurrent.Await -import scala.concurrent.ExecutionContext.global -import scala.concurrent.duration.Duration - -object Main extends TestMain { - - def tests[T](harness: Harness[T]): List[(String, T)] = - List( - ("Examples", PlayJsonExamples.tests(harness)) - ) - - def main(args: Array[String]): Unit = { - val result = Await.result(Runner(suites(harness), global), Duration.Inf) - - if (result.failed) throw new Exception("some tests failed") - } -} diff --git a/modules/tests/src/main/scala/Main.scala b/modules/tests/src/main/scala/Main.scala index 3150eae..3db9df3 100644 --- a/modules/tests/src/main/scala/Main.scala +++ b/modules/tests/src/main/scala/Main.scala @@ -45,7 +45,8 @@ object Main { ("Examples", SchemaModuleExamples.tests(harness)), ("JSON", JsonExamples.tests(harness)), ("Scalacheck generators", GenModuleExamples.tests(harness)), - ("Generic Show interpreter", ShowExamples.tests(harness)) + ("Generic Show interpreter", ShowExamples.tests(harness)), + ("Play-JSON codecs", PlayJsonExamples.tests(harness)) ) def main(args: Array[String]): Unit = { diff --git a/modules/play-json/src/test/scala/PlayJsonExamples.scala b/modules/tests/src/main/scala/PlayJsonExamples.scala similarity index 69% rename from modules/play-json/src/test/scala/PlayJsonExamples.scala rename to modules/tests/src/main/scala/PlayJsonExamples.scala index bdddcf0..ea09587 100644 --- a/modules/play-json/src/test/scala/PlayJsonExamples.scala +++ b/modules/tests/src/main/scala/PlayJsonExamples.scala @@ -2,17 +2,16 @@ package scalaz package schema -package play.json +package tests import testz._ import _root_.play.api.libs.json._ -import monocle.Iso import org.scalacheck._, Prop._, Arbitrary._ object PlayJsonExamples { - val jsonModule = new PlayJsonModule[JsonSchema.type] with scalacheck.GenModule[JsonSchema.type] { - val R = JsonSchema + val module = new TestModule with play.json.PlayJsonModule[JsonSchema.type] + with scalacheck.GenModule[JsonSchema.type] { implicit val primToGenNT = new (JsonSchema.Prim ~> Gen) { override def apply[A](prim: JsonSchema.Prim[A]): Gen[A] = prim match { @@ -52,7 +51,7 @@ object PlayJsonExamples { def tests[T](harness: Harness[T]): T = { import harness._ import Schema._ - import jsonModule._ + import module._ import JsonSchema._ section("play-json codecs")( @@ -67,34 +66,6 @@ object PlayJsonExamples { ) }, test("Derived `Reads` and `Writes` for a given schema should be symmetrical") { () => - val user = record( - "active" -*>: prim(JsonSchema.JsonBool), - Iso[Boolean, User](User.apply)(_.active) - ) - - val admin = record( - "rights" -*>: seq(prim(JsonSchema.JsonString)), - Iso[List[String], Admin](Admin.apply)(_.rights) - ) - - val person = record( - "name" -*>: prim(JsonSchema.JsonString) :*: - "role" -*>: optional( - union( - "user" -+>: user :+: - "admin" -+>: admin, - Iso[User \/ Admin, Role] { - case -\/(u) => u - case \/-(a) => a - } { - case u @ User(_) => -\/(u) - case a @ Admin(_) => \/-(a) - } - ) - ), - Iso[(String, Option[Role]), Person]((Person.apply _).tupled)(p => (p.name, p.role)) - ) - implicit val personGen = Arbitrary(person.to[Gen]) val reader = person.to[Reads]