summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-10-18 16:52:28 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-10-18 16:59:18 +0200
commita6d6550826c3fbd04948382893ce3147d298ffbc (patch)
tree0aa749c13ed646d8379f7e0ee037d87c97180f76 /test/files/run
parent3b4dc75710ac51de729224929690422d1b44e3ad (diff)
downloadscala-a6d6550826c3fbd04948382893ce3147d298ffbc.tar.gz
scala-a6d6550826c3fbd04948382893ce3147d298ffbc.tar.bz2
scala-a6d6550826c3fbd04948382893ce3147d298ffbc.zip
changes some manual tree constructions in macro tests to quasiquotes
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/macro-bundle-repl.check4
-rw-r--r--test/files/run/macro-bundle-repl.scala4
-rw-r--r--test/files/run/macro-bundle-static/Impls_Macros_1.scala8
-rw-r--r--test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala8
-rw-r--r--test/files/run/macro-expand-tparams-bounds/Impls_1.scala4
-rw-r--r--test/files/run/macro-expand-tparams-prefix/Impls_1.scala15
-rw-r--r--test/files/run/macro-impl-default-params/Impls_Macros_1.scala13
-rw-r--r--test/files/run/macro-impl-rename-context/Impls_Macros_1.scala5
-rw-r--r--test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala2
-rw-r--r--test/files/run/macro-system-properties.check2
-rw-r--r--test/files/run/macro-system-properties.scala2
-rw-r--r--test/files/run/repl-term-macros.check6
-rw-r--r--test/files/run/repl-term-macros.scala6
-rw-r--r--test/files/run/t5894.scala2
-rw-r--r--test/files/run/t5940.scala4
-rw-r--r--test/files/run/t6199-toolbox.scala2
16 files changed, 41 insertions, 46 deletions
diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check
index 008db4d7fd..c11c48dc55 100644
--- a/test/files/run/macro-bundle-repl.check
+++ b/test/files/run/macro-bundle-repl.check
@@ -7,13 +7,13 @@ import scala.language.experimental.macros
scala> import scala.reflect.macros.Macro
import scala.reflect.macros.Macro
-scala> trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) } };def bar = macro Bar.impl
+scala> trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
defined trait Bar
defined term macro bar: Unit
scala> bar
-scala> trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) } }
+scala> trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
defined trait Foo
scala> def foo = macro Foo.impl
diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala
index 06a6dcd5ce..3171aaacc2 100644
--- a/test/files/run/macro-bundle-repl.scala
+++ b/test/files/run/macro-bundle-repl.scala
@@ -4,9 +4,9 @@ object Test extends ReplTest {
def code = """
import scala.language.experimental.macros
import scala.reflect.macros.Macro
-trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) } };def bar = macro Bar.impl
+trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
bar
-trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) } }
+trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
def foo = macro Foo.impl
foo
"""
diff --git a/test/files/run/macro-bundle-static/Impls_Macros_1.scala b/test/files/run/macro-bundle-static/Impls_Macros_1.scala
index 79597ec4e5..e81fd0dbd6 100644
--- a/test/files/run/macro-bundle-static/Impls_Macros_1.scala
+++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala
@@ -4,8 +4,8 @@ import scala.language.experimental.macros
object Enclosing {
trait Impl extends Macro {
- def mono = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
- def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](Literal(Constant(c.weakTypeOf[T].toString))) }
+ def mono = { import c.universe._; c.Expr[Unit](q"()") }
+ def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") }
def weird = macro mono
}
}
@@ -18,8 +18,8 @@ object Macros {
package pkg {
object Enclosing {
trait Impl extends Macro {
- def mono = { import c.universe._; c.Expr[Boolean](Literal(Constant(true))) }
- def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](Literal(Constant(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString))) }
+ def mono = { import c.universe._; c.Expr[Boolean](q"true") }
+ def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") }
def weird = macro mono
}
}
diff --git a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
index e17dd6f6e1..8c7df2cdc5 100644
--- a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
+++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala
@@ -2,8 +2,8 @@ import scala.reflect.macros.Context
import scala.reflect.macros.Macro
trait Impl extends Macro {
- def mono = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
- def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](Literal(Constant(c.weakTypeOf[T].toString))) }
+ def mono = { import c.universe._; c.Expr[Unit](q"()") }
+ def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") }
def weird = macro mono
}
@@ -14,8 +14,8 @@ object Macros {
package pkg {
trait Impl extends Macro {
- def mono = { import c.universe._; c.Expr[Boolean](Literal(Constant(true))) }
- def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](Literal(Constant(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString))) }
+ def mono = { import c.universe._; c.Expr[Boolean](q"true") }
+ def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") }
def weird = macro mono
}
diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala
index bb6592615a..d63f034e9b 100644
--- a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala
@@ -1,12 +1,12 @@
import scala.reflect.macros.Context
object Impls1 {
- def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+ def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") }
}
class C
class D extends C
object Impls2 {
- def foo[U <: C](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+ def foo[U <: C](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") }
}
diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala
index e92396d1b4..a98c4abe78 100644
--- a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala
+++ b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala
@@ -5,8 +5,7 @@ object Impls1 {
def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = {
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
- val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString))))
- c.Expr[Unit](body)
+ c.Expr[Unit](q"println(${U.toString})")
}
}
@@ -16,18 +15,18 @@ object Impls2 {
val T = implicitly[c.WeakTypeTag[T]]
val U = implicitly[c.WeakTypeTag[U]]
val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString + " " + U.toString))))
- c.Expr[Unit](body)
+ c.Expr[Unit](q"""println(${T.toString} + " " + ${U.toString})""")
}
}
object Impls345 {
def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = {
import c.universe._
- c.Expr(Block(List(
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))),
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))),
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))),
- Literal(Constant(()))))
+ c.Expr(q"""
+ println(${T.toString})
+ println(${implicitly[c.WeakTypeTag[U]].toString})
+ println(${V.toString})
+ """)
}
}
diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
index 95d746980e..043675ec00 100644
--- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
+++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
@@ -6,13 +6,12 @@ object Impls {
import c.{prefix => prefix}
import c.universe._
val U = implicitly[c.WeakTypeTag[U]]
- val body = Block(List(
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))),
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))),
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))),
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + U.tpe))))),
- Literal(Constant(())))
- c.Expr[Unit](body)
+ c.Expr[Unit](q"""
+ println("invoking foo_targs...")
+ println("type of prefix is: " + ${prefix.staticType.toString})
+ println("type of prefix tree is: " + ${prefix.tree.tpe.toString})
+ println("U is: " + ${U.tpe.toString})
+ """)
}
}
diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala
index 738c88bbc8..5f3bbac719 100644
--- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala
+++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala
@@ -3,10 +3,7 @@ import scala.reflect.macros.{Context => Ctx}
object Impls {
def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = {
import unconventionalName.universe._
- val body = Block(List(
- Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo..."))))),
- Literal(Constant(())))
- unconventionalName.Expr[Unit](body)
+ unconventionalName.Expr[Unit](q"""println("invoking foo...")""")
}
}
diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala
index cbc1b8e539..24eacb36de 100644
--- a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala
+++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala
@@ -1,5 +1,5 @@
import scala.reflect.macros.{Context => Ctx}
object Impls {
- def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+ def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") }
}
diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check
index 3cbe5b9514..c61fe7f2cf 100644
--- a/test/files/run/macro-system-properties.check
+++ b/test/files/run/macro-system-properties.check
@@ -8,7 +8,7 @@ import reflect.macros.Context
scala> object GrabContext {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
- def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](Literal(Constant(()))) }
+ def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
def grab() = macro impl
}
defined object GrabContext
diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala
index 31bcdf2600..9dcd044dbd 100644
--- a/test/files/run/macro-system-properties.scala
+++ b/test/files/run/macro-system-properties.scala
@@ -7,7 +7,7 @@ object Test extends ReplTest {
object GrabContext {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
- def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](Literal(Constant(()))) }
+ def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
def grab() = macro impl
}
object Test { class C(implicit a: Any) { GrabContext.grab } }
diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check
index da3c70739e..63bafe401b 100644
--- a/test/files/run/repl-term-macros.check
+++ b/test/files/run/repl-term-macros.check
@@ -9,7 +9,7 @@ import language.experimental.macros
scala>
-scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
impl1: (c: scala.reflect.macros.Context)c.Expr[Unit]
scala> def foo1 = macro impl1
@@ -19,7 +19,7 @@ scala> foo1
scala>
-scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
impl2: (c: scala.reflect.macros.Context)()c.Expr[Unit]
scala> def foo2() = macro impl2
@@ -29,7 +29,7 @@ scala> foo2()
scala>
-scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
impl3: (c: scala.reflect.macros.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
scala> def foo3(x: Int)(y: Int) = macro impl3
diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala
index 9824bf49cb..125e397b22 100644
--- a/test/files/run/repl-term-macros.scala
+++ b/test/files/run/repl-term-macros.scala
@@ -5,15 +5,15 @@ object Test extends ReplTest {
import scala.reflect.macros.Context
import language.experimental.macros
-def impl1(c: Context) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo1 = macro impl1
foo1
-def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
def foo2() = macro impl2
foo2()
-def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
def foo3(x: Int)(y: Int) = macro impl3
foo3(2)(3)
"""
diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala
index 8da4aa8523..5deda34489 100644
--- a/test/files/run/t5894.scala
+++ b/test/files/run/t5894.scala
@@ -4,7 +4,7 @@ class Test
object Test {
def foo = macro fooImpl
- def fooImpl(c: reflect.macros.Context) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+ def fooImpl(c: reflect.macros.Context) = { import c.universe._; c.Expr[Unit](q"()") }
def main(args: Array[String]) {
try {
diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala
index 54aaf88684..9c8f702c68 100644
--- a/test/files/run/t5940.scala
+++ b/test/files/run/t5940.scala
@@ -7,12 +7,12 @@ object Test extends DirectTest {
import scala.reflect.macros.Context
object Impls {
- def impl(c: Context) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+ def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
}
object Macros {
//import Impls._
- def impl(c: Context) = { import c.universe._; c.Expr[Unit](Literal(Constant(()))) }
+ def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
def foo = macro impl
}
"""
diff --git a/test/files/run/t6199-toolbox.scala b/test/files/run/t6199-toolbox.scala
index 89015f5878..6ba5e50f66 100644
--- a/test/files/run/t6199-toolbox.scala
+++ b/test/files/run/t6199-toolbox.scala
@@ -4,5 +4,5 @@ import scala.tools.reflect.ToolBox
object Test extends App {
val tb = cm.mkToolBox()
- println(tb.eval(Literal(Constant(()))))
+ println(tb.eval(q"()"))
} \ No newline at end of file