summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-06-27 16:03:06 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-06-27 16:03:06 +0200
commit856fe4ad0472ab71d91a6ab442fba77c4cf9950b (patch)
treef45971d824669c0962ddb71b109837afd954c537 /test
parent899ad4f3f5388599b748525f4d412d7411b2b8f2 (diff)
parentfcb3932b32a2133612473e7b061859f97aa562df (diff)
downloadscala-856fe4ad0472ab71d91a6ab442fba77c4cf9950b.tar.gz
scala-856fe4ad0472ab71d91a6ab442fba77c4cf9950b.tar.bz2
scala-856fe4ad0472ab71d91a6ab442fba77c4cf9950b.zip
Merge pull request #3780 from xeno-by/topic/rangepos-macro-args
macro args now correctly preserve range positions
Diffstat (limited to 'test')
-rw-r--r--test/files/run/macro-rangepos-args.check1
-rw-r--r--test/files/run/macro-rangepos-args.flags1
-rw-r--r--test/files/run/macro-rangepos-args/Macros_1.scala10
-rw-r--r--test/files/run/macro-rangepos-args/Test_2.scala4
4 files changed, 16 insertions, 0 deletions
diff --git a/test/files/run/macro-rangepos-args.check b/test/files/run/macro-rangepos-args.check
new file mode 100644
index 0000000000..d779505c66
--- /dev/null
+++ b/test/files/run/macro-rangepos-args.check
@@ -0,0 +1 @@
+Line: 3. Width: 5.
diff --git a/test/files/run/macro-rangepos-args.flags b/test/files/run/macro-rangepos-args.flags
new file mode 100644
index 0000000000..fcf951d907
--- /dev/null
+++ b/test/files/run/macro-rangepos-args.flags
@@ -0,0 +1 @@
+-Yrangepos \ No newline at end of file
diff --git a/test/files/run/macro-rangepos-args/Macros_1.scala b/test/files/run/macro-rangepos-args/Macros_1.scala
new file mode 100644
index 0000000000..97b938613c
--- /dev/null
+++ b/test/files/run/macro-rangepos-args/Macros_1.scala
@@ -0,0 +1,10 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl(c: Context)(x: c.Tree): c.Tree = {
+ import c.universe._
+ Literal(Constant(s"Line: ${x.pos.line}. Width: ${x.pos.end - x.pos.start}."))
+ }
+ def pos(x: Any): String = macro impl
+}
diff --git a/test/files/run/macro-rangepos-args/Test_2.scala b/test/files/run/macro-rangepos-args/Test_2.scala
new file mode 100644
index 0000000000..8c770e9010
--- /dev/null
+++ b/test/files/run/macro-rangepos-args/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val x = 2
+ println(Macros.pos(x + 2))
+} \ No newline at end of file