From 9d2853bcded9a92786e01aa11b4430a5943ea111 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 30 Jan 2020 10:57:22 +0100 Subject: [PATCH] Fix #8115: Add regression test --- tests/run-macros/i8115/Macro_2.scala | 12 ++++++++++++ tests/run-macros/i8115/MyClass_1.scala | 3 +++ tests/run-macros/i8115/Test_3.scala | 3 +++ tests/run-macros/i8115b/Macro_2.scala | 14 ++++++++++++++ tests/run-macros/i8115b/MyClass_1.scala | 3 +++ tests/run-macros/i8115b/Test_3.scala | 4 ++++ 6 files changed, 39 insertions(+) create mode 100644 tests/run-macros/i8115/Macro_2.scala create mode 100644 tests/run-macros/i8115/MyClass_1.scala create mode 100644 tests/run-macros/i8115/Test_3.scala create mode 100644 tests/run-macros/i8115b/Macro_2.scala create mode 100644 tests/run-macros/i8115b/MyClass_1.scala create mode 100644 tests/run-macros/i8115b/Test_3.scala diff --git a/tests/run-macros/i8115/Macro_2.scala b/tests/run-macros/i8115/Macro_2.scala new file mode 100644 index 000000000000..3737865774f5 --- /dev/null +++ b/tests/run-macros/i8115/Macro_2.scala @@ -0,0 +1,12 @@ +package example + +import scala.quoted._ + +object MyClassMaker { + inline def make: MyClass = ${ makeImpl } + def makeImpl(given qctx: QuoteContext): Expr[MyClass] = { + '{ + new MyClass { } /* eventually I want to add properties inside */ + } + } +} \ No newline at end of file diff --git a/tests/run-macros/i8115/MyClass_1.scala b/tests/run-macros/i8115/MyClass_1.scala new file mode 100644 index 000000000000..e16794d625ba --- /dev/null +++ b/tests/run-macros/i8115/MyClass_1.scala @@ -0,0 +1,3 @@ +package example + +class MyClass { } diff --git a/tests/run-macros/i8115/Test_3.scala b/tests/run-macros/i8115/Test_3.scala new file mode 100644 index 000000000000..fc2d73802900 --- /dev/null +++ b/tests/run-macros/i8115/Test_3.scala @@ -0,0 +1,3 @@ +@main def Test() = { + val typeclass = example.MyClassMaker.make +} diff --git a/tests/run-macros/i8115b/Macro_2.scala b/tests/run-macros/i8115b/Macro_2.scala new file mode 100644 index 000000000000..998263767989 --- /dev/null +++ b/tests/run-macros/i8115b/Macro_2.scala @@ -0,0 +1,14 @@ +package example + +import scala.quoted._ + +object MyClassMaker { + inline def make: MyClass = ${ makeImpl } + def makeImpl(given qctx: QuoteContext): Expr[MyClass] = { + '{ + new MyClass { + override def toString(): String = "MyClassMaker.make.MyClass" + } + } + } +} \ No newline at end of file diff --git a/tests/run-macros/i8115b/MyClass_1.scala b/tests/run-macros/i8115b/MyClass_1.scala new file mode 100644 index 000000000000..e16794d625ba --- /dev/null +++ b/tests/run-macros/i8115b/MyClass_1.scala @@ -0,0 +1,3 @@ +package example + +class MyClass { } diff --git a/tests/run-macros/i8115b/Test_3.scala b/tests/run-macros/i8115b/Test_3.scala new file mode 100644 index 000000000000..066581951503 --- /dev/null +++ b/tests/run-macros/i8115b/Test_3.scala @@ -0,0 +1,4 @@ +@main def Test() = { + val typeclass = example.MyClassMaker.make + assert(typeclass.toString == "MyClassMaker.make.MyClass") +}