Skip to content

Commit

Permalink
Drop duplicate CompilerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Mar 20, 2020
1 parent 8870d38 commit 3ae592d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 95 deletions.
50 changes: 2 additions & 48 deletions test/files/run/compiler-asSeenFrom.scala
@@ -1,56 +1,10 @@
/*
* filter: inliner warning; re-run with
*/
import scala.language.postfixOps
import scala.tools.nsc._
import scala.tools.partest.DirectTest
import scala.tools.partest.CompilerTest
import scala.collection.{ mutable, immutable, generic }
import scala.language.{postfixOps, implicitConversions}
import scala.reflect.runtime.{universe => ru}

// necessary to avoid bincompat with scala-partest compiled against the old compiler
abstract class CompilerTest extends DirectTest {
def check(source: String, unit: global.CompilationUnit): Unit

lazy val global: Global = newCompiler()
lazy val units: List[global.CompilationUnit] = compilationUnits(global)(sources: _ *)
import global._
import definitions.{ compilerTypeFromTag }

override def extraSettings = "-feature -usejavacp -d " + testOutput.path

def show() = sources.lazyZip(units) 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 t: ru.TypeTag[M]): Type =
if (sym eq NoSymbol) NoType
else appliedType(sym, compilerTypeFromTag(t))
}
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 = rootMirror.getPackage(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
}
}

/** It's too messy but it's better than not having it.
*/
Expand Down
47 changes: 0 additions & 47 deletions test/files/run/t7096.scala
Expand Up @@ -3,53 +3,6 @@
*/
import scala.tools.partest._
import scala.tools.nsc._
import scala.reflect.runtime.{universe => ru}
import scala.language.implicitConversions

// necessary to avoid bincompat with scala-partest compiled against the old compiler
abstract class CompilerTest extends DirectTest {
def check(source: String, unit: global.CompilationUnit): Unit

lazy val global: Global = newCompiler()
lazy val units: List[global.CompilationUnit] = compilationUnits(global)(sources: _ *)
import global._
import definitions.{ compilerTypeFromTag }

override def extraSettings = "-usejavacp -d " + testOutput.path

def show() = sources.lazyZip(units) 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 t: ru.TypeTag[M]): Type =
if (sym eq NoSymbol) NoType
else appliedType(sym, compilerTypeFromTag(t))
}
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 = rootMirror.getPackage(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
}
}

object Test extends CompilerTest {
import global._
Expand Down

0 comments on commit 3ae592d

Please sign in to comment.