|
1 | 1 |
|
2 | 2 | object Test {
|
3 | 3 | import TypeToolbox.*
|
4 |
| - |
5 |
| - def assertEql[A](obt: A, exp: A): Unit = |
6 |
| - assert(obt == exp, s"\nexpected: $exp\nobtained: $obt") |
7 |
| - |
8 | 4 | def main(args: Array[String]): Unit = {
|
9 | 5 | val x = 5
|
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 }], |
| 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 }] == |
16 | 12 | """[X >: scala.Nothing <: scala.Any] => X match {
|
17 | 13 | | case scala.Int => scala.Int
|
18 | 14 | |}""".stripMargin)
|
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")))))""") |
| 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")))))""") |
32 | 16 |
|
33 | 17 | // TODO: more complex types:
|
34 | 18 | // - implicit function types
|
|
0 commit comments