Skip to content

Commit 59ab849

Browse files
committed
Fix run-macros/type-show
[Cherry-picked db1dcdc][modified]
1 parent ef56f15 commit 59ab849

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

tests/run-macros/type-show/Test_2.scala

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11

22
object Test {
33
import TypeToolbox.*
4+
5+
def assertEql[A](obt: A, exp: A): Unit =
6+
assert(obt == exp, s"\nexpected: $exp\nobtained: $obt")
7+
48
def main(args: Array[String]): Unit = {
59
val x = 5
6-
assert(show[x.type] == "x.type")
7-
assert(show[Nil.type] == "scala.Nil.type")
8-
assert(show[Int] == "scala.Int")
9-
assert(show[Int => Int] == "scala.Function1[scala.Int, scala.Int]")
10-
assert(show[(Int, String)] == "scala.Tuple2[scala.Int, scala.Predef.String]")
11-
assert(show[[X] =>> X match { case Int => Int }] ==
10+
assertEql(show[x.type], "x.type")
11+
assertEql(show[Nil.type], "scala.Nil.type")
12+
assertEql(show[Int], "scala.Int")
13+
assertEql(show[Int => Int], "scala.Function1[scala.Int, scala.Int]")
14+
assertEql(show[(Int, String)], "scala.Tuple2[scala.Int, scala.Predef.String]")
15+
assertEql(show[[X] =>> X match { case Int => Int }],
1216
"""[X >: scala.Nothing <: scala.Any] => X match {
1317
| case scala.Int => scala.Int
1418
|}""".stripMargin)
15-
assert(showStructure[[X] =>> X match { case Int => Int }] == """TypeLambda(List(X), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Nothing"), TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"))), MatchType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"), ParamRef(binder, 0), List(MatchCase(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int"), TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int")))))""")
19+
assertEql(showStructure[[X] =>> X match { case Int => Int }],
20+
"""TypeLambda("""+
21+
"""List(X), """+
22+
"""List(TypeBounds("""+
23+
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Nothing"), """+
24+
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"))), """+
25+
"""MatchType("""+
26+
"""TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int"), """+ // match type bound
27+
"""ParamRef(binder, 0), """+
28+
"""List("""+
29+
"""MatchCase("""+
30+
"""TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int"), """+
31+
"""TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int")))))""")
1632

1733
// TODO: more complex types:
1834
// - implicit function types

0 commit comments

Comments
 (0)