diff options
author | François Garillot <francois@garillot.net> | 2013-09-24 11:41:22 +0200 |
---|---|---|
committer | François Garillot <francois@garillot.net> | 2013-09-24 12:01:08 +0200 |
commit | efd64ae594e286d2141d2cb99ec25d97de60a414 (patch) | |
tree | 551f523ca2a46be4ff6a19a0a2f3a78db9d83be8 | |
parent | 710401d8aec814d95b25ca2104036aa414a5db35 (diff) | |
download | scala-efd64ae594e286d2141d2cb99ec25d97de60a414.tar.gz scala-efd64ae594e286d2141d2cb99ec25d97de60a414.tar.bz2 scala-efd64ae594e286d2141d2cb99ec25d97de60a414.zip |
Add position check for regression introduced by #2957
The starting bound for ValDefs in #2957 is distinct from the expected result, e.g.
[4:9]val x = [8:9]0
instead of
[0:9]val x = [8:9]0
-rw-r--r-- | test/files/run/position-val-def.check | 30 | ||||
-rw-r--r-- | test/files/run/position-val-def.scala | 26 |
2 files changed, 56 insertions, 0 deletions
diff --git a/test/files/run/position-val-def.check b/test/files/run/position-val-def.check new file mode 100644 index 0000000000..a92c77c68c --- /dev/null +++ b/test/files/run/position-val-def.check @@ -0,0 +1,30 @@ +val x = 0 +[0:9]val x = [8:9]0 + +var x = 0 +[0:9]var x = [8:9]0 + +val x, y = 0 +[NoPosition]{ + [0:5]val x = [11]0; + [7:12]val y = [11:12]0; + [NoPosition]() +} + +var x, y = 0 +[NoPosition]{ + [0:5]var x = [11]0; + [7:12]var y = [11:12]0; + [NoPosition]() +} + +val (x, y) = 0 +[NoPosition]{ + <0:14><synthetic> <artifact> private[this] val x$1 = <4:14>[13:14][13:14]0: @[13]scala.unchecked match { + <4:10>case <4:10>[4]scala.Tuple2(<5:6>(x @ [5]_), <8:9>(y @ [8]_)) => <4:10><4:10>scala.Tuple2(<4:10>x, <4:10>y) + }; + [5:6]val x = [5]x$1._1; + [8:9]val y = [8]x$1._2; + [NoPosition]() +} + diff --git a/test/files/run/position-val-def.scala b/test/files/run/position-val-def.scala new file mode 100644 index 0000000000..62cb54acf8 --- /dev/null +++ b/test/files/run/position-val-def.scala @@ -0,0 +1,26 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test { + val toolbox = cm.mkToolBox(options = "-Yrangepos") + + def main(args: Array[String]) { + def test(expr: String) { + val t = toolbox.parse(expr) + println(expr) + println(show(t, printPositions = true)) + println() + } + val tests = """ + val x = 0 + var x = 0 + val x, y = 0 + var x, y = 0 + val (x, y) = 0 + """ + val exprs = tests.split("\\n").map(_.trim).filterNot(_.isEmpty) + exprs foreach test + } +} |