Skip to content

Commit 8b8b258

Browse files
committed
Add test cases
1 parent e469bc5 commit 8b8b258

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

tests/run-macros/i17905.check

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
case 1: [3rd case] another_given outside
2-
case 2: [3rd case] given outside
1+
case 1: [matched 1st case] another_given outside
2+
case 2: [matched 2nd case] given outside
3+
case 3: [matched 1st case] another_given outside

tests/run-macros/i17905/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ inline def testCtxParam(inline body: Any) = ${ testCtxParamImpl('body) }
44
def testCtxParamImpl(body: Expr[Any])(using Quotes): Expr[String] =
55
body match
66
case '{ given i: String = "given"; def g(using s: String) = "placeholder"; $a(g, i): String } =>
7-
'{ $a(((s: String) ?=> s"[3rd case] ${s}"), "another_given") }
7+
'{ $a(((s: String) ?=> s"[matched 1st case] ${s}"), "another_given") }
88
case '{ def g(using s: String) = "placeholder"; $a(g): String } =>
9-
'{ $a((s: String) ?=> s"[3rd case] ${s}") }
9+
'{ $a((s: String) ?=> s"[matched 2nd case] ${s}") }
1010
case _ => Expr("not matched")

tests/run-macros/i17905/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
println("case 1: " + testCtxParam { given String = "given"; def f(using t: String) = "placeholder"; f + " outside" })
33
given String = "given"
44
println("case 2: " + testCtxParam { def f(using t: String) = "placeholder"; f + " outside" })
5+
/* This is expected to match the first case. The current QuoteMatcher identifies a function with a contextual function. */
6+
println("case 3: " + testCtxParam { given i: String = "given"; def a(x: String) = "placeholder"; a(i) + " outside" } )

0 commit comments

Comments
 (0)