aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/CoproductTypeFormats.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2018-03-08 16:13:03 -0800
committerJakob Odersky <jakob@odersky.com>2018-03-08 16:21:49 -0800
commit5ef502abc058358ec3a329c774bb42b9a7bd106f (patch)
treeee5c20fa79307e1a8397a86f31fbe54cbfe9fe1a /src/test/scala/CoproductTypeFormats.scala
parenteb1ad3c956c828d421b7650dd3b01d5129a41a3d (diff)
downloadspray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.tar.gz
spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.tar.bz2
spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.zip
Don't ake derived formats implicit by defaultv0.3.0
Diffstat (limited to 'src/test/scala/CoproductTypeFormats.scala')
-rw-r--r--src/test/scala/CoproductTypeFormats.scala72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/test/scala/CoproductTypeFormats.scala b/src/test/scala/CoproductTypeFormats.scala
deleted file mode 100644
index 6496e00..0000000
--- a/src/test/scala/CoproductTypeFormats.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-package xyz.driver.json
-
-import spray.json._
-
-import org.scalatest._
-
-class CoproductTypeFormats
- extends FlatSpec
- with FormatTests
- with DefaultJsonProtocol
- with DerivedFormats {
-
- sealed trait Expr
- case class Zero() extends Expr
- case class Value(x: Int) extends Expr
- case class Plus(lhs: Expr, rhs: Expr) extends Expr
- case object One extends Expr
-
- "No-parameter case class child" should behave like checkRoundtrip[Expr](
- Zero(),
- """{"type":"Zero"}"""
- )
-
- "Simple parameter case class child" should behave like checkRoundtrip[Expr](
- Value(42),
- """{"type":"Value","x":42}"""
- )
-
- "Nested parameter case class child" should behave like checkRoundtrip[Expr](
- Plus(Value(42), One),
- """{"type":"Plus","lhs":{"type":"Value","x":42},"rhs":{"type":"One"}}"""
- )
-
- "Case object child" should behave like checkRoundtrip[Expr](
- One,
- """{"type": "One"}"""
- )
-
- @gadt("kind")
- sealed abstract class Keyword(`type`: String)
- case class If(`type`: String) extends Keyword(`type`)
-
- "GADT with type field alias" should behave like checkRoundtrip[Keyword](
- If("class"),
- """{"kind":"If","type":"class"}"""
- )
-
- @gadt("""_`crazy type!`"""")
- sealed abstract trait Crazy
- case class CrazyType() extends Crazy
-
- "GADT with special characters in type field" should behave like checkRoundtrip[
- Crazy](
- CrazyType(),
- """{"_`crazy type!`\"": "CrazyType"}"""
- )
-
- sealed trait Enum
- case object A extends Enum
- case object B extends Enum
-
- "Enum" should behave like checkRoundtrip[List[Enum]](
- A :: B :: Nil,
- """[{"type":"A"}, {"type":"B"}]"""
- )
-
- "Serializing as sealed trait an deserializing as child" should "work" in {
- val expr: Expr = Plus(Value(42), Plus(Zero(), One))
- assert(expr.toJson.convertTo[Plus] == expr)
- }
-
-}