Skip to content

Commit 425be1a

Browse files
committed
Add test case for runtime behavior
1 parent 5216ca1 commit 425be1a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
not matched
2+
case 2 matched => 5
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import scala.quoted.*
2+
3+
inline def testExpr(inline body: Any) = ${ testExprImpl1('body) }
4+
def testExprImpl1(body: Expr[Any])(using Quotes): Expr[String] =
5+
body match
6+
case '{ [A] => (x : Int, y : Int) => $b(x, y) : Int } =>
7+
'{ "case 2 matched => " + $b(2, 3) }
8+
case '{ [A] => (x : A, y : A) => $b[A](x, y) : A } =>
9+
'{ "case 3 matched => " + $b[String]("truthy", "falsy") }
10+
case _ => Expr("not matched")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@main def Test: Unit =
2+
println(testExpr([B] => (x : B, y : B) => x)) // Should match case 3
3+
println(testExpr([B] => (x : Int, y : Int) => x + y)) // Should match case 2

0 commit comments

Comments
 (0)