summaryrefslogtreecommitdiff
path: root/test/junit/scala/tools/testing/RunTesting.scala
blob: 1320db42302e1613f652857c9113212e15115bd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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))
}