summaryrefslogtreecommitdiff
path: root/test/scaladoc/scalacheck/IndexScriptTest.scala
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-03-27 10:35:40 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2012-03-27 10:35:40 +0200
commit5632167f6cacec16d82b1961d233d7e761cf6036 (patch)
tree13cf3cdd1b8e41ddaa7c0a22d805dbbc6cfa7bb7 /test/scaladoc/scalacheck/IndexScriptTest.scala
parenta532ba0600444b3564b6b015688ebc4cdf084ba6 (diff)
downloadscala-5632167f6cacec16d82b1961d233d7e761cf6036.tar.gz
scala-5632167f6cacec16d82b1961d233d7e761cf6036.tar.bz2
scala-5632167f6cacec16d82b1961d233d7e761cf6036.zip
Fixes SI-5373
And adds basic support for scaladoc model tests (class partest.ScaladocModelTest)
Diffstat (limited to 'test/scaladoc/scalacheck/IndexScriptTest.scala')
-rw-r--r--test/scaladoc/scalacheck/IndexScriptTest.scala52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/scaladoc/scalacheck/IndexScriptTest.scala b/test/scaladoc/scalacheck/IndexScriptTest.scala
new file mode 100644
index 0000000000..5aef38e00a
--- /dev/null
+++ b/test/scaladoc/scalacheck/IndexScriptTest.scala
@@ -0,0 +1,52 @@
+import org.scalacheck._
+import org.scalacheck.Prop._
+
+import scala.tools.nsc.doc
+import scala.tools.nsc.doc.html.page.IndexScript
+import java.net.{URLClassLoader, URLDecoder}
+
+object Test extends Properties("IndexScript") {
+
+ def getClasspath = {
+ val loader = Thread.currentThread.getContextClassLoader
+ val paths = loader.asInstanceOf[URLClassLoader].getURLs
+ val morepaths = loader.getParent.asInstanceOf[URLClassLoader].getURLs
+ (paths ++ morepaths).map(u => URLDecoder.decode(u.getPath)).mkString(java.io.File.pathSeparator)
+ }
+
+ val docFactory = {
+ val settings = new doc.Settings({Console.err.println(_)})
+ settings.classpath.value = getClasspath
+ val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings)
+ new doc.DocFactory(reporter, settings)
+ }
+
+ val indexModelFactory = doc.model.IndexModelFactory
+
+ def createIndexScript(path: String) =
+ docFactory.makeUniverse(Left(List(path))) match {
+ case Some(universe) => {
+ val index = new IndexScript(universe,
+ indexModelFactory.makeIndex(universe))
+ Some(index)
+ }
+ case _ =>
+ None
+ }
+
+ property("allPackages") = {
+ createIndexScript("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match {
+ case Some(index) =>
+ index.allPackages.map(_.toString) == List(
+ "scala",
+ "scala.tools",
+ "scala.tools.nsc",
+ "scala.tools.nsc.doc",
+ "scala.tools.nsc.doc.html",
+ "scala.tools.nsc.doc.html.page"
+ )
+ case None =>
+ false
+ }
+ }
+}