From c6ca941ccc017a8869f4def717cfeb640f965077 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 6 Mar 2013 07:39:19 -0800 Subject: Moved scaladoc sources into separate directory. This change is not externally visible. It moves the scaladoc sources into src/scaladoc and adds an ant target for building them. The compilation products are still packaged into scala-compiler.jar as before, but with a small change to build.xml a separate jar can be created instead. --- test/scaladoc/run/t5527.check | 99 +++++++++++++++++++++++ test/scaladoc/run/t5527.scala | 107 +++++++++++++++++++++++++ test/scaladoc/scalacheck/IndexScriptTest.scala | 2 +- test/scaladoc/scalacheck/IndexTest.scala | 6 +- 4 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 test/scaladoc/run/t5527.check create mode 100644 test/scaladoc/run/t5527.scala (limited to 'test/scaladoc') diff --git a/test/scaladoc/run/t5527.check b/test/scaladoc/run/t5527.check new file mode 100644 index 0000000000..1518168c51 --- /dev/null +++ b/test/scaladoc/run/t5527.check @@ -0,0 +1,99 @@ +[[syntax trees at end of parser]] // newSource1 +package { + object UselessComments extends scala.AnyRef { + def () = { + super.(); + () + }; + var z = 0; + def test1 = { + object Maybe extends scala.AnyRef { + def () = { + super.(); + () + }; + /** Some comment inside */ + def nothing() = () + }; + () + }; + def test2 = { + var x = 4; + if (true) + { + x = 5; + val y = 6; + () + } + else + () + }; + def test3 = { + if (true) + z = 3 + else + (); + val t = 4; + 0.to(4).foreach(((i) => println(i))) + }; + val test4 = 'a' match { + case ('0'| '1'| '2'| '3'| '4'| '5'| '6'| '7'| '8'| '9') => true + case _ => false + } + }; + /** comments that we should keep */ + object UsefulComments extends scala.AnyRef { + def () = { + super.(); + () + }; + /** class A */ + class A extends scala.AnyRef { + def () = { + super.(); + () + }; + /** f */ + def f(i: Int) = i; + /** v */ + val v = 1; + /** u */ + var u = 2 + }; + /** trait B */ + abstract trait B extends scala.AnyRef { + def $init$() = { + () + }; + /** T */ + type T >: _root_.scala.Nothing <: _root_.scala.Any; + /** f */ + def f(i: Int): scala.Unit; + /** v */ + val v = 1; + /** u */ + var u = 2 + }; + /** object C */ + object C extends scala.AnyRef { + def () = { + super.(); + () + }; + /** f */ + def f(i: Int) = i; + /** v */ + val v = 1; + /** u */ + var u = 2 + }; + /** class D */ + @new deprecated("use ... instead", "2.10.0") class D extends scala.AnyRef { + def () = { + super.(); + () + } + } + } +} + diff --git a/test/scaladoc/run/t5527.scala b/test/scaladoc/run/t5527.scala new file mode 100644 index 0000000000..2449ff60c3 --- /dev/null +++ b/test/scaladoc/run/t5527.scala @@ -0,0 +1,107 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.doc.{Settings, DocFactory} +import scala.tools.nsc.reporters.ConsoleReporter + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:parser -Yrangepos -Ystop-after:parser -d " + testOutput.path + + override def code = """ + // SI-5527 + object UselessComments { + + var z = 0 + + def test1 = { + /** Some comment here */ + object Maybe { + /** Some comment inside */ + def nothing() = () + } + } + + def test2 = { + var x = 4 + if (true) { + /** Testing 123 */ + x = 5 + val y = 6 + } + } + + def test3 = { + if (true) + z = 3 + + /** Calculate this result. */ + val t = 4 + for (i <- 0 to 4) + println(i) + } + + val test4 = ('a') match { + /** Another digit is a giveaway. */ + case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => + true + case _ => + false + } + } + + /** comments that we should keep */ + object UsefulComments { + /** class A */ + class A { + /** f */ + def f(i: Int) = i + /** v */ + val v = 1 + /** u */ + var u = 2 + } + /** trait B */ + trait B { + /** T */ + type T + /** f */ + def f(i: Int) + /** v */ + val v = 1 + /** u */ + var u = 2 + } + /** object C */ + object C { + /** f */ + def f(i: Int) = i + /** v */ + val v = 1 + /** u */ + var u = 2 + } + /** class D */ + @deprecated("use ... instead", "2.10.0") + class D + } + """.trim + + override def show(): Unit = { + // redirect err to out, for logging + val prevErr = System.err + System.setErr(System.out) + compile() + System.setErr(prevErr) + } + + override def newCompiler(args: String*): Global = { + // we want the Scaladoc compiler here, because it keeps DocDef nodes in the tree + val settings = new Settings(_ => ()) + val command = new ScalaDoc.Command((CommandLineParser tokenize extraSettings) ++ args.toList, settings) + new DocFactory(new ConsoleReporter(settings), settings).compiler + } + + override def isDebug = false // so we don't get the newSettings warning +} diff --git a/test/scaladoc/scalacheck/IndexScriptTest.scala b/test/scaladoc/scalacheck/IndexScriptTest.scala index 5aef38e00a..37f6947aaa 100644 --- a/test/scaladoc/scalacheck/IndexScriptTest.scala +++ b/test/scaladoc/scalacheck/IndexScriptTest.scala @@ -35,7 +35,7 @@ object Test extends Properties("IndexScript") { } property("allPackages") = { - createIndexScript("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndexScript("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => index.allPackages.map(_.toString) == List( "scala", diff --git a/test/scaladoc/scalacheck/IndexTest.scala b/test/scaladoc/scalacheck/IndexTest.scala index bf385898fc..dc4ab126d4 100644 --- a/test/scaladoc/scalacheck/IndexTest.scala +++ b/test/scaladoc/scalacheck/IndexTest.scala @@ -56,7 +56,7 @@ object Test extends Properties("Index") { } property("path") = { - createIndex("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => index.path == List("index.html") case None => false @@ -64,7 +64,7 @@ object Test extends Properties("Index") { } property("title") = { - createIndex("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => index.title == "" @@ -72,7 +72,7 @@ object Test extends Properties("Index") { } } property("browser contants a script element") = { - createIndex("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => (index.browser \ "script").size == 1 -- cgit v1.2.3