diff options
-rw-r--r-- | src/test/scala/scala/async/TreeInterrogation.scala | 6 | ||||
-rw-r--r-- | src/test/scala/scala/async/package.scala | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/test/scala/scala/async/TreeInterrogation.scala b/src/test/scala/scala/async/TreeInterrogation.scala index deaee03..43393a7 100644 --- a/src/test/scala/scala/async/TreeInterrogation.scala +++ b/src/test/scala/scala/async/TreeInterrogation.scala @@ -15,7 +15,7 @@ class TreeInterrogation { @Test def `a minimal set of vals are lifted to vars`() { val cm = reflect.runtime.currentMirror - val tb = mkToolbox("-cp target/scala-2.10/classes") + val tb = mkToolbox(s"-cp ${toolboxClasspath}") val tree = tb.parse( """| import _root_.scala.async.AsyncId._ | async { @@ -52,7 +52,7 @@ class TreeInterrogation { && !dd.symbol.asTerm.isAccessor && !dd.symbol.asTerm.isSetter => dd.name } }.flatten - defDefs.map(_.decoded.trim).toSet mustBe (Set("foo$1", "apply", "resume$async", "<init>")) + defDefs.map(_.decoded.trim).toSet mustBe (Set("foo$1", "apply", "resume", "<init>")) } } @@ -68,7 +68,7 @@ object TreeInterrogation extends App { withDebug { val cm = reflect.runtime.currentMirror - val tb = mkToolbox("-cp target/scala-2.10/classes -Xprint:flatten") + val tb = mkToolbox("-cp ${toolboxClasspath} -Xprint:flatten") import scala.async.Async._ val tree = tb.parse( """ import _root_.scala.async.AsyncId.{async, await} diff --git a/src/test/scala/scala/async/package.scala b/src/test/scala/scala/async/package.scala index 4a7a958..7c42024 100644 --- a/src/test/scala/scala/async/package.scala +++ b/src/test/scala/scala/async/package.scala @@ -42,7 +42,22 @@ package object async { m.mkToolBox(options = compileOptions) } - def expectError(errorSnippet: String, compileOptions: String = "", baseCompileOptions: String = "-cp target/scala-2.10/classes")(code: String) { + def scalaBinaryVersion: String = { + val Pattern = """(\d+\.\d+)\..*""".r + scala.util.Properties.versionNumberString match { + case Pattern(v) => v + case _ => "" + } + } + + def toolboxClasspath = { + val f = new java.io.File(s"target/scala-${scalaBinaryVersion}/classes") + if (!f.exists) sys.error(s"output directory ${f.getAbsolutePath} does not exist.") + f.getAbsolutePath + } + + def expectError(errorSnippet: String, compileOptions: String = "", + baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String) { intercept[ToolBoxError] { eval(code, compileOptions + " " + baseCompileOptions) }.getMessage mustContain errorSnippet |