summaryrefslogtreecommitdiff
path: root/src/partest-extras/scala/tools/partest
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 /src/partest-extras/scala/tools/partest
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 'src/partest-extras/scala/tools/partest')
-rw-r--r--src/partest-extras/scala/tools/partest/ScriptTest.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/partest-extras/scala/tools/partest/ScriptTest.scala b/src/partest-extras/scala/tools/partest/ScriptTest.scala
new file mode 100644
index 0000000000..24a4121b54
--- /dev/null
+++ b/src/partest-extras/scala/tools/partest/ScriptTest.scala
@@ -0,0 +1,21 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2013 LAMP/EPFL
+ */
+
+package scala.tools.partest
+
+import scala.reflect.internal.util.ScalaClassLoader
+
+/** A `ScriptTest` is a `DirectTest` for which the code
+ * is the contents of a script file.
+ */
+abstract class ScriptTest extends DirectTest {
+ def testmain = "TestMain"
+ override def extraSettings = s"-usejavacp -Xscript $testmain"
+ def scriptPath = testPath changeExtension "script"
+ def code = scriptPath.toFile.slurp
+ def show() = {
+ compile()
+ ScalaClassLoader(getClass.getClassLoader).run(testmain, Seq.empty[String])
+ }
+}