diff options
Diffstat (limited to 'test/scaladoc/run')
23 files changed, 367 insertions, 33 deletions
diff --git a/test/scaladoc/run/SI-6017.check b/test/scaladoc/run/SI-10027.check index 619c56180b..619c56180b 100644 --- a/test/scaladoc/run/SI-6017.check +++ b/test/scaladoc/run/SI-10027.check diff --git a/test/scaladoc/run/SI-10027.scala b/test/scaladoc/run/SI-10027.scala new file mode 100644 index 0000000000..d720d8371c --- /dev/null +++ b/test/scaladoc/run/SI-10027.scala @@ -0,0 +1,12 @@ +import scala.tools.nsc.doc.Universe +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocJavaModelTest + +object Test extends ScaladocJavaModelTest { + + override def resourceFile = "SI-10027.java" + override def scaladocSettings = "" + + // just make sure it compiles + def testModel(rootPackage: Package) = {} +} diff --git a/test/scaladoc/run/SI-4826-no-comments.check b/test/scaladoc/run/SI-4826-no-comments.check new file mode 100644 index 0000000000..3925a0d464 --- /dev/null +++ b/test/scaladoc/run/SI-4826-no-comments.check @@ -0,0 +1 @@ +Done.
\ No newline at end of file diff --git a/test/scaladoc/run/SI-4826-no-comments.scala b/test/scaladoc/run/SI-4826-no-comments.scala new file mode 100644 index 0000000000..217fc29d81 --- /dev/null +++ b/test/scaladoc/run/SI-4826-no-comments.scala @@ -0,0 +1,20 @@ +import scala.tools.nsc.doc.Universe +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocJavaModelTest + +object Test extends ScaladocJavaModelTest { + + override def resourceFile = "SI-4826.java" + override def scaladocSettings = "-no-java-comments" + + def testModel(rootPackage: Package) = { + import access._ + + val base = rootPackage._package("test")._package("scaladoc") + val clazz = base._class("JavaComments") + val method = clazz._method("answer") + + assert(clazz.comment == None) + assert(method.comment == None) + } +} diff --git a/test/scaladoc/run/SI-4826.check b/test/scaladoc/run/SI-4826.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-4826.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-4826.scala b/test/scaladoc/run/SI-4826.scala new file mode 100644 index 0000000000..6d4b3a6da7 --- /dev/null +++ b/test/scaladoc/run/SI-4826.scala @@ -0,0 +1,21 @@ +import scala.tools.nsc.doc.Universe +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocJavaModelTest + +object Test extends ScaladocJavaModelTest { + + override def resourceFile = "SI-4826.java" + override def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + val Tag = ":marker:" + + val base = rootPackage._package("test")._package("scaladoc") + val clazz = base._class("JavaComments") + val method = clazz._method("answer") + + assert(extractCommentText(clazz.comment.get).contains(Tag)) + assert(extractCommentText(method.comment.get).contains(Tag)) + } +} diff --git a/test/scaladoc/run/SI-6017.scala b/test/scaladoc/run/SI-6017.scala deleted file mode 100644 index 9951534c6d..0000000000 --- a/test/scaladoc/run/SI-6017.scala +++ /dev/null @@ -1,28 +0,0 @@ -import scala.tools.nsc.doc -import scala.tools.nsc.doc.model._ -import scala.tools.nsc.doc.html.page.{Index, ReferenceIndex} -import scala.tools.partest.ScaladocModelTest - -object Test extends ScaladocModelTest { - override def scaladocSettings = "" - override def code = """ - class STAR - class Star - """ - - def testModel(rootPackage: Package) { - model match { - case Some(universe) => { - val index = IndexModelFactory.makeIndex(universe) - // Because "STAR" and "Star" are different - assert(index.firstLetterIndex('s').keys.toSeq.length == 2) - - val indexPage = new Index(universe, index) - val letters = indexPage.letters - assert(letters.length > 1) - assert(letters(0).toString == "<span>#</span>") - } - case _ => assert(false) - } - } -} diff --git a/test/scaladoc/run/SI-6580.scala b/test/scaladoc/run/SI-6580.scala index c544138f44..55168a060b 100644 --- a/test/scaladoc/run/SI-6580.scala +++ b/test/scaladoc/run/SI-6580.scala @@ -1,6 +1,5 @@ import scala.tools.nsc.doc import scala.tools.nsc.doc.model._ -import scala.tools.nsc.doc.html.page.{Index, ReferenceIndex} import scala.tools.partest.ScaladocModelTest object Test extends ScaladocModelTest { diff --git a/test/scaladoc/run/SI-9620.check b/test/scaladoc/run/SI-9620.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-9620.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-9620.scala b/test/scaladoc/run/SI-9620.scala new file mode 100644 index 0000000000..cac34d1c18 --- /dev/null +++ b/test/scaladoc/run/SI-9620.scala @@ -0,0 +1,42 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + package a + + trait Foo[S] { + def foo(t: S): Int = 123 + } + + /** Boo with only one foo method, hopefully! + * @hideImplicitConversion BooShouldNotAppearIsFoo + */ + trait Boo[T] + + object Boo { + sealed trait ShouldNotAppear + implicit class BooShouldNotAppearIsFoo(boo: Boo[ShouldNotAppear]) extends Foo[ShouldNotAppear] + implicit class BooLongIsFoo(boo: Boo[Long]) extends Foo[Long] + } + """ + + def scaladocSettings = "-implicits" + + def testModel(rootPackage: Package) = { + import access._ + + // Assert Boo only has one implicit conversion + val boo = rootPackage._package("a")._trait("Boo") + val conversions = boo._conversions("a.Boo.BooShouldNotAppearIsFoo") ++ boo._conversions("a.Boo.BooLongIsFoo") + assert(conversions.length == 1, conversions.length + " == 1") + + // Assert that the implicit conversion is not "BooShouldNotAppearIsFoo" + assert(conversions.head.conversionShortName == "BooLongIsFoo", + conversions.head.conversionShortName + " == BooLongIsFoo") + + // Assert that the same for full path + assert(conversions.head.conversionQualifiedName == "a.Boo.BooLongIsFoo", + conversions.head.conversionQualifiedName + " == a.Boo.BooLongIsFoo") + } +} diff --git a/test/scaladoc/run/SI-9704.check b/test/scaladoc/run/SI-9704.check new file mode 100644 index 0000000000..5a73befd9b --- /dev/null +++ b/test/scaladoc/run/SI-9704.check @@ -0,0 +1,4 @@ +Chain(List(Chain(List(Text(Demonstrates a scala issue in which the closing link tag is duplicated), Text( +), HtmlTag(<a href="https://link">title</a>), Text( +), Text())))) +Done. diff --git a/test/scaladoc/run/SI-9704.scala b/test/scaladoc/run/SI-9704.scala new file mode 100644 index 0000000000..e6f071704e --- /dev/null +++ b/test/scaladoc/run/SI-9704.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + object Foo { + /** + * Demonstrates a scala issue in which the closing link tag is duplicated + * <a href="https://link">title</a> + */ + def bar = ??? + } + """ + + def scaladocSettings = "" + + def testModel(root: Package) = { + import access._ + val thing = root._object("Foo")._method("bar") + println(thing.comment.get.short) + } +} diff --git a/test/scaladoc/run/inlineToStr-strips-unwanted-text.check b/test/scaladoc/run/inlineToStr-strips-unwanted-text.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/inlineToStr-strips-unwanted-text.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/inlineToStr-strips-unwanted-text.scala b/test/scaladoc/run/inlineToStr-strips-unwanted-text.scala new file mode 100644 index 0000000000..8faaf1b93d --- /dev/null +++ b/test/scaladoc/run/inlineToStr-strips-unwanted-text.scala @@ -0,0 +1,58 @@ +import scala.tools.nsc.doc.html.Page +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + /** This comment contains ^superscript^ */ + class Foo { + /** This comment contains ,,subscript,, */ + def bar = ??? + + /** This comment contains a link [[https://scala.epfl.ch/]] */ + def baz = ??? + + /** This comment contains an <strong>html tag</strong> */ + def qux = ??? + + /** This comment contains a<br> single html tag */ + def quux = ??? + + /** This comment contains nested <strong>html<br> tags</strong> */ + def quuz = ??? + + /** This comment contains a [[corge ,,link with a subscript title,,]] */ + def corge = ??? + } + """ + def scaladocSettings = "" + + def testModel(root: Package) = { + import scala.tools.nsc.doc.base.comment._ + import access._ + + val foo = root._class("Foo") + + val fooStr = Page.inlineToStr(foo.comment.get.short) + assert(fooStr == "This comment contains superscript", fooStr) + + val barStr = Page.inlineToStr(foo._method("bar").comment.get.short) + assert(barStr == "This comment contains subscript", barStr) + + val bazStr = Page.inlineToStr(foo._method("baz").comment.get.short) + assert(bazStr == "This comment contains a link https://scala.epfl.ch/", bazStr) + + val quxStr = Page.inlineToStr(foo._method("qux").comment.get.short) + assert(quxStr == "This comment contains an html tag", quxStr) + + val quuxStr = Page.inlineToStr(foo._method("quux").comment.get.short) + assert(quuxStr == "This comment contains a single html tag", quuxStr) + + val quuzStr = Page.inlineToStr(foo._method("quuz").comment.get.short) + assert(quuzStr == "This comment contains nested html tags", quuzStr) + + val corgeStr = Page.inlineToStr(foo._method("corge").comment.get.short) + assert(corgeStr == "This comment contains a link with a subscript title", corgeStr) + } +} diff --git a/test/scaladoc/run/shortDescription-annotation.check b/test/scaladoc/run/shortDescription-annotation.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/shortDescription-annotation.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/shortDescription-annotation.scala b/test/scaladoc/run/shortDescription-annotation.scala new file mode 100644 index 0000000000..4f9a891133 --- /dev/null +++ b/test/scaladoc/run/shortDescription-annotation.scala @@ -0,0 +1,44 @@ +import scala.tools.nsc.doc.html.Page +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + package a + + /** This comment should not appear + * @shortDescription This one should appear + */ + class Foo { + /** This comment should appear */ + def foo: Int = 1 + + /** This comment should not appear + * @shortDescription This comment should appear + */ + def goo: Int = 2 + } + """ + + // no need for special settings + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import scala.tools.nsc.doc.base.comment._ + import access._ + + val foo = rootPackage._package("a")._class("Foo") + + // Assert that the class has the correct short description + val classDesc = Page.inlineToStr(foo.comment.get.short) + assert(classDesc == "This one should appear", classDesc) + + // Assert that the `foo` method has the correct short description + val fooDesc = Page.inlineToStr(foo._method("foo").comment.get.short) + assert(fooDesc == "This comment should appear", fooDesc) + + // Assert that the `goo` method has the correct short description + val gooDesc = Page.inlineToStr(foo._method("goo").comment.get.short) + assert(gooDesc == "This comment should appear", gooDesc) + } +} diff --git a/test/scaladoc/run/t7767.scala b/test/scaladoc/run/t7767.scala index 6c9ceb511d..433fc5c0c4 100644 --- a/test/scaladoc/run/t7767.scala +++ b/test/scaladoc/run/t7767.scala @@ -4,15 +4,49 @@ import scala.tools.partest.ScaladocModelTest object Test extends ScaladocModelTest { override def code = """ - class Docable extends { /**Doc*/ val foo = 0 } with AnyRef - """ + class CEarly extends { /**CEarly_Doc_foo*/ val foo = 0 } with AnyRef + trait TEarly extends { /**TEarly_Doc_foo*/ val foo = 0 } with AnyRef + class C { + /**C_Doc_sigInferred*/ val sigInferred = 0 + /**C_Doc_const*/ final val const = 0 + /**C_Doc_varr*/ var varr: Any = null + /**C_Doc_abs*/ val abs: Int + /**C_Doc_absVar*/ var absVar: Any + /**C_Doc_lazyValInferred*/ lazy val lazyValInferred = 0 + /**C_Doc_lazyValConst*/ final lazy val lazyValConst = 0 + /**C_Doc_lazyValUnit*/ lazy val lazyValUnit: Unit = println() + /**C_Doc_lazyVal*/ lazy val lazyVal: Int = 0 + } + trait T { + /**T_Doc_sigInferred*/ val sigInferred = 0 + /**T_Doc_const*/ final val const = 0 + /**T_Doc_varr*/ var varr: Any = null + /**T_Doc_abs*/ val abs: Int + /**T_Doc_absVar*/ var absVar: Any + /**T_Doc_lazyValInferred*/ lazy val lazyValInferred = 0 + /**T_Doc_lazyValConst*/ final lazy val lazyValConst = 0 + /**T_Doc_lazyValUnit*/ lazy val lazyValUnit: Unit = println() + /**T_Doc_lazyVal*/ lazy val lazyVal: Int = 0 + }""" // no need for special settings def scaladocSettings = "" + def assertDoc(classEntity: DocTemplateEntity, valName: String) = { + import access._ + val comment = classEntity._value(valName).comment.map(_.body.toString.trim).getOrElse("") + val className = classEntity.name + val marker = s"${className}_Doc_${valName}" + assert(comment.contains(marker), s"Expected $marker in comment for $valName in $className, found: $comment.") + } + def testModel(rootPackage: Package) = { import access._ - val comment = rootPackage._class("Docable")._value("foo").comment.map(_.body.toString.trim).getOrElse("") - assert(comment.contains("Doc"), comment) + assertDoc(rootPackage._class("CEarly"), "foo") + assertDoc(rootPackage._trait("TEarly"), "foo") + + val valNames = List("sigInferred", "const", "varr", "abs", "absVar", "lazyValInferred", "lazyValConst", "lazyValUnit", "lazyVal") + val entities = List(rootPackage._class("C"), rootPackage._trait("T")) + for (e <- entities; vn <- valNames) assertDoc(e, vn) } } diff --git a/test/scaladoc/run/t7905.check b/test/scaladoc/run/t7905.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/t7905.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/t7905.scala b/test/scaladoc/run/t7905.scala new file mode 100644 index 0000000000..8570724470 --- /dev/null +++ b/test/scaladoc/run/t7905.scala @@ -0,0 +1,36 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + object A { + val foo = new B { + val bar = new C { + val baz: A.this.type = A.this + } + } + } + + trait B { + type E = bar.D + + val bar: C + } + + trait C { + trait D + } + + trait G { + type F = A.foo.E + + def m(f: F) = f match { + case _: A.foo.bar.D => // error here + } + } + """ + + def scaladocSettings = "" + + def testModel(root: Package) = () +} diff --git a/test/scaladoc/run/t9585.check b/test/scaladoc/run/t9585.check new file mode 100644 index 0000000000..3784317d54 --- /dev/null +++ b/test/scaladoc/run/t9585.check @@ -0,0 +1,6 @@ +warning: there was one feature warning; re-run with -feature for details +any2stringadd[Box[T]] +StringFormat[Box[T]] +Ensuring[Box[T]] +ArrowAssoc[Box[T]] +Done. diff --git a/test/scaladoc/run/t9585.scala b/test/scaladoc/run/t9585.scala new file mode 100644 index 0000000000..af8350b6cf --- /dev/null +++ b/test/scaladoc/run/t9585.scala @@ -0,0 +1,25 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + object Box { + + implicit def anyToBox[T](t: T): Box[T] = new Box(t) + + } + + class Box[T](val t: T) + """ + + def scaladocSettings = "-implicits" + + def testModel(root: Package) = { + import access._ + + // this used to contain the conversion to Box[Box[T]], + // but not anymore. + val conversions = root._class("Box").conversions + println(conversions.map(_.targetType).mkString("\n")) + } +} diff --git a/test/scaladoc/run/t9752.check b/test/scaladoc/run/t9752.check new file mode 100644 index 0000000000..daeafb8ecc --- /dev/null +++ b/test/scaladoc/run/t9752.check @@ -0,0 +1,5 @@ +List(Body(List(Paragraph(Chain(List(Summary(Text())))), Code(class A + + +class B)))) +Done. diff --git a/test/scaladoc/run/t9752.scala b/test/scaladoc/run/t9752.scala new file mode 100644 index 0000000000..b11c7f5c32 --- /dev/null +++ b/test/scaladoc/run/t9752.scala @@ -0,0 +1,28 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = s""" + /** + * Foo + * + * @example + * {{{ + * class A + * + * + * class B + * }}} + */ + object Foo + """ + + def scaladocSettings = "" + + def testModel(root: Package) = { + import access._ + val obj = root._object("Foo") + println(obj.comment.get.example) + } +} |