Skip to content

Commit 7f29fa8

Browse files
committed
add test for ordinal and fromProduct
1 parent 5006b3e commit 7f29fa8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/run/i10997.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class ClassWrapper {
2+
3+
sealed trait Parent
4+
case class Foo(x: Int, y: Int, s: String) extends Parent
5+
case class Bar(x: Int, y: Int) extends Parent
6+
7+
def testcase(): Unit =
8+
9+
val mirrorParent = summon[deriving.Mirror.Of[Parent]]
10+
val mirrorFoo = summon[deriving.Mirror.Of[Foo]]
11+
val mirrorBar = summon[deriving.Mirror.Of[Bar]]
12+
13+
val fooShapedTuple: (Int, Int, String) = (23, 47, "ok")
14+
val barShapedTuple: (Int, Int) = (57, 71)
15+
16+
val foo: Foo = mirrorFoo.fromProduct(fooShapedTuple)
17+
val bar: Bar = mirrorBar.fromProduct(barShapedTuple)
18+
19+
assert(foo == Foo(23, 47, "ok"))
20+
assert(bar == Bar(57, 71))
21+
22+
val fooOrd = mirrorParent.ordinal(foo)
23+
val barOrd = mirrorParent.ordinal(bar)
24+
25+
assert(fooOrd == 0)
26+
assert(barOrd == 1)
27+
}
28+
29+
@main def Test =
30+
ClassWrapper().testcase()

0 commit comments

Comments
 (0)