Skip to content

Commit

Permalink
Add a value to Typeable recursive tree test (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 authored Jan 10, 2024
1 parent 9ccd0eb commit 8939588
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions modules/typeable/src/test/scala/shapeless3/typeable/typeable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,15 @@ class TypeableTests:

@Test
def testTree(): Unit =
val t = Typeable[Tree]
val v: Any = Tree(Vector(Tree(Vector.empty), Tree(Vector.empty)))
assert(t.castable(v))
assert(!t.castable("tree"))
assert(t.cast(v).contains(v))
assert(t.cast("tree").isEmpty)
assertEquals(t.describe, "Tree")
assertEquals(t.toString, "Typeable[Tree]")
val ti = Typeable[Tree[Int]]
val ts = Typeable[Tree[String]]
val tree: Any = Tree(1, Vector(Tree(2, Vector.empty), Tree(3, Vector.empty)))
assert(ti.castable(tree))
assert(!ts.castable(tree))
assert(ti.cast(tree).contains(tree))
assert(ts.cast(tree).isEmpty)
assertEquals(ti.describe, "Tree[Int]")
assertEquals(ti.toString, "Typeable[Tree[Int]]")

object TypeableTests:
final case class Tree(children: Vector[Tree])
final case class Tree[+A](value: A, children: Vector[Tree[A]])

0 comments on commit 8939588

Please sign in to comment.