diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-04-14 10:33:10 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-04-14 11:33:56 +0200 |
commit | 0ba3d542cc236ab2dbed3dc551920ede94787a0c (patch) | |
tree | 9e7e6e0c26a8d2f8e5b62fbf2a609349acbd8855 /test/files | |
parent | 3a2901da406f2478b5634b0636e56de9c4cd676d (diff) | |
download | scala-0ba3d542cc236ab2dbed3dc551920ede94787a0c.tar.gz scala-0ba3d542cc236ab2dbed3dc551920ede94787a0c.tar.bz2 scala-0ba3d542cc236ab2dbed3dc551920ede94787a0c.zip |
restores some disabled macro tests, makes checkFeature synchronous when used for macros
Diffstat (limited to 'test/files')
22 files changed, 329 insertions, 5 deletions
diff --git a/test/files/neg/macro-deprecate-idents.check b/test/files/neg/macro-deprecate-idents.check new file mode 100644 index 0000000000..f8a7e519df --- /dev/null +++ b/test/files/neg/macro-deprecate-idents.check @@ -0,0 +1,52 @@ +macro-deprecate-idents.scala:2: error: macro is now a reserved word; usage as an identifier is deprecated
+ val macro = ???
+ ^
+macro-deprecate-idents.scala:6: error: macro is now a reserved word; usage as an identifier is deprecated
+ var macro = ???
+ ^
+macro-deprecate-idents.scala:10: error: macro is now a reserved word; usage as an identifier is deprecated
+ type macro = Int
+ ^
+macro-deprecate-idents.scala:14: error: macro is now a reserved word; usage as an identifier is deprecated
+ class macro
+ ^
+macro-deprecate-idents.scala:18: error: macro is now a reserved word; usage as an identifier is deprecated
+ class macro
+ ^
+macro-deprecate-idents.scala:22: error: macro is now a reserved word; usage as an identifier is deprecated
+ object macro
+ ^
+macro-deprecate-idents.scala:26: error: macro is now a reserved word; usage as an identifier is deprecated
+ object macro
+ ^
+macro-deprecate-idents.scala:30: error: macro is now a reserved word; usage as an identifier is deprecated
+ trait macro
+ ^
+macro-deprecate-idents.scala:34: error: macro is now a reserved word; usage as an identifier is deprecated
+ trait macro
+ ^
+macro-deprecate-idents.scala:37: error: macro is now a reserved word; usage as an identifier is deprecated
+package macro {
+ ^
+macro-deprecate-idents.scala:38: error: macro is now a reserved word; usage as an identifier is deprecated
+ package macro.bar {
+ ^
+macro-deprecate-idents.scala:43: error: macro is now a reserved word; usage as an identifier is deprecated
+ package macro.foo {
+ ^
+macro-deprecate-idents.scala:48: error: macro is now a reserved word; usage as an identifier is deprecated
+ val Some(macro) = Some(42)
+ ^
+macro-deprecate-idents.scala:49: error: macro is now a reserved word; usage as an identifier is deprecated
+ macro match {
+ ^
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
+ case macro => println(macro)
+ ^
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
+ case macro => println(macro)
+ ^
+macro-deprecate-idents.scala:55: error: macro is now a reserved word; usage as an identifier is deprecated
+ def macro = 2
+ ^
+17 errors found
diff --git a/test/files/neg/macro-deprecate-idents.flags b/test/files/neg/macro-deprecate-idents.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/macro-deprecate-idents.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/macro-deprecate-idents.scala b/test/files/neg/macro-deprecate-idents.scala new file mode 100644 index 0000000000..23c398e341 --- /dev/null +++ b/test/files/neg/macro-deprecate-idents.scala @@ -0,0 +1,56 @@ +object Test1 { + val macro = ??? +} + +object Test2 { + var macro = ??? +} + +object Test3 { + type macro = Int +} + +package test4 { + class macro +} + +object Test5 { + class macro +} + +package test6 { + object macro +} + +object Test7 { + object macro +} + +package test8 { + trait macro +} + +object Test9 { + trait macro +} + +package macro { + package macro.bar { + } +} + +package foo { + package macro.foo { + } +} + +object Test12 { + val Some(macro) = Some(42) + macro match { + case macro => println(macro) + } +} + +object Test13 { + def macro = 2 +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-d.check b/test/files/neg/macro-invalidshape-d.check new file mode 100644 index 0000000000..f0d77e2f2d --- /dev/null +++ b/test/files/neg/macro-invalidshape-d.check @@ -0,0 +1,8 @@ +Macros_Test_2.scala:2: warning: macro is now a reserved word; usage as an identifier is deprecated
+ def foo(x: Any) = {2; macro Impls.foo}
+ ^
+Macros_Test_2.scala:2: error: ';' expected but '.' found.
+ def foo(x: Any) = {2; macro Impls.foo}
+ ^
+one warning found
+one error found
diff --git a/test/files/neg/macro-invalidshape-d.flags b/test/files/neg/macro-invalidshape-d.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/neg/macro-invalidshape-d.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-d/Impls_1.scala b/test/files/neg/macro-invalidshape-d/Impls_1.scala new file mode 100644 index 0000000000..7b1620d117 --- /dev/null +++ b/test/files/neg/macro-invalidshape-d/Impls_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Any]) = ??? +} diff --git a/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala b/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala new file mode 100644 index 0000000000..bacd9a6e7c --- /dev/null +++ b/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo(x: Any) = {2; macro Impls.foo} +} + +object Test extends App { + import Macros._ + foo(42) +}
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check new file mode 100644 index 0000000000..fd2667dbb8 --- /dev/null +++ b/test/files/neg/macro-without-xmacros-a.check @@ -0,0 +1,17 @@ +Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
+ def foo(x: Int): Int = macro foo_impl
+ ^
+Macros_2.scala:7: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def bar(x: Int): Int = macro bar_impl
+ ^
+Macros_2.scala:11: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def quux(x: Int): Int = macro quux_impl
+ ^
+three errors found
diff --git a/test/files/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala new file mode 100644 index 0000000000..01daf12b1a --- /dev/null +++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + } + + def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + } + + def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + } +} diff --git a/test/files/neg/macro-without-xmacros-a/Macros_2.scala b/test/files/neg/macro-without-xmacros-a/Macros_2.scala new file mode 100644 index 0000000000..62f9dcf505 --- /dev/null +++ b/test/files/neg/macro-without-xmacros-a/Macros_2.scala @@ -0,0 +1,12 @@ +import Impls._ + +object Macros { + object Shmacros { + def foo(x: Int): Int = macro foo_impl + } + def bar(x: Int): Int = macro bar_impl +} + +class Macros { + def quux(x: Int): Int = macro quux_impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-a/Test_3.scala b/test/files/neg/macro-without-xmacros-a/Test_3.scala new file mode 100644 index 0000000000..e9a10e20c9 --- /dev/null +++ b/test/files/neg/macro-without-xmacros-a/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros.Shmacros._ + println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +}
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check new file mode 100644 index 0000000000..2d675b8319 --- /dev/null +++ b/test/files/neg/macro-without-xmacros-b.check @@ -0,0 +1,17 @@ +Macros_2.scala:3: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
+ def foo(x: Int): Int = macro Impls.foo_impl
+ ^
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def bar(x: Int): Int = macro Impls.bar_impl
+ ^
+Macros_2.scala:9: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def quux(x: Int): Int = macro Impls.quux_impl
+ ^
+three errors found
diff --git a/test/files/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala new file mode 100644 index 0000000000..01daf12b1a --- /dev/null +++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + } + + def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + } + + def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + } +} diff --git a/test/files/neg/macro-without-xmacros-b/Macros_2.scala b/test/files/neg/macro-without-xmacros-b/Macros_2.scala new file mode 100644 index 0000000000..de7080c7e8 --- /dev/null +++ b/test/files/neg/macro-without-xmacros-b/Macros_2.scala @@ -0,0 +1,10 @@ +object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo_impl + } + def bar(x: Int): Int = macro Impls.bar_impl +} + +class Macros { + def quux(x: Int): Int = macro Impls.quux_impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-b/Test_3.scala b/test/files/neg/macro-without-xmacros-b/Test_3.scala new file mode 100644 index 0000000000..e9a10e20c9 --- /dev/null +++ b/test/files/neg/macro-without-xmacros-b/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros.Shmacros._ + println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +}
\ No newline at end of file diff --git a/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala new file mode 100644 index 0000000000..69a7333011 --- /dev/null +++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala @@ -0,0 +1,56 @@ +object Test1 { + val `macro` = ??? +} + +object Test2 { + var `macro` = ??? +} + +object Test3 { + type `macro` = Int +} + +package test4 { + class `macro` +} + +object Test5 { + class `macro` +} + +package test6 { + object `macro` +} + +object Test7 { + object `macro` +} + +package test8 { + trait `macro` +} + +object Test9 { + trait `macro` +} + +package `macro` { + package `macro`.bar { + } +} + +package foo { + package `macro`.foo { + } +} + +//object Test12 { +// val Some(`macro`) = Some(42) +// `macro` match { +// case `macro` => println(`macro`) +// } +//} + +object Test13 { + def `macro` = 2 +}
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi.check b/test/files/run/macro-reflective-mamd-normal-mi.check new file mode 100644 index 0000000000..ac4213d6e9 --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi.check @@ -0,0 +1 @@ +43
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala new file mode 100644 index 0000000000..dc7d42d23e --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } +} diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala new file mode 100644 index 0000000000..cf34f1685d --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -0,0 +1,17 @@ +//object Macros { +// def foo(x: Int) = macro Impls.foo +//} + +object Test extends App { + import scala.reflect.mirror._ + + val macrobody = Select(Ident(newTermName("Impls")), newTermName("foo")) + val macroparam = ValDef(NoMods, newTermName("x"), TypeTree(definitions.IntClass.asType), EmptyTree) + val macrodef = DefDef(Modifiers(Set(scala.reflect.api.Modifier.`macro`)), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) + val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(Apply(Select(Super(This(EmptyTypeName), EmptyTypeName), nme.CONSTRUCTOR), List()))) + val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) + val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Block(macrodef, module, macroapp) + val toolbox = mkToolBox(options = "-language:experimental.macros") + println(toolbox.runExpr(tree)) +} diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index 5fe1e73a45..8d97a82799 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,5 +1,5 @@ -((x: scala.Predef.String) => { - val x$1 = x; - val x$2 = x; - Test.test(x$2, x$1) -}) +((x: String) => {
+ val x$1 = x;
+ val x$2 = x;
+ Test.this.test(x$2, x$1)
+})
diff --git a/test/files/run/t2886.scala b/test/files/run/t2886.scala new file mode 100644 index 0000000000..e0835a0a44 --- /dev/null +++ b/test/files/run/t2886.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test { + def test(name: String, address: String) = null + def main(args: Array[String]) = { + val tree = reify((x:String) => test(address=x,name=x)).tree + println(tree) + } +} |