Skip to content

Commit b963533

Browse files
committed
Add codec derivation test for recursive higher-kinded types
1 parent 21d984d commit b963533

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

jsoniter-scala-macros/shared/src/test/scala/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMakerSpec.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,6 +3113,16 @@ class JsonCodecMakerSpec extends VerifyingSpec {
31133113
verifySerDeser(codecOfFooForOption, Bar[Option](_root_.scala.Some(1)), """{"type":"Bar","a":1}""")
31143114
verifySerDeser(codecOfFooForOption, Baz[Option](_root_.scala.Some("VVV")), """{"type":"Baz","a":"VVV"}""")
31153115
}
3116+
"serialize and deserialize recursive higher-kinded types" in {
3117+
case class HigherKindedType[F[_]](f: F[Int], fs: F[HigherKindedType[F]])
3118+
3119+
verifySerDeser(JsonCodecMaker.make[HigherKindedType[Option]](CodecMakerConfig.withAllowRecursiveTypes(true)),
3120+
HigherKindedType[Option](_root_.scala.Some(1), _root_.scala.Some(HigherKindedType[Option](_root_.scala.Some(2), _root_.scala.None))),
3121+
"""{"f":1,"fs":{"f":2}}""")
3122+
verifySerDeser(JsonCodecMaker.make[HigherKindedType[Seq]](CodecMakerConfig.withAllowRecursiveTypes(true)),
3123+
HigherKindedType[Seq](Seq(1, 2, 3), Seq(HigherKindedType[Seq](Seq(4, 5, 6), Seq()))),
3124+
"""{"f":[1,2,3],"fs":[{"f":[4,5,6]}]}""")
3125+
}
31163126
"serialize and deserialize case classes with an auxiliary constructor using primary one" in {
31173127
case class AuxiliaryConstructor(i: Int, s: String = "") {
31183128
def this(s: String) = this(0, s)

0 commit comments

Comments
 (0)