summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-03-12 17:47:39 -0400
committerPaul Phillips <paulp@improving.org>2012-03-16 12:19:02 -0700
commit8ebfd48564c905624eecfc0efb51fd124c60c6a1 (patch)
tree75b80c7328d152b3f88cbe8664a5de80c726fc18 /src/partest
parentb27a31b87d5ae42a51ee026d3d4fa181249ec669 (diff)
downloadscala-8ebfd48564c905624eecfc0efb51fd124c60c6a1.tar.gz
scala-8ebfd48564c905624eecfc0efb51fd124c60c6a1.tar.bz2
scala-8ebfd48564c905624eecfc0efb51fd124c60c6a1.zip
Testing compiler asSeenFrom directly.
It's more of a "dump what it says to a file so we'll know if any of this ever changes" than a "test" per se. It could use some wheat/chaff/nonsense/sense sorting. Still, it would be great to have more stuff like this.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/CompilerTest.scala35
-rw-r--r--src/partest/scala/tools/partest/DirectTest.scala2
2 files changed, 35 insertions, 2 deletions
diff --git a/src/partest/scala/tools/partest/CompilerTest.scala b/src/partest/scala/tools/partest/CompilerTest.scala
index 1cb09b433a..994928c0f6 100644
--- a/src/partest/scala/tools/partest/CompilerTest.scala
+++ b/src/partest/scala/tools/partest/CompilerTest.scala
@@ -19,9 +19,42 @@ abstract class CompilerTest extends DirectTest {
lazy val global: Global = newCompiler()
lazy val units = compilationUnits(global)(sources: _ *)
+ import global._
+ import definitions._
override def extraSettings = "-usejavacp -d " + testOutput.path
- def sources: List[String] = List(code)
def show() = (sources, units).zipped foreach check
+
+ // Override at least one of these...
+ def code = ""
+ def sources: List[String] = List(code)
+
+ // Utility functions
+
+ class MkType(sym: Symbol) {
+ def apply[M](implicit m1: Manifest[M]): Type =
+ if (sym eq NoSymbol) NoType
+ else appliedType(sym.typeConstructor, List(m1) map (x => manifestToType(x)))
+ }
+ implicit def mkMkType(sym: Symbol) = new MkType(sym)
+
+ def allMembers(root: Symbol): List[Symbol] = {
+ def loop(seen: Set[Symbol], roots: List[Symbol]): List[Symbol] = {
+ val latest = roots flatMap (_.info.members) filterNot (seen contains _)
+ if (latest.isEmpty) seen.toList.sortWith(_ isLess _)
+ else loop(seen ++ latest, latest)
+ }
+ loop(Set(), List(root))
+ }
+
+ class SymsInPackage(pkgName: String) {
+ def pkg = getRequiredModule(pkgName)
+ def classes = allMembers(pkg) filter (_.isClass)
+ def modules = allMembers(pkg) filter (_.isModule)
+ def symbols = classes ++ terms filterNot (_ eq NoSymbol)
+ def terms = allMembers(pkg) filter (s => s.isTerm && !s.isConstructor)
+ def tparams = classes flatMap (_.info.typeParams)
+ def tpes = symbols map (_.tpe) distinct
+ }
}
diff --git a/src/partest/scala/tools/partest/DirectTest.scala b/src/partest/scala/tools/partest/DirectTest.scala
index 07444f8d4b..4e7f36bdc9 100644
--- a/src/partest/scala/tools/partest/DirectTest.scala
+++ b/src/partest/scala/tools/partest/DirectTest.scala
@@ -69,7 +69,7 @@ abstract class DirectTest extends App {
/** Constructor/main body **/
try show()
- catch { case t => println(t) ; sys.exit(1) }
+ catch { case t => println(t) ; t.printStackTrace ; sys.exit(1) }
/** Debugger interest only below this line **/
protected def isDebug = (sys.props contains "partest.debug") || (sys.env contains "PARTEST_DEBUG")