From 4da259b26eb9d3409392fef91d36471cd7ac4354 Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Thu, 8 Dec 2011 02:14:21 +0100 Subject: Fixed #5054, #5287 The documents with use cases should be restructured like: /** * The full definition, either used with an implicit value or with an explicit one. * * Some more explanation on implicits... * * @param lost a lost parameter * @return some integer * * @usecase def test(): Int * * This takes the implicit value in scope. * * Example: `test()` * * @usecase def test(explicit: Int): Int * * This takes the explicit value passed. * * Example: `test(3)` */ def test(implicit lost: Int): Int --- test/scaladoc/resources/SI_5054.scala | 10 --- test/scaladoc/resources/SI_5054_q1.scala | 9 +++ test/scaladoc/resources/SI_5054_q2.scala | 9 +++ test/scaladoc/resources/SI_5054_q3.scala | 9 +++ test/scaladoc/resources/SI_5054_q4.scala | 9 +++ test/scaladoc/resources/SI_5054_q5.scala | 9 +++ test/scaladoc/resources/SI_5054_q6.scala | 9 +++ test/scaladoc/resources/SI_5054_q7.scala | 22 ++++++ test/scaladoc/scala/html/HtmlFactoryTest.scala | 101 ++++++++++++++++++++++++- 9 files changed, 173 insertions(+), 14 deletions(-) delete mode 100644 test/scaladoc/resources/SI_5054.scala create mode 100644 test/scaladoc/resources/SI_5054_q1.scala create mode 100644 test/scaladoc/resources/SI_5054_q2.scala create mode 100644 test/scaladoc/resources/SI_5054_q3.scala create mode 100644 test/scaladoc/resources/SI_5054_q4.scala create mode 100644 test/scaladoc/resources/SI_5054_q5.scala create mode 100644 test/scaladoc/resources/SI_5054_q6.scala create mode 100644 test/scaladoc/resources/SI_5054_q7.scala (limited to 'test/scaladoc') diff --git a/test/scaladoc/resources/SI_5054.scala b/test/scaladoc/resources/SI_5054.scala deleted file mode 100644 index 17167303e4..0000000000 --- a/test/scaladoc/resources/SI_5054.scala +++ /dev/null @@ -1,10 +0,0 @@ -class SI_5054 { - - /** - * A simple comment - * - * @param lost a lost parameter - * @usecase def test(): Int - */ - def test(implicit lost: Int): Int = lost -} \ No newline at end of file diff --git a/test/scaladoc/resources/SI_5054_q1.scala b/test/scaladoc/resources/SI_5054_q1.scala new file mode 100644 index 0000000000..02d9be8dd0 --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q1.scala @@ -0,0 +1,9 @@ +class SI_5054_q1 { + /** + * A simple comment + * + * @param lost a lost parameter + * @usecase def test(): Int + */ + def test(implicit lost: Int): Int = lost +} diff --git a/test/scaladoc/resources/SI_5054_q2.scala b/test/scaladoc/resources/SI_5054_q2.scala new file mode 100644 index 0000000000..c873731e5b --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q2.scala @@ -0,0 +1,9 @@ +class SI_5054_q2 { + /** + * A simple comment + * + * @param lost a lost parameter + * @usecase def test(): Int + */ + final def test(implicit lost: Int): Int = lost +} diff --git a/test/scaladoc/resources/SI_5054_q3.scala b/test/scaladoc/resources/SI_5054_q3.scala new file mode 100644 index 0000000000..be5d22ffdc --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q3.scala @@ -0,0 +1,9 @@ +class SI_5054_q3 { + /** + * A simple comment + * + * @param lost a lost parameter + * @usecase def test(): Int + */ + implicit def test(implicit lost: Int): Int = lost +} diff --git a/test/scaladoc/resources/SI_5054_q4.scala b/test/scaladoc/resources/SI_5054_q4.scala new file mode 100644 index 0000000000..4e5e4865f1 --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q4.scala @@ -0,0 +1,9 @@ +abstract class SI_5054_q4 { + /** + * A simple comment + * + * @param lost a lost parameter + * @usecase def test(): Int + */ + def test(implicit lost: Int): Int +} diff --git a/test/scaladoc/resources/SI_5054_q5.scala b/test/scaladoc/resources/SI_5054_q5.scala new file mode 100644 index 0000000000..05ba7488eb --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q5.scala @@ -0,0 +1,9 @@ +trait SI_5054_q5 { + /** + * A simple comment + * + * @param lost a lost parameter + * @usecase def test(): Int + */ + def test(implicit lost: Int): Int = lost +} diff --git a/test/scaladoc/resources/SI_5054_q6.scala b/test/scaladoc/resources/SI_5054_q6.scala new file mode 100644 index 0000000000..607be654a5 --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q6.scala @@ -0,0 +1,9 @@ +trait SI_5054_q6 { + /** + * A simple comment + * + * @param lost a lost parameter + * @usecase def test(): Int + */ + def test(implicit lost: Int): Int +} diff --git a/test/scaladoc/resources/SI_5054_q7.scala b/test/scaladoc/resources/SI_5054_q7.scala new file mode 100644 index 0000000000..26d4b5fcf4 --- /dev/null +++ b/test/scaladoc/resources/SI_5054_q7.scala @@ -0,0 +1,22 @@ +trait SI_5054_q7 { + /** + * The full definition, either used with an implicit value or with an explicit one. + * + * Some more explanation on implicits... + * + * @param lost a lost parameter + * @return some integer + * @usecase def test(): Int + * + * This takes the implicit value in scope. + * + * Example: `test()` + * + * @usecase def test(explicit: Int): Int + * + * This takes the explicit value passed. + * + * Example: `test(3)` + */ + def test(implicit lost: Int): Int +} diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala index c8dad4cf48..d1bfbb023f 100644 --- a/test/scaladoc/scala/html/HtmlFactoryTest.scala +++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala @@ -378,15 +378,108 @@ object Test extends Properties("HtmlFactory") { true } - property("Use cases should override their original members - valid until signature is added to html") = { - createTemplate("SI_5054.scala") match { + // A piece of the signature - corresponding to the use case + def signature(no: Int, modifier: String) = (""" +
  • + +

    + + """ + modifier + """ + def + + + test(): Int + +

    +

    [use case] +

    +
  • """).replaceAll("\\s+", "") + + property("Use cases should override their original members") = { + createTemplate("SI_5054_q1.scala") match { + case node: scala.xml.Node => + node.toString.replaceAll("\\s+","").contains(signature(1, "")) + case _ => false + } + } + + property("Use cases should keep their flags - final should not be lost") = { + createTemplate("SI_5054_q2.scala") match { + case node: scala.xml.Node => + node.toString.replaceAll("\\s+","").contains(signature(2, "final")) + case _ => false + } + } + + property("Use cases should keep their flags - implicit should not be lost") = { + createTemplate("SI_5054_q3.scala") match { + case node: scala.xml.Node => + node.toString.replaceAll("\\s+","").contains(signature(3, "implicit")) + case _ => false + } + } + + property("Use cases should keep their flags - real abstract should not be lost") = { + createTemplate("SI_5054_q4.scala") match { + case node: scala.xml.Node => + node.toString.replaceAll("\\s+","").contains(signature(4, "abstract")) + case _ => false + } + } + + property("Use cases should keep their flags - traits should not be affected") = { + createTemplate("SI_5054_q5.scala") match { case node: scala.xml.Node => - node.toString.contains("A simple comment") && - ! node.toString.contains("a lost parameter") + node.toString.replaceAll("\\s+","").contains(signature(5, "")) case _ => false } } + property("Use cases should keep their flags - traits should not be affected") = { + createTemplate("SI_5054_q6.scala") match { + case node: scala.xml.Node => + node.toString.replaceAll("\\s+","").contains(signature(6, "abstract")) + case _ => false + } + } + + val useCaseExplanation = """ +
  • + +

    + + abstract + def + + + test(): Int + +

    +

    [use case] This takes the implicit value in scope.

    [use case]

    This takes the implicit value in scope.

    Example: test()

    returns

    some integer +

    +
  • + +

    + + abstract + def + + + test(explicit: Int): Int + +

    +

    [use case] This takes the explicit value passed.

    [use case]

    This takes the explicit value passed.

    Example: test(3)

    returns

    some integer +

    +
  • + """.replaceAll("\\s+","") + + property("Use case individual signature test") = { + createTemplate("SI_5054_q7.scala") match { + case node: scala.xml.Node => + node.toString.replaceAll("\\s+","").contains(useCaseExplanation) + case _ => false + } + } { val files = createTemplates("basic.scala") -- cgit v1.2.3