diff options
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/TestAPI.kt | 7 | ||||
-rw-r--r-- | test/src/markdown/ParserTest.kt | 20 | ||||
-rw-r--r-- | test/src/model/CommentTest.kt | 2 | ||||
-rw-r--r-- | test/src/model/FunctionTest.kt | 30 | ||||
-rw-r--r-- | test/src/model/LinkTest.kt | 48 | ||||
-rw-r--r-- | test/src/model/PropertyTest.kt | 4 |
6 files changed, 86 insertions, 25 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index ccef8919..5a4b9863 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -63,6 +63,13 @@ fun StringBuilder.appendNode(node: ContentNode): StringBuilder { append(node.text) } is ContentEmphasis -> append("*").appendChildren(node).append("*") + is ContentNodeLink -> { + append("[") + appendChildren(node) + append(" -> ") + append(node.node.toString()) + append("]") + } else -> { appendChildren(node) } diff --git a/test/src/markdown/ParserTest.kt b/test/src/markdown/ParserTest.kt index 16892f23..80ee7332 100644 --- a/test/src/markdown/ParserTest.kt +++ b/test/src/markdown/ParserTest.kt @@ -5,12 +5,18 @@ import org.jetbrains.dokka import org.jetbrains.dokka.toTestString import org.jetbrains.dokka.toHtml import org.jetbrains.dokka.parseMarkdown +import org.junit.Ignore -public class ParserTest { +Ignore public class ParserTest { fun runTestFor(text : String) { + println("MD: ---") + println(text) val markdownTree = parseMarkdown(text) + println("AST: ---") println(markdownTree.toTestString()) + println("HTML: ---") println(markdownTree.toHtml()) + println() } Test fun text() { @@ -89,20 +95,20 @@ number two } Test fun emphAndEmptySection() { - runTestFor("*text* \$sec:") + runTestFor("*text*\n\$sec:\n") } Test fun emphAndSection() { - runTestFor("*text* \$sec: some text") + runTestFor("*text*\n\$sec: some text\n") } Test fun emphAndBracedSection() { - runTestFor("Text *bold* text \${sec}: some text") + runTestFor("Text *bold* text \n\${sec}: some text") } Test fun section() { runTestFor( - "Plain text \$one: Summary \${two}: Description with *emphasis* \${An example of a section}: Example") + "Plain text \n\$one: Summary \n\${two}: Description with *emphasis* \n\${An example of a section}: Example") } Test fun anonymousSection() { @@ -111,12 +117,12 @@ number two Test fun specialSection() { runTestFor( - "Plain text \$\$summary: Summary \${\$description}: Description \${\$An example of a section}: Example") + "Plain text \n\$\$summary: Summary \n\${\$description}: Description \n\${\$An example of a section}: Example") } Test fun emptySection() { runTestFor( - "Plain text \$summary:") + "Plain text \n\$summary:") } val b = "$" diff --git a/test/src/model/CommentTest.kt b/test/src/model/CommentTest.kt index b2ad0ac0..5fc95726 100644 --- a/test/src/model/CommentTest.kt +++ b/test/src/model/CommentTest.kt @@ -25,7 +25,7 @@ public class CommentTest { verifyModel("test/data/comments/multilineDoc.kt") { model -> with(model.members.single().members.single()) { assertEquals("doc1", content.summary.toTestString()) - assertEquals("doc2\ndoc3\n", content.description.toTestString()) + assertEquals("doc2\ndoc3", content.description.toTestString()) } } } diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index c6ad93cc..2a4ad0a5 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -24,12 +24,10 @@ public class FunctionTest { assertEquals("fn", name) assertEquals(DocumentationNode.Kind.Function, kind) assertEquals("Function with receiver", content.summary.toTestString()) - assertEquals("Unit", details.elementAt(0).name) - assertEquals(4, details.count()) + assertEquals("internal", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) - assertEquals("internal", details.elementAt(2).name) - with(details.elementAt(3)) { + with(details.elementAt(2)) { assertEquals("<this>", name) assertEquals(DocumentationNode.Kind.Receiver, kind) assertEquals(Content.Empty, content) @@ -37,6 +35,7 @@ public class FunctionTest { assertTrue(members.none()) assertTrue(links.none()) } + assertEquals("Unit", details.elementAt(3).name) assertTrue(members.none()) assertTrue(links.none()) } @@ -51,10 +50,9 @@ public class FunctionTest { assertEquals("generic function", content.summary.toTestString()) assertEquals(4, details.count()) - assertEquals("Unit", details.elementAt(0).name) + assertEquals("private", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) - assertEquals("private", details.elementAt(2).name) - with(details.elementAt(3)) { + with(details.elementAt(2)) { assertEquals("T", name) assertEquals(DocumentationNode.Kind.TypeParameter, kind) assertEquals(Content.Empty, content) @@ -62,6 +60,7 @@ public class FunctionTest { assertTrue(members.none()) assertTrue(links.none()) } + assertEquals("Unit", details.elementAt(3).name) assertTrue(members.none()) assertTrue(links.none()) @@ -76,15 +75,16 @@ public class FunctionTest { assertEquals("generic function", content.summary.toTestString()) assertEquals(5, details.count()) - assertEquals("Unit", details.elementAt(0).name) + assertEquals("public", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) - assertEquals("public", details.elementAt(2).name) - with(details.elementAt(3)) { + with(details.elementAt(2)) { assertEquals("T", name) assertEquals(DocumentationNode.Kind.TypeParameter, kind) assertEquals(Content.Empty, content) with(details.single()) { assertEquals("R", name) + assertEquals("R", name) + assertEquals("R", name) assertEquals(DocumentationNode.Kind.UpperBound, kind) assertEquals(Content.Empty, content) assertTrue(details.none()) @@ -94,13 +94,14 @@ public class FunctionTest { assertTrue(members.none()) assertTrue(links.none()) } - with(details.elementAt(4)) { + with(details.elementAt(3)) { assertEquals("R", name) assertEquals(DocumentationNode.Kind.TypeParameter, kind) assertEquals(Content.Empty, content) assertTrue(members.none()) assertTrue(links.none()) } + assertEquals("Unit", details.elementAt(4).name) assertTrue(members.none()) assertTrue(links.none()) @@ -118,10 +119,9 @@ public class FunctionTest { Documentation""", content.description.toTestString()) assertEquals(4, details.count()) - assertEquals("Unit", details.elementAt(0).name) + assertEquals("internal", details.elementAt(0).name) assertEquals("final", details.elementAt(1).name) - assertEquals("internal", details.elementAt(2).name) - with(details.elementAt(3)) { + with(details.elementAt(2)) { assertEquals("x", name) assertEquals(DocumentationNode.Kind.Parameter, kind) assertEquals("parameter", content.summary.toTestString()) @@ -129,7 +129,7 @@ Documentation""", content.description.toTestString()) assertTrue(members.none()) assertTrue(links.none()) } - + assertEquals("Unit", details.elementAt(3).name) assertTrue(members.none()) assertTrue(links.none()) } diff --git a/test/src/model/LinkTest.kt b/test/src/model/LinkTest.kt new file mode 100644 index 00000000..151d2696 --- /dev/null +++ b/test/src/model/LinkTest.kt @@ -0,0 +1,48 @@ +package org.jetbrains.dokka.tests + +import org.junit.Test +import kotlin.test.* +import org.jetbrains.dokka.* + +public class LinkTest { + Test fun linkToSelf() { + verifyModel("test/data/links/linkToSelf.kt") { model -> + with(model.members.single().members.single()) { + assertEquals("Foo", name) + assertEquals(DocumentationNode.Kind.Class, kind) + assertEquals("This is link to [Foo -> Class:Foo]", content.summary.toTestString()) + } + } + } + + Test fun linkToMember() { + verifyModel("test/data/links/linkToMember.kt") { model -> + with(model.members.single().members.single()) { + assertEquals("Foo", name) + assertEquals(DocumentationNode.Kind.Class, kind) + assertEquals("This is link to [member -> Function:member]", content.summary.toTestString()) + } + } + } + + Test fun linkToQualifiedMember() { + verifyModel("test/data/links/linkToQualifiedMember.kt") { model -> + with(model.members.single().members.single()) { + assertEquals("Foo", name) + assertEquals(DocumentationNode.Kind.Class, kind) + assertEquals("This is link to [Foo.member -> Function:member]", content.summary.toTestString()) + } + } + } + + Test fun linkToParam() { + verifyModel("test/data/links/linkToParam.kt") { model -> + with(model.members.single().members.single()) { + assertEquals("Foo", name) + assertEquals(DocumentationNode.Kind.Function, kind) + assertEquals("This is link to [param -> Parameter:param]", content.summary.toTestString()) + } + } + } + +}
\ No newline at end of file diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index 93d81769..7cd287a0 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -40,7 +40,7 @@ public class PropertyTest { assertEquals("String", detail(DocumentationNode.Kind.Type).name) assertTrue(links.none()) with(members.single()) { - assertEquals("<get-property>", name) + assertEquals("<get>", name) assertEquals(DocumentationNode.Kind.Function, kind) assertEquals(Content.Empty, content) assertEquals("String", detail(DocumentationNode.Kind.Type).name) @@ -66,7 +66,7 @@ public class PropertyTest { assertEquals(2, members.count()) with(members.elementAt(0)) { - assertEquals("<get-property>", name) + assertEquals("<get>", name) assertEquals(DocumentationNode.Kind.Function, kind) assertEquals(Content.Empty, content) val get_modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } |