From a0ea242f75c83717bc8019d1be7865a52fd6186f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 5 May 2011 23:46:31 +0000 Subject: Be silent when compiling the repl extraction ob... Be silent when compiling the repl extraction object to suppress spurious warnings. Also corrected the busted logic for spotting repl wrappers. Closes #4542, no review. --- src/partest/scala/tools/partest/ReplTest.scala | 47 ++++-------------------- src/partest/scala/tools/partest/SigTest.scala | 51 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 src/partest/scala/tools/partest/SigTest.scala (limited to 'src/partest') diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala index b31c43ba6f..dd21e7906a 100644 --- a/src/partest/scala/tools/partest/ReplTest.scala +++ b/src/partest/scala/tools/partest/ReplTest.scala @@ -14,48 +14,15 @@ import java.lang.reflect.{ Method => JMethod, Field => JField } */ abstract class ReplTest extends App { def code: String - def settings: Settings = new Settings // override for custom settings + // override to add additional settings + def extraSettings: String = "" + def settings: Settings = { + val s = new Settings + s processArgumentString extraSettings + s + } def eval() = ILoop.runForTranscript(code, settings).lines drop 1 def show() = eval() foreach println show() } - -trait SigTest { - def mstr(m: JMethod) = " (m) %s%s".format( - m.toGenericString, - if (m.isBridge) " (bridge)" else "" - ) - def fstr(f: JField) = " (f) %s".format(f.toGenericString) - - def isObjectMethodName(name: String) = classOf[Object].getMethods exists (_.getName == name) - - def fields[T: ClassManifest](p: JField => Boolean) = { - val cl = classManifest[T].erasure - val fs = (cl.getFields ++ cl.getDeclaredFields).distinct sortBy (_.getName) - - fs filter p - } - def methods[T: ClassManifest](p: JMethod => Boolean) = { - val cl = classManifest[T].erasure - val ms = (cl.getMethods ++ cl.getDeclaredMethods).distinct sortBy (x => (x.getName, x.isBridge)) - - ms filter p - } - def allFields[T: ClassManifest]() = fields[T](_ => true) - def allMethods[T: ClassManifest]() = methods[T](m => !isObjectMethodName(m.getName)) - def fieldsNamed[T: ClassManifest](name: String) = fields[T](_.getName == name) - def methodsNamed[T: ClassManifest](name: String) = methods[T](_.getName == name) - - def allGenericStrings[T: ClassManifest]() = - (allMethods[T]() map mstr) ++ (allFields[T]() map fstr) - - def genericStrings[T: ClassManifest](name: String) = - (methodsNamed[T](name) map mstr) ++ (fieldsNamed[T](name) map fstr) - - def show[T: ClassManifest](name: String = "") = { - println(classManifest[T].erasure.getName) - if (name == "") allGenericStrings[T]() foreach println - else genericStrings[T](name) foreach println - } -} diff --git a/src/partest/scala/tools/partest/SigTest.scala b/src/partest/scala/tools/partest/SigTest.scala new file mode 100644 index 0000000000..072ec006f9 --- /dev/null +++ b/src/partest/scala/tools/partest/SigTest.scala @@ -0,0 +1,51 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2011 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.partest + +import scala.tools.nsc.Settings +import scala.tools.nsc.interpreter.ILoop +import java.lang.reflect.{ Method => JMethod, Field => JField } + +/** Support code for testing signatures. + */ +trait SigTest { + def mstr(m: JMethod) = " (m) %s%s".format( + m.toGenericString, + if (m.isBridge) " (bridge)" else "" + ) + def fstr(f: JField) = " (f) %s".format(f.toGenericString) + + def isObjectMethodName(name: String) = classOf[Object].getMethods exists (_.getName == name) + + def fields[T: ClassManifest](p: JField => Boolean) = { + val cl = classManifest[T].erasure + val fs = (cl.getFields ++ cl.getDeclaredFields).distinct sortBy (_.getName) + + fs filter p + } + def methods[T: ClassManifest](p: JMethod => Boolean) = { + val cl = classManifest[T].erasure + val ms = (cl.getMethods ++ cl.getDeclaredMethods).distinct sortBy (x => (x.getName, x.isBridge)) + + ms filter p + } + def allFields[T: ClassManifest]() = fields[T](_ => true) + def allMethods[T: ClassManifest]() = methods[T](m => !isObjectMethodName(m.getName)) + def fieldsNamed[T: ClassManifest](name: String) = fields[T](_.getName == name) + def methodsNamed[T: ClassManifest](name: String) = methods[T](_.getName == name) + + def allGenericStrings[T: ClassManifest]() = + (allMethods[T]() map mstr) ++ (allFields[T]() map fstr) + + def genericStrings[T: ClassManifest](name: String) = + (methodsNamed[T](name) map mstr) ++ (fieldsNamed[T](name) map fstr) + + def show[T: ClassManifest](name: String = "") = { + println(classManifest[T].erasure.getName) + if (name == "") allGenericStrings[T]() foreach println + else genericStrings[T](name) foreach println + } +} -- cgit v1.2.3