From 9b958c06ce121474b529664ce11211905a47083c Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Thu, 18 Apr 2019 13:20:47 +0200 Subject: [PATCH] Fix #6201: Add test --- tests/run-with-compiler/i6201/macro_1.scala | 15 +++++++++++++++ tests/run-with-compiler/i6201/test_2.scala | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/run-with-compiler/i6201/macro_1.scala create mode 100644 tests/run-with-compiler/i6201/test_2.scala diff --git a/tests/run-with-compiler/i6201/macro_1.scala b/tests/run-with-compiler/i6201/macro_1.scala new file mode 100644 index 000000000000..85fc35d598e6 --- /dev/null +++ b/tests/run-with-compiler/i6201/macro_1.scala @@ -0,0 +1,15 @@ +import scala.quoted._ +import scala.tasty._ + +inline def (inline x: String) strip: String = + ${ stripImpl(x) } + +def stripImpl(x: String)(implicit refl: Reflection): Expr[String] = + x.stripMargin.toExpr + +inline def isHello(inline x: String): Boolean = + ${ isHelloImpl(x) } + +def isHelloImpl(x: String)(implicit refl: Reflection): Expr[Boolean] = + if (x == "hello") true.toExpr else false.toExpr + diff --git a/tests/run-with-compiler/i6201/test_2.scala b/tests/run-with-compiler/i6201/test_2.scala new file mode 100644 index 000000000000..cb8c2053e673 --- /dev/null +++ b/tests/run-with-compiler/i6201/test_2.scala @@ -0,0 +1,6 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(isHello(strip("hello"))) + assert(!isHello(strip("bonjour"))) + } +} \ No newline at end of file