diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/data/classes/classWithClassObject.kt | 7 | ||||
-rw-r--r-- | test/data/format/classWithClassObject.html | 44 | ||||
-rw-r--r-- | test/data/format/classWithClassObject.kt | 7 | ||||
-rw-r--r-- | test/data/format/classWithClassObject.md | 30 | ||||
-rw-r--r-- | test/data/format/htmlEscaping.html | 12 | ||||
-rw-r--r-- | test/data/format/htmlEscaping.kt | 4 | ||||
-rw-r--r-- | test/data/format/overloads.html | 24 | ||||
-rw-r--r-- | test/data/format/overloads.kt | 5 | ||||
-rw-r--r-- | test/src/TestAPI.kt | 4 | ||||
-rw-r--r-- | test/src/format/HtmlFormatTest.kt | 27 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 8 | ||||
-rw-r--r-- | test/src/model/ClassTest.kt | 32 |
12 files changed, 200 insertions, 4 deletions
diff --git a/test/data/classes/classWithClassObject.kt b/test/data/classes/classWithClassObject.kt new file mode 100644 index 00000000..459efad6 --- /dev/null +++ b/test/data/classes/classWithClassObject.kt @@ -0,0 +1,7 @@ +class Klass() { + class object { + val x = 1 + + fun foo() {} + } +} diff --git a/test/data/format/classWithClassObject.html b/test/data/format/classWithClassObject.html new file mode 100644 index 00000000..79546418 --- /dev/null +++ b/test/data/format/classWithClassObject.html @@ -0,0 +1,44 @@ +<HTML> +<HEAD> +</HEAD> +<BODY> +<a href="out.html">test</a> / <a href="out.html"></a> / <a href="out.html">Klass</a><br/> +<br/> +<h1>Klass</h1> +<pre><code><span class="keyword">class </span><span class="identifier">Klass</span></code></pre><br/> +<br/> +<h3>Constructors</h3> +<table> +<tbody> +<tr> +<td> +<a href="out.html"><init></a></td> +<td> +<code><span class="keyword">public</span> <span class="identifier">Klass</span><span class="symbol">(</span><span class="symbol">)</span></code></td> +</tr> +</tbody> +</table> +<h3>Class Object Properties</h3> +<table> +<tbody> +<tr> +<td> +<a href="out.html">x</a></td> +<td> +<code><span class="keyword">val </span><span class="identifier">x</span><span class="symbol">: </span><span class="identifier">Int</span></code></td> +</tr> +</tbody> +</table> +<h3>Class Object Functions</h3> +<table> +<tbody> +<tr> +<td> +<a href="out.html">foo</a></td> +<td> +<code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td> +</tr> +</tbody> +</table> +</BODY> +</HTML> diff --git a/test/data/format/classWithClassObject.kt b/test/data/format/classWithClassObject.kt new file mode 100644 index 00000000..459efad6 --- /dev/null +++ b/test/data/format/classWithClassObject.kt @@ -0,0 +1,7 @@ +class Klass() { + class object { + val x = 1 + + fun foo() {} + } +} diff --git a/test/data/format/classWithClassObject.md b/test/data/format/classWithClassObject.md new file mode 100644 index 00000000..f694a76f --- /dev/null +++ b/test/data/format/classWithClassObject.md @@ -0,0 +1,30 @@ +[test](out.md) / [](out.md) / [Klass](out.md) + + +# Klass + + +``` +class Klass +``` + + + + +### Constructors + + +| [<init>](out.md) | `public Klass()` | + + +### Class Object Properties + + +| [x](out.md) | `val x: Int` | + + +### Class Object Functions + + +| [foo](out.md) | `fun foo(): Unit` | + diff --git a/test/data/format/htmlEscaping.html b/test/data/format/htmlEscaping.html new file mode 100644 index 00000000..4f1409c4 --- /dev/null +++ b/test/data/format/htmlEscaping.html @@ -0,0 +1,12 @@ +<HTML> +<HEAD> +</HEAD> +<BODY> +<a href="out.html">test</a> / <a href="out.html"></a> / <a href="out.html">x</a><br/> +<br/> +<h1>x</h1> +<pre><code><span class="keyword">fun </span><span class="symbol"><</span><span class="identifier">T</span><span class="symbol">> </span><span class="identifier">x</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">T?</span></code></pre><p>Special characters: < is "less than", > is "greater than", & is "ampersand"</p> +<br/> +<br/> +</BODY> +</HTML> diff --git a/test/data/format/htmlEscaping.kt b/test/data/format/htmlEscaping.kt new file mode 100644 index 00000000..8778d8a5 --- /dev/null +++ b/test/data/format/htmlEscaping.kt @@ -0,0 +1,4 @@ +/** + * Special characters: < is "less than", > is "greater than", & is "ampersand" + */ +fun x<T>(): T? = null diff --git a/test/data/format/overloads.html b/test/data/format/overloads.html new file mode 100644 index 00000000..9ea88869 --- /dev/null +++ b/test/data/format/overloads.html @@ -0,0 +1,24 @@ +<HTML> +<HEAD> +</HEAD> +<BODY> +<a href="out.html">test</a> / <a href="out.html"></a><br/> +<br/> +<h1></h1> +<pre><code><span class="keyword">package</span> <span class="identifier"></span></code></pre><br/> +<br/> +<h3>Functions</h3> +<table> +<tbody> +<tr> +<td> +<a href="out.html">f</a></td> +<td> +<code><span class="keyword">fun </span><span class="identifier">f</span><span class="symbol">(</span><span class="identifier">x</span><span class="symbol">: </span><span class="identifier">Int</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code><br/> +<code><span class="keyword">fun </span><span class="identifier">f</span><span class="symbol">(</span><span class="identifier">x</span><span class="symbol">: </span><span class="identifier">String</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code><p>Performs an action on x.</p> +</td> +</tr> +</tbody> +</table> +</BODY> +</HTML> diff --git a/test/data/format/overloads.kt b/test/data/format/overloads.kt new file mode 100644 index 00000000..dcd2d097 --- /dev/null +++ b/test/data/format/overloads.kt @@ -0,0 +1,5 @@ +/** Performs an action on x. */ +fun f(x: Int) { } + +/** Performs an action on x. */ +fun f(x: String) { } diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index a16a0b57..cc09f001 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -51,11 +51,11 @@ public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> Disposer.dispose(environment) } -public fun verifyOutput(path: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { +public fun verifyOutput(path: String, outputExtension: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { verifyModel(path) { val output = StringBuilder() outputGenerator(it, output) - val expectedOutput = File(path.replace(".kt", ".md")).readText() + val expectedOutput = File(path.replace(".kt", outputExtension)).readText() assertEquals(expectedOutput, output.toString()) } } diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt new file mode 100644 index 00000000..881a7828 --- /dev/null +++ b/test/src/format/HtmlFormatTest.kt @@ -0,0 +1,27 @@ +package org.jetbrains.dokka.tests + +import org.jetbrains.dokka.KotlinLanguageService +import org.junit.Test +import org.jetbrains.dokka.HtmlFormatService + +public class HtmlFormatTest { + private val htmlService = HtmlFormatService(InMemoryLocationService, KotlinLanguageService()) + + Test fun classWithClassObject() { + verifyOutput("test/data/format/classWithClassObject.kt", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + Test fun htmlEscaping() { + verifyOutput("test/data/format/htmlEscaping.kt", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + Test fun overloads() { + verifyOutput("test/data/format/overloads.kt", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members) + } + } +} diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index beb727da..5cdfb8b5 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -9,7 +9,13 @@ public class MarkdownFormatTest { private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService()) Test fun emptyDescription() { - verifyOutput("test/data/format/emptyDescription.kt") { model, output -> + verifyOutput("test/data/format/emptyDescription.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + Test fun classWithClassObject() { + verifyOutput("test/data/format/classWithClassObject.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index 65363c92..b95a31dc 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -136,4 +136,34 @@ public class ClassTest { } } } -}
\ No newline at end of file + + Test fun classWithClassObject() { + verifyModel("test/data/classes/classWithClassObject.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(DocumentationNode.Kind.Class, kind) + assertEquals("Klass", name) + assertEquals(Content.Empty, content) + assertEquals(2, details.count()) + assertTrue(links.none()) + + assertEquals(3, members.count()) + with(members.elementAt(0)) { + assertEquals("<init>", name) + assertEquals(Content.Empty, content) + } + with(members.elementAt(1)) { + assertEquals("x", name) + assertEquals(DocumentationNode.Kind.ClassObjectProperty, kind) + assertTrue(members.none()) + assertTrue(links.none()) + } + with(members.elementAt(2)) { + assertEquals("foo", name) + assertEquals(DocumentationNode.Kind.ClassObjectFunction, kind) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + } +} |