summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-08-28 09:48:11 -0700
committerSom Snytt <som.snytt@gmail.com>2013-09-05 01:41:43 -0700
commite8af579a4442b3cda9ea82ddc1ce7f9bd6899418 (patch)
tree05e70d16bb0b6eed6d555132d4906de0e75b3e66 /test/files/run
parenta24fc60deed8fbed062ecd6ff96e434349cca75d (diff)
downloadscala-e8af579a4442b3cda9ea82ddc1ce7f9bd6899418.tar.gz
scala-e8af579a4442b3cda9ea82ddc1ce7f9bd6899418.tar.bz2
scala-e8af579a4442b3cda9ea82ddc1ce7f9bd6899418.zip
SI-7791 Line number table reflects underlying file
Since positions ultimately know their ultimate positions in their ultimate source, use that line number, ultimately, when emitting line number table entries. It is possible, but possibly not useful, to emit both the actual (ultimate) line number and the nominal one. The `int`-valued line number of the `StackTraceElement` is "derived" from the attribute. In global, wrapping a `BatchSourceFile` as a `ScriptSource` happens in `compileSources` to facilitate testing. A `ScriptTest` facility is provided to facilitate testing the script facility. It is rather facile.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t7791-script-linenums.check1
-rw-r--r--test/files/run/t7791-script-linenums.scala16
-rw-r--r--test/files/run/t7791-script-linenums.script8
3 files changed, 25 insertions, 0 deletions
diff --git a/test/files/run/t7791-script-linenums.check b/test/files/run/t7791-script-linenums.check
new file mode 100644
index 0000000000..b7d969564a
--- /dev/null
+++ b/test/files/run/t7791-script-linenums.check
@@ -0,0 +1 @@
+hello, scripted test
diff --git a/test/files/run/t7791-script-linenums.scala b/test/files/run/t7791-script-linenums.scala
new file mode 100644
index 0000000000..d89b8d4c63
--- /dev/null
+++ b/test/files/run/t7791-script-linenums.scala
@@ -0,0 +1,16 @@
+
+import scala.tools.partest.ScriptTest
+
+object Test extends ScriptTest {
+ object ExceptionLine {
+ def unapply(e: Exception) = Some(e.getStackTrace()(0).getLineNumber)
+ }
+ override def show() = {
+ import util._
+ Try(super.show()) match {
+ case Failure(ExceptionLine(7)) => ()
+ case Failure(e) => e.printStackTrace()
+ case Success(_) => Console println "Expected error"
+ }
+ }
+}
diff --git a/test/files/run/t7791-script-linenums.script b/test/files/run/t7791-script-linenums.script
new file mode 100644
index 0000000000..403dcc2d28
--- /dev/null
+++ b/test/files/run/t7791-script-linenums.script
@@ -0,0 +1,8 @@
+#!/bin/bash
+exec ${SCALA_HOME}/bin/scala "$0" "$@" 2>&1
+!#
+
+Console println s"hello, scripted test"
+
+throw new RuntimeException("failing") // line 7
+