diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-14 12:10:57 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-15 08:01:19 -0700 |
commit | 3262f7072b4060b1058acb6d772eaa61d4dec1d4 (patch) | |
tree | 8a4e0f285145d1f429096ad8dc08b90e846b5c38 /src/partest | |
parent | 930c85d6c96507d798d1847ea078eebf93dc0acb (diff) | |
parent | 83c1b1062957e50e5336c1b3409e54e0a5cce275 (diff) | |
download | scala-3262f7072b4060b1058acb6d772eaa61d4dec1d4.tar.gz scala-3262f7072b4060b1058acb6d772eaa61d4dec1d4.tar.bz2 scala-3262f7072b4060b1058acb6d772eaa61d4dec1d4.zip |
Merge remote-tracking branch 'origin/2.10.x' into merge-210
* origin/2.10.x: (68 commits)
Eliminate breaking relative names in source.
"Hot fix" for broken build.
Fix SI-4813 - Clone doesn't work on LinkedList.
Made 'def clone()' consistent with parens everywhere.
accommodates pull request feedback
SI-6310 redeploys the starr
SI-6310 AbsTypeTag => WeakTypeTag
SI-6323 outlaws free types from TypeTag
SI-6323 prohibits reflection against free types
improvements for reification of free symbols
removes build.newFreeExistential
SI-6359 Deep prohibition of templates in value class
Fixes SI-6259. Unable to use typeOf in super call of top-level object.
Fixes binary repo push for new typesafe repo layouts.
Better error message for pattern arity errors.
Rescued TreeBuilder from the parser.
Pending test for SI-3943
Test case for a bug fixed in M7.
Fix for SI-6367, exponential time in inference.
SI-6306 Remove incorrect eta-expansion optimization in Uncurry
...
Conflicts:
src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
Diffstat (limited to 'src/partest')
6 files changed, 44 insertions, 8 deletions
diff --git a/src/partest/scala/tools/partest/PartestDefaults.scala b/src/partest/scala/tools/partest/PartestDefaults.scala index 73a7b92778..b27ce6ff75 100644 --- a/src/partest/scala/tools/partest/PartestDefaults.scala +++ b/src/partest/scala/tools/partest/PartestDefaults.scala @@ -2,7 +2,7 @@ package scala.tools package partest import nsc.io.{ File, Path, Directory } -import util.{ PathResolver } +import scala.tools.util.PathResolver import nsc.Properties.{ propOrElse, propOrNone, propOrEmpty } import java.lang.Runtime.getRuntime diff --git a/src/partest/scala/tools/partest/TestUtil.scala b/src/partest/scala/tools/partest/TestUtil.scala index b86a8e2c7f..9bfd444180 100644 --- a/src/partest/scala/tools/partest/TestUtil.scala +++ b/src/partest/scala/tools/partest/TestUtil.scala @@ -1,5 +1,7 @@ package scala.tools.partest +import scala.reflect.{ classTag, ClassTag } + trait TestUtil { /** Given function and block of code, evaluates code block, * calls function with nanoseconds elapsed, and returns block result. @@ -29,8 +31,16 @@ trait TestUtil { assert(mult <= acceptableMultiple, "Performance difference too great: multiple = " + mult) } + + def intercept[T <: Exception : ClassTag](code: => Unit): Unit = + try { + code + assert(false, "did not throw " + classTag[T]) + } catch { + case ex: Exception if classTag[T].runtimeClass isInstance ex => + } } object TestUtil extends TestUtil { -}
\ No newline at end of file +} diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 064b82da85..512c718040 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -13,7 +13,7 @@ import java.io.{File, FilenameFilter, IOException, StringWriter, FileReader, PrintWriter, FileWriter} import java.net.URI import scala.tools.nsc.io.{ Path, Directory, File => SFile } -import sys.process._ +import scala.sys.process._ import scala.collection.mutable trait FileUtil { diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index 43ea0c7104..d283a6b476 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -312,8 +312,8 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP val testFiles = dir.listFiles.toList filter isJavaOrScala def isInGroup(f: File, num: Int) = SFile(f).stripExtension endsWith ("_" + num) - val groups = (0 to 9).toList map (num => testFiles filter (f => isInGroup(f, num))) - val noGroupSuffix = testFiles filterNot (groups.flatten contains) + val groups = (0 to 9).toList map (num => (testFiles filter (f => isInGroup(f, num))).sorted) + val noGroupSuffix = (testFiles filterNot (groups.flatten contains)).sorted noGroupSuffix :: groups filterNot (_.isEmpty) } diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala index 6fa31492f3..206ee19c76 100644 --- a/src/partest/scala/tools/partest/nest/SBTRunner.scala +++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala @@ -4,7 +4,7 @@ package nest import java.io.File import scala.tools.nsc.io.{ Directory } import scala.util.Properties.setProp -import collection.JavaConverters._ +import scala.collection.JavaConverters._ object SBTRunner extends DirectRunner { diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 09eb4b66f1..69d0ce9e4c 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -6,7 +6,7 @@ package scala.tools import java.io.{ FileNotFoundException, File => JFile } import nsc.io.{ Path, Directory, File => SFile } -import util.{ PathResolver } +import scala.tools.util.PathResolver import nsc.Properties.{ propOrElse, propOrNone, propOrEmpty } import scala.sys.process.javaVmArguments import java.util.concurrent.Callable @@ -62,7 +62,7 @@ package object partest { ) def allPropertiesString = { - import collection.JavaConversions._ + import scala.collection.JavaConversions._ System.getProperties.toList.sorted map { case (k, v) => "%s -> %s\n".format(k, v) } mkString "" } @@ -73,4 +73,30 @@ package object partest { def isPartestDebug: Boolean = propOrEmpty("partest.debug") == "true" + + import language.experimental.macros + + /** + * `trace("".isEmpty)` will return `true` and as a side effect print the following to standard out. + * {{{ + * trace> "".isEmpty + * res: Boolean = true + * + * }}} + * + * An alternative to [[scala.tools.partest.ReplTest]] that avoids the inconvenience of embedding + * test code in a string. + */ + def trace[A](a: A) = macro traceImpl[A] + + import scala.reflect.macros.Context + def traceImpl[A: c.WeakTypeTag](c: Context)(a: c.Expr[A]): c.Expr[A] = { + import c.universe._ + val exprCode = c.literal(show(a.tree)) + val exprType = c.literal(show(a.actualType)) + reify { + println(s"trace> ${exprCode.splice}\nres: ${exprType.splice} = ${a.splice}\n") + a.splice + } + } } |