diff options
author | Ignat Beresnev <ignat@beresnev.me> | 2022-01-27 14:33:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 14:33:37 +0300 |
commit | 69638c251846abfc9c1b402f45c98c435fd30808 (patch) | |
tree | 65a29e159affb3cf6a2a50ad003ce6f0d99f219a /plugins/base/src/test/kotlin | |
parent | 066c551fc6fcb2c60e3ed2014d0ef5e11409f9eb (diff) | |
download | dokka-69638c251846abfc9c1b402f45c98c435fd30808.tar.gz dokka-69638c251846abfc9c1b402f45c98c435fd30808.tar.bz2 dokka-69638c251846abfc9c1b402f45c98c435fd30808.zip |
Enhance generated primary constructor signature for html format (#2313)
Fixes #1880
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r-- | plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt | 9 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/signatures/SignatureTest.kt | 26 |
2 files changed, 33 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt index 508a0a36..b6fc4e6b 100644 --- a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt @@ -122,7 +122,7 @@ class ConstructorsSignaturesTest : BaseAbstractTest() { |/src/main/kotlin/test/source.kt |package test | - |class SomeClass(val a: String) + |class SomeClass(val a: String, var i: Int) | """.trimIndent(), testConfiguration ) { @@ -139,8 +139,13 @@ class ConstructorsSignaturesTest : BaseAbstractTest() { +"(" group { group { - +"a: " // TODO: Make sure if we still do not want to have "val" here + +"val a: " group { link { +"String" } } + +", " + } + group { + +"var i: " + group { link { +"Int" } } } } +")" diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index 7ab0f663..ddf1c892 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -745,6 +745,32 @@ class SignatureTest : BaseAbstractTest() { } @Test + fun `primary constructor with properties check for all tokens`() { + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |class PrimaryConstructorClass<T>(val x: Int, var s: String) { } + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("root/example/-primary-constructor-class/index.html").firstSignature().match( + // In `<T>` expression, an empty `<span class="token keyword"></span>` is present for some reason + Span("class "), A("PrimaryConstructorClass"), Span("<"), Span(), A("T"), Span(">"), Span("("), Parameters( + Parameter(Span("val "), "x", Span(": "), A("Int"), Span(",")), + Parameter(Span("var "), "s", Span(": "), A("String")) + ), Span(")"), Span(), + ) + } + } + } + + @Test fun `fun with default values`() { val source = source("fun simpleFun(int: Int = 1, string: String = \"string\"): String = \"\"") val writerPlugin = TestOutputWriterPlugin() |