summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-08 14:25:01 +0000
committerPaul Phillips <paulp@improving.org>2010-11-08 14:25:01 +0000
commit948f4228c1a279f49093dbc7dc042eea749c463d (patch)
tree851295427a1ce42d810005a2c945a76c345d7046 /test
parent7f8ccd778d34016e6fb63b218524783da3916573 (diff)
downloadscala-948f4228c1a279f49093dbc7dc042eea749c463d.tar.gz
scala-948f4228c1a279f49093dbc7dc042eea749c463d.tar.bz2
scala-948f4228c1a279f49093dbc7dc042eea749c463d.zip
A bit of -Xshow-class / -Xshow-object which did...
A bit of -Xshow-class / -Xshow-object which didn't quite make the Global patch. Now type selections should do the right thing, e.g. scalac -Xshow-class Global#Run src/compiler/scala/tools/nsc/Global.scala will show you interesting things about Run. Or see the test case for even more thrills. No review.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/global-showdef.check14
-rw-r--r--test/files/run/global-showdef.scala69
2 files changed, 83 insertions, 0 deletions
diff --git a/test/files/run/global-showdef.check b/test/files/run/global-showdef.check
new file mode 100644
index 0000000000..8f67253ced
--- /dev/null
+++ b/test/files/run/global-showdef.check
@@ -0,0 +1,14 @@
+<<-- class foo.bar.Bippy -->>
+ def showdefTestMemberClass1: Int
+<<-- type foo.bar.Bippy.BippyType -->>
+ def showdefTestMemberType1: Unit
+<<-- type foo.bar.Bippy.BippyType -->>
+ def showdefTestMemberType2: Unit
+<<-- class foo.bar.Bippy.Boppity -->>
+ def showdefTestMemberClass2: Int
+<<-- class foo.bar.Bippy.Boppity.Boo -->>
+ def showdefTestMemberClass3: Int
+<<-- object foo.bar.Bippy -->>
+ def showdefTestMemberObject2: java.lang.String
+<<-- object foo.bar.Bippy.Boppity.Boo -->>
+ def showdefTestMemberObject1: java.lang.String
diff --git a/test/files/run/global-showdef.scala b/test/files/run/global-showdef.scala
new file mode 100644
index 0000000000..0b34fc4548
--- /dev/null
+++ b/test/files/run/global-showdef.scala
@@ -0,0 +1,69 @@
+import scala.tools.nsc._
+import io.{ AbstractFile }
+import util.{ SourceFile, BatchSourceFile, stringFromStream }
+import scala.tools.nsc.reporters.ConsoleReporter
+
+object Test {
+ val src: SourceFile = new BatchSourceFile("src", """
+package foo.bar
+
+class Bippy {
+ type BippyType <: {
+ def showdefTestMemberType1: Unit
+ }
+
+ def showdefTestMemberClass1 = 5
+ class Boppity {
+ def showdefTestMemberClass2 = 5
+ class Boo {
+ def showdefTestMemberClass3 = 5
+ }
+ object Boo {
+ def showdefTestMemberObject1 = "abc"
+ }
+ }
+}
+
+object Bippy {
+ type BippyType <: {
+ def showdefTestMemberType2: Unit
+ }
+
+ def showdefTestMemberObject2 = "abc"
+}
+ """)
+
+ def mkCompiler(args: String*) = {
+ val settings = new Settings()
+ val command = new CompilerCommand("-usejavacp" :: args.toList, settings)
+
+ new Global(settings)
+ }
+
+ def slurp(body: => Unit): String = stringFromStream { stream =>
+ Console.withOut(stream) {
+ Console.withErr(stream) {
+ body
+ }
+ }
+ }
+ def lines(args: String*): List[String] = {
+ val output = slurp {
+ val compiler = mkCompiler(args: _*)
+ val run = new compiler.Run()
+ run.compileSources(List(src))
+ }
+ output split "\\n" toList
+ }
+ def showClass(name: String) = lines("-Xshow-class", name)
+ def showObject(name: String) = lines("-Xshow-object", name)
+
+ def show(xs: List[String]) = {
+ xs filter (x => (x contains "def showdefTestMember") || (x startsWith "<<-- ")) foreach println
+ }
+
+ def main(args: Array[String]) {
+ show(List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo") flatMap showClass)
+ show(List("Bippy", "Bippy#Boppity#Boo") flatMap showObject)
+ }
+}