aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/content/signatures
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-06-08 08:41:17 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-06-09 13:20:31 +0200
commit4346d4f45bff017df0135dc3c914db74c8795041 (patch)
treed11167985b56ea71a20992a1fdca832ef9590bd9 /plugins/base/src/test/kotlin/content/signatures
parent23e0d26139a09c7e2e157d1e0099ceab58d9bb48 (diff)
downloaddokka-4346d4f45bff017df0135dc3c914db74c8795041.tar.gz
dokka-4346d4f45bff017df0135dc3c914db74c8795041.tar.bz2
dokka-4346d4f45bff017df0135dc3c914db74c8795041.zip
Fix rendering of functions without parameters
Diffstat (limited to 'plugins/base/src/test/kotlin/content/signatures')
-rw-r--r--plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt43
-rw-r--r--plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt205
2 files changed, 245 insertions, 3 deletions
diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
index 68042fd4..bdefe45a 100644
--- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
+++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
@@ -1,15 +1,12 @@
package content.signatures
import matchers.content.*
-import org.jetbrains.dokka.pages.ContentGroup
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.pages.PackagePageNode
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
-import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.junit.jupiter.api.Test
import utils.ParamAttributes
import utils.bareSignature
-import utils.functionSignature
import utils.propertySignature
class ContentForSignaturesTest : AbstractCoreTest() {
@@ -142,6 +139,46 @@ class ContentForSignaturesTest : AbstractCoreTest() {
}
@Test
+ fun `function without parameters`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |fun function(): String {
+ | return "Hello"
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "function" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"function" }
+ }
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ bareSignature(
+ annotations = emptyMap(),
+ visibility = "",
+ modifier = "",
+ keywords = emptySet(),
+ name = "function",
+ returnType = "String",
+ )
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+
+ @Test
fun `suspend function`() {
testInline(
"""
diff --git a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt
new file mode 100644
index 00000000..d1e4dad8
--- /dev/null
+++ b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt
@@ -0,0 +1,205 @@
+package content.signatures
+
+import matchers.content.*
+import org.jetbrains.dokka.pages.ContentPage
+import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Test
+import utils.functionSignature
+
+class ConstructorsSignaturesTest : AbstractCoreTest() {
+ private val testConfiguration = dokkaConfiguration {
+ passes {
+ pass {
+ sourceRoots = listOf("src/")
+ analysisPlatform = "jvm"
+ targets = listOf("jvm")
+ }
+ }
+ }
+
+ @Test
+ fun `class name without parenthesis`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |class SomeClass
+ |
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "SomeClass" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"SomeClass" }
+ platformHinted {
+ group {
+ group {
+ +"class"
+ link { +"SomeClass" }
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `class name with empty parenthesis`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |class SomeClass()
+ |
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "SomeClass" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"SomeClass" }
+ platformHinted {
+ group {
+ group {
+ +"class"
+ link { +"SomeClass" }
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `class with a parameter`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |class SomeClass(a: String)
+ |
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "SomeClass" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"SomeClass" }
+ platformHinted {
+ group {
+ group {
+ +"class"
+ link { +"SomeClass" }
+ +"(a:"
+ group { link { +"String" } }
+ +")"
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `class with a val parameter`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |class SomeClass(val a: String)
+ |
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "SomeClass" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"SomeClass" }
+ platformHinted {
+ group {
+ group {
+ +"class"
+ link { +"SomeClass" }
+ +"(a:" // TODO: Make sure if we still do not want to have "val" here
+ group { link { +"String" } }
+ +")"
+ }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `class with a parameterless secondary constructor`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |class SomeClass(a: String) {
+ | constructor
+ |
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "SomeClass" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"SomeClass" }
+ platformHinted {
+ group {
+ group {
+ +"class"
+ link { +"SomeClass" }
+ +"(a:"
+ group { link { +"String" } }
+ +")"
+ }
+ }
+ }
+ }
+ group {
+ header { +"Constructors" }
+ table {
+ group {
+ link { +"<init>" }
+ functionSignature(
+ annotations = emptyMap(),
+ visibility = "",
+ modifier = "",
+ keywords = emptySet(),
+ name = "<init>"
+ )
+ }
+ }
+ skipAllNotMatching()
+ }
+
+ }
+ }
+ }
+ }
+} \ No newline at end of file