diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-05-20 08:20:41 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-05-20 16:44:21 +0200 |
commit | d9ce4dc1eeb351a52e98c6c0fa1551a5cc3b87f5 (patch) | |
tree | 2b3efea4dc7779e85a09f036e1b08bcd8005a385 /test/junit/scala/tools | |
parent | 5d5a6aa154ab533dca4a0e589a7ae67c3c037d61 (diff) | |
download | scala-d9ce4dc1eeb351a52e98c6c0fa1551a5cc3b87f5.tar.gz scala-d9ce4dc1eeb351a52e98c6c0fa1551a5cc3b87f5.tar.bz2 scala-d9ce4dc1eeb351a52e98c6c0fa1551a5cc3b87f5.zip |
Better abstraction for JUnit run tests
Diffstat (limited to 'test/junit/scala/tools')
-rw-r--r-- | test/junit/scala/tools/testing/RunTesting.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/junit/scala/tools/testing/RunTesting.scala b/test/junit/scala/tools/testing/RunTesting.scala new file mode 100644 index 0000000000..1320db4230 --- /dev/null +++ b/test/junit/scala/tools/testing/RunTesting.scala @@ -0,0 +1,17 @@ +package scala.tools.testing + +import scala.reflect.runtime._ +import scala.tools.reflect.ToolBox + +trait RunTesting extends ClearAfterClass { + def compilerArgs = "" // to be overridden + val runner = cached("toolbox", () => Runner.make(compilerArgs)) +} + +class Runner(val toolBox: ToolBox[universe.type]) { + def run[T](code: String): T = toolBox.eval(toolBox.parse(code)).asInstanceOf[T] +} + +object Runner { + def make(compilerArgs: String) = new Runner(universe.runtimeMirror(getClass.getClassLoader).mkToolBox(options = compilerArgs)) +} |