Skip to content

Commit

Permalink
Merge pull request #74 from tflucke/scalajs-version-update
Browse files Browse the repository at this point in the history
Updated scala and scalajs version numbers.
  • Loading branch information
julienrf authored Jan 17, 2021
2 parents 2d19ac4 + 5e6a0e8 commit 08df196
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 39 deletions.
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

scalaVersion in ThisBuild := "2.13.0"
scalaVersion in ThisBuild := "2.13.3"

crossScalaVersions in ThisBuild := Seq(scalaVersion.value, "2.12.8")

Expand All @@ -13,9 +13,10 @@ val library =
name := "play-json-derived-codecs",
libraryDependencies ++= Seq(
"com.chuusai" %%% "shapeless" % "2.3.3",
"org.scalatest" %%% "scalatest" % "3.0.8" % Test,
"org.scalacheck" %%% "scalacheck" % "1.14.0" % Test,
"com.typesafe.play" %%% "play-json" % "2.8.0"
"org.scalatest" %%% "scalatest" % "3.2.3" % Test,
"org.scalacheck" %%% "scalacheck" % "1.15.2" % Test,
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.3.0" % Test,
"com.typesafe.play" %%% "play-json" % "2.9.2"
),
publishTo := {
val nexus = "https://oss.sonatype.org"
Expand Down Expand Up @@ -50,7 +51,7 @@ val library =
"-Xlint"
) ++
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => Seq("-Xsource:2.14")
case Some((2, n)) if n >= 13 => Seq("-Xsource:3")
case _ => Seq("-Yno-adapted-args", "-Ywarn-unused-import", "-Xfuture")
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ package julienrf.json.derived

import org.scalacheck.{Gen, Arbitrary}
import org.scalacheck.Arbitrary.arbitrary
import org.scalatest.FeatureSpec
import org.scalatest.prop.Checkers
import org.scalatest.featurespec.AnyFeatureSpec
import org.scalatestplus.scalacheck.Checkers
import play.api.libs.json.{JsNumber, Json, OFormat, OWrites, Reads, __}

class DerivedOFormatSuite extends FeatureSpec with Checkers {
class DerivedOFormatSuite extends AnyFeatureSpec with Checkers {

feature("encoding andThen decoding = identity") {
Feature("encoding andThen decoding = identity") {

scenario("product type") {
Scenario("product type") {
case class Foo(s: String, i: Int)
implicit val fooArbitrary: Arbitrary[Foo] =
Arbitrary(for (s <- arbitrary[String]; i <- arbitrary[Int]) yield Foo(s, i))
implicit val fooFormat: OFormat[Foo] = oformat()
identityLaw[Foo]
}

scenario("tuple type") {
Scenario("tuple type") {
type Foo = (String, Int)
implicit val fooFormat: OFormat[Foo] = oformat()

identityLaw[Foo]
}

scenario("sum types") {
Scenario("sum types") {
sealed trait Foo
case class Bar(x: Int) extends Foo
case class Baz(s: String) extends Foo
Expand Down Expand Up @@ -54,7 +54,7 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
}
}

scenario("recursive types") {
Scenario("recursive types") {
sealed trait Tree
case class Leaf(s: String) extends Tree
case class Node(lhs: Tree, rhs: Tree) extends Tree
Expand Down Expand Up @@ -83,7 +83,7 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
}
}

scenario("polylmorphic types") {
Scenario("polylmorphic types") {
case class Quux[A](value: A)
implicit val fooFormat: OFormat[Quux[Int]] = oformat()
implicit val arbitraryFoo: Arbitrary[Quux[Int]] =
Expand All @@ -95,8 +95,8 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
def identityLaw[A](implicit reads: Reads[A], owrites: OWrites[A], arbA: Arbitrary[A]): Unit =
check((a: A) => reads.reads(owrites.writes(a)).fold(_ => false, _ == a))

feature("default codecs represent sum types using nested JSON objects") {
scenario("default codecs represent sum types using nested JSON objects") {
Feature("default codecs represent sum types using nested JSON objects") {
Scenario("default codecs represent sum types using nested JSON objects") {
sealed trait Foo
case class Bar(x: Int) extends Foo
case class Baz(s: String) extends Foo
Expand All @@ -105,8 +105,8 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
}
}

feature("sum types JSON representation can be customized") {
scenario("sum types JSON representation can be customized") {
Feature("sum types JSON representation can be customized") {
Scenario("sum types JSON representation can be customized") {
sealed trait Foo
case class Bar(x: Int) extends Foo
case class Baz(s: String) extends Foo
Expand All @@ -115,25 +115,25 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
}
}

feature("case classes can have optional values") {
Feature("case classes can have optional values") {
case class Foo(s: Option[String])
implicit val fooFormat: OFormat[Foo] = oformat()
implicit val arbitraryFoo: Arbitrary[Foo] =
Arbitrary(for (s <- arbitrary[Option[String]]) yield Foo(s))

scenario("identity law") {
Scenario("identity law") {
identityLaw[Foo]
}

scenario("Missing fields are successfully decoded as `None`") {
Scenario("Missing fields are successfully decoded as `None`") {
assert(fooFormat.reads(Json.obj()).asOpt.contains(Foo(None)))
}

scenario("Wrong fields are errors") {
Scenario("Wrong fields are errors") {
assert(fooFormat.reads(Json.obj("s" -> 42)).asOpt.isEmpty)
}

scenario("Nested objects") {
Scenario("Nested objects") {
case class Bar(foo: Foo)
implicit val barFormat: OFormat[Bar] = oformat()
implicit val arbitraryBar: Arbitrary[Bar] =
Expand All @@ -146,8 +146,8 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
}
}

feature("error messages must be helpful") {
scenario("error messages must be helpful") {
Feature("error messages must be helpful") {
Scenario("error messages must be helpful") {
sealed trait Foo
case class Bar(x: Int) extends Foo
case class Baz(s: String) extends Foo
Expand All @@ -161,8 +161,8 @@ class DerivedOFormatSuite extends FeatureSpec with Checkers {
}
}

feature("user-defined type tags") {
scenario("user-defined type tags") {
Feature("user-defined type tags") {
Scenario("user-defined type tags") {
sealed trait Foo
case class Bar(x: Int) extends Foo
case class Baz(s: String) extends Foo
Expand Down
20 changes: 10 additions & 10 deletions library/src/test/scala/julienrf/json/derived/NameAdapterSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package julienrf.json.derived

import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.{Arbitrary, Gen}
import org.scalatest.FeatureSpec
import org.scalatest.prop.Checkers
import org.scalatest.featurespec.AnyFeatureSpec
import org.scalatestplus.scalacheck.Checkers
import play.api.libs.json._

class NameAdapterSuite extends FeatureSpec with Checkers {
class NameAdapterSuite extends AnyFeatureSpec with Checkers {

feature("use camelCase as the default casing for field names") {
Feature("use camelCase as the default casing for field names") {

scenario("product type") {
Scenario("product type") {
case class Foo(sC: String, iC: Int)
implicit val fooArbitrary: Arbitrary[(Foo, JsValue)] =
Arbitrary(for (s <- Gen.alphaStr; i <- arbitrary[Int]) yield (Foo(s, i), Json.obj("sC" -> s, "iC" -> i)))
Expand All @@ -20,17 +20,17 @@ class NameAdapterSuite extends FeatureSpec with Checkers {

}

feature("customize the casing for field names") {
Feature("customize the casing for field names") {

scenario("product type") {
Scenario("product type") {
case class Foo(sC: String, iC: Int)
implicit val fooArbitrary: Arbitrary[(Foo, JsValue)] =
Arbitrary(for (s <- Gen.alphaStr; i <- arbitrary[Int]) yield (Foo(s, i), Json.obj("s_c" -> s, "i_c" -> i)))
implicit val fooFormat: OFormat[Foo] = oformat(snakeAdapter())
jsonIdentityLaw[Foo]
}

scenario("sum types") {
Scenario("sum types") {
sealed trait Foo
case class Bar(xC: Int) extends Foo
case class Baz(sC: String) extends Foo
Expand All @@ -50,7 +50,7 @@ class NameAdapterSuite extends FeatureSpec with Checkers {
jsonIdentityLaw[Foo]
}

scenario("sum types with options") {
Scenario("sum types with options") {
sealed trait Foo
case class Bar(xC: Int) extends Foo
case class Baz(sC: String) extends Foo
Expand All @@ -73,7 +73,7 @@ class NameAdapterSuite extends FeatureSpec with Checkers {



scenario("recursive type") {
Scenario("recursive type") {
sealed trait Tree
case class Leaf(lS: String) extends Tree
case class Node(lhsSnake: Tree, rhsSnake: Tree) extends Tree
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.17
sbt.version=1.3.10
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.29")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")

0 comments on commit 08df196

Please sign in to comment.