Skip to content

Commit

Permalink
ADT test no longer needs JSON special case handling
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Nov 11, 2020
1 parent 12aa6a9 commit 419e565
Showing 1 changed file with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import io.bullet.borer._
import utest._

import scala.util.{Failure, Try}
import scala.util.control.NonFatal

abstract class DerivationSpec(target: Target) extends AbstractBorerSpec {
import Dom._
Expand Down Expand Up @@ -428,26 +427,21 @@ abstract class DerivationSpec(target: Target) extends AbstractBorerSpec {
"ADT" - {
import ADT._

try {
implicit val dogCodec = deriveCodec[Dog]
implicit val catCodec = deriveCodec[Cat]
implicit val mouseCodec = deriveCodec[Mouse]
implicit val animalCodec = deriveCodec[Animal]

val animals: List[Animal] = List(
Dog(12, "Fred"),
Cat(weight = 1.0, color = "none", home = "there"),
Dog(4, "Lolle"),
Mouse(true)
)
implicit val dogCodec = deriveCodec[Dog]
implicit val catCodec = deriveCodec[Cat]
implicit val mouseCodec = deriveCodec[Mouse]
implicit val animalCodec = deriveCodec[Animal]

val encoded = encode(animals)
decode[Element](encoded) ==> mapBasedAnimalsDom
decode[List[Animal]](encoded) ==> animals
} catch {
case NonFatal(e) if target == Json =>
e.getMessage ==> "JSON does not support integer values as a map key (Output.ToByteArray index 124)"
}
val animals: List[Animal] = List(
Dog(12, "Fred"),
Cat(weight = 1.0, color = "none", home = "there"),
Dog(4, "Lolle"),
Mouse(true)
)

val encoded = encode(animals)
decode[Element](encoded) ==> mapBasedAnimalsDom
decode[List[Animal]](encoded) ==> animals
}

"ADT Key Collision" - {
Expand Down

0 comments on commit 419e565

Please sign in to comment.