diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-10-20 18:06:29 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-10-20 18:06:29 -0700 |
commit | 1899c91b149c6508c1d527fcbdbc9310f627c21f (patch) | |
tree | 340c2542a9909d1021a0569415209958098b605b /test/scaladoc/run | |
parent | 9dbb0675352a36965c556b678bec2b1ffc3d2e45 (diff) | |
parent | d22b74c22fef4151533bf23efcc6b4f59e60d88f (diff) | |
download | scala-1899c91b149c6508c1d527fcbdbc9310f627c21f.tar.gz scala-1899c91b149c6508c1d527fcbdbc9310f627c21f.tar.bz2 scala-1899c91b149c6508c1d527fcbdbc9310f627c21f.zip |
Merge pull request #1479 from vigdorchik/2.10.x
Scaladoc knows the package structure of the libraries,
Diffstat (limited to 'test/scaladoc/run')
-rwxr-xr-x | test/scaladoc/run/SI-191-deprecated.check | 1 | ||||
-rwxr-xr-x | test/scaladoc/run/SI-191-deprecated.scala | 71 | ||||
-rwxr-xr-x | test/scaladoc/run/SI-191.check | 1 | ||||
-rwxr-xr-x | test/scaladoc/run/SI-191.scala | 76 |
4 files changed, 149 insertions, 0 deletions
diff --git a/test/scaladoc/run/SI-191-deprecated.check b/test/scaladoc/run/SI-191-deprecated.check new file mode 100755 index 0000000000..3925a0d464 --- /dev/null +++ b/test/scaladoc/run/SI-191-deprecated.check @@ -0,0 +1 @@ +Done.
\ No newline at end of file diff --git a/test/scaladoc/run/SI-191-deprecated.scala b/test/scaladoc/run/SI-191-deprecated.scala new file mode 100755 index 0000000000..746aa9c598 --- /dev/null +++ b/test/scaladoc/run/SI-191-deprecated.scala @@ -0,0 +1,71 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.nsc.doc.model.comment._ +import scala.tools.partest.ScaladocModelTest +import java.net.{URI, URL} +import java.io.File + +object Test extends ScaladocModelTest { + + override def code = + """ + /** See: + * - [[scala.collection.Map]] Simple linking + * - [[scala.collection.immutable.::]] Linking with symbolic name + * - [[scala.Int]].toLong Linking to a class + * - [[scala.Predef]] Linking to an object + * - [[scala.Int.toLong]] Linking to a method + * - [[scala]] Linking to a package + * - [[scala.AbstractMethodError]] Linking to a member in the package object + * - [[scala.Predef.String]] Linking to a member in an object + * + * Don't look at: + * - [[scala.NoLink]] Not linking :) + */ + object Test { + def foo(param: Any) {} + def barr(l: scala.collection.immutable.List[Any]) {} + def bar(l: List[String]) {} // TODO: Should be able to link to type aliases + def baz(d: java.util.Date) {} // Should not be resolved + } + """ + + def scalaURL = "http://bog.us" + + override def scaladocSettings = "-no-link-warnings -external-urls scala=" + scalaURL + + def testModel(rootPackage: Package) { + import access._ + val test = rootPackage._object("Test") + + def check(memberDef: Def, expected: Int) { + val externals = memberDef.valueParams(0)(0).resultType.refEntity collect { + case (_, (LinkToExternal(name, url), _)) => assert(url.contains(scalaURL)); name + } + assert(externals.size == expected) + } + + check(test._method("foo"), 1) + check(test._method("bar"), 0) + check(test._method("barr"), 2) + check(test._method("baz"), 0) + + val expectedUrls = collection.mutable.Set[String]( + "scala.collection.Map", + "scala.collection.immutable.::", + "scala.Int", + "scala.Predef$", + "scala.Int@toLong:Long", + "scala.package", + "scala.package@AbstractMethodError=AbstractMethodError", + "scala.Predef$@String=String" + ).map(scalaURL + "/index.html#" + _) + + def isExpectedExternalLink(l: EntityLink) = l.link match { + case LinkToExternal(name, url) => assert(expectedUrls contains url, url); true + case _ => false + } + + assert(countLinks(test.comment.get, isExpectedExternalLink) == 8, + countLinks(test.comment.get, isExpectedExternalLink) + " == 8") + } +} diff --git a/test/scaladoc/run/SI-191.check b/test/scaladoc/run/SI-191.check new file mode 100755 index 0000000000..3925a0d464 --- /dev/null +++ b/test/scaladoc/run/SI-191.check @@ -0,0 +1 @@ +Done.
\ No newline at end of file diff --git a/test/scaladoc/run/SI-191.scala b/test/scaladoc/run/SI-191.scala new file mode 100755 index 0000000000..0fb28145c3 --- /dev/null +++ b/test/scaladoc/run/SI-191.scala @@ -0,0 +1,76 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.nsc.doc.model.comment._ +import scala.tools.partest.ScaladocModelTest +import java.net.{URI, URL} +import java.io.File + +object Test extends ScaladocModelTest { + + override def code = + """ + /** See: + * - [[scala.collection.Map]] Simple linking + * - [[scala.collection.immutable.::]] Linking with symbolic name + * - [[scala.Int]].toLong Linking to a class + * - [[scala.Predef]] Linking to an object + * - [[scala.Int.toLong]] Linking to a method + * - [[scala]] Linking to a package + * - [[scala.AbstractMethodError]] Linking to a member in the package object + * - [[scala.Predef.String]] Linking to a member in an object + * + * Don't look at: + * - [[scala.NoLink]] Not linking :) + */ + object Test { + def foo(param: Any) {} + def barr(l: scala.collection.immutable.List[Any]) {} + def bar(l: List[String]) {} // TODO: Should be able to link to type aliases + def baz(d: java.util.Date) {} // Should not be resolved + } + """ + + def scalaURL = "http://bog.us" + + override def scaladocSettings = { + val scalaLibUri = getClass.getClassLoader.getResource("scala/Function1.class").toURI.getSchemeSpecificPart.split("!")(0) + val scalaLib = new File(new URL(scalaLibUri).getPath).getPath + val extArg = new URI("file", scalaLib, scalaURL).toString + "-no-link-warnings -doc-external-uris " + extArg + } + + def testModel(rootPackage: Package) { + import access._ + val test = rootPackage._object("Test") + + def check(memberDef: Def, expected: Int) { + val externals = memberDef.valueParams(0)(0).resultType.refEntity collect { + case (_, (LinkToExternal(name, url), _)) => assert(url.contains(scalaURL)); name + } + assert(externals.size == expected) + } + + check(test._method("foo"), 1) + check(test._method("bar"), 0) + check(test._method("barr"), 2) + check(test._method("baz"), 0) + + val expectedUrls = collection.mutable.Set[String]( + "scala.collection.Map", + "scala.collection.immutable.::", + "scala.Int", + "scala.Predef$", + "scala.Int@toLong:Long", + "scala.package", + "scala.package@AbstractMethodError=AbstractMethodError", + "scala.Predef$@String=String" + ).map(scalaURL + "/index.html#" + _) + + def isExpectedExternalLink(l: EntityLink) = l.link match { + case LinkToExternal(name, url) => assert(expectedUrls contains url, url); true + case _ => false + } + + assert(countLinks(test.comment.get, isExpectedExternalLink) == 8, + countLinks(test.comment.get, isExpectedExternalLink) + " == 8") + } +} |