aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures
diff options
context:
space:
mode:
authorAndrey Tyrin <andrei.tyrin@jetbrains.com>2022-10-31 13:42:32 +0100
committerGitHub <noreply@github.com>2022-10-31 13:42:32 +0100
commitc0aece910e9b012a45ef577136a3f986c52df23e (patch)
tree37ac99a37569283185b4a6858cc3be80cc44ad7b /plugins/base/src/test/kotlin/signatures
parentd1b24984fdf6d2f383697b557086c62c94e4eee0 (diff)
downloaddokka-c0aece910e9b012a45ef577136a3f986c52df23e.tar.gz
dokka-c0aece910e9b012a45ef577136a3f986c52df23e.tar.bz2
dokka-c0aece910e9b012a45ef577136a3f986c52df23e.zip
Add constructor keyword (#2691)
Diffstat (limited to 'plugins/base/src/test/kotlin/signatures')
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt65
1 files changed, 52 insertions, 13 deletions
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 13e103b4..77c92d9c 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -8,7 +8,6 @@ import org.jetbrains.dokka.model.dfs
import org.junit.jupiter.api.Test
import utils.*
import kotlin.test.assertEquals
-import kotlin.test.assertFalse
class SignatureTest : BaseAbstractTest() {
private val configuration = dokkaConfiguration {
@@ -760,38 +759,50 @@ class SignatureTest : BaseAbstractTest() {
writerPlugin.writer.renderedContent("root/example/-generic-class/-generic-class.html").signature().zip(
listOf(
arrayOf(
- "fun <", A("T"), "> ", A("GenericClass"), "(", Parameters(
+ "constructor(",
+ Parameters(
Parameter("x: ", A("T"))
- ), ")",
+ ),
+ ")",
),
arrayOf(
- "fun ", A("GenericClass"), "(", Parameters(
+ "constructor(",
+ Parameters(
Parameter("x: ", A("Int"), ", "),
Parameter("y: ", A("String"))
- ), ")",
+ ),
+ ")",
),
arrayOf(
- "fun <", A("T"), "> ", A("GenericClass"), "(", Parameters(
+ "constructor(",
+ Parameters(
Parameter("x: ", A("Int"), ", "),
Parameter("y: ", A("List"), "<", A("T"), ">")
- ), ")",
+ ),
+ ")",
),
arrayOf(
- "fun ", A("GenericClass"), "(", Parameters(
+ "constructor(",
+ Parameters(
Parameter("x: ", A("Boolean"), ", "),
Parameter("y: ", A("Int"), ", "),
Parameter("z:", A("String"))
- ), ")",
+ ),
+ ")",
),
arrayOf(
- "fun <", A("T"), "> ", A("GenericClass"), "(", Parameters(
+ "constructor(",
+ Parameters(
Parameter("x: ", A("List"), "<", A("Comparable"), "<", A("Lazy"), "<", A("T"), ">>>?")
- ), ")",
+ ),
+ ")",
),
arrayOf(
- "fun ", A("GenericClass"), "(", Parameters(
+ "constructor(",
+ Parameters(
Parameter("x: ", A("Int"))
- ), ")",
+ ),
+ ")",
),
)
).forEach {
@@ -802,6 +813,34 @@ class SignatureTest : BaseAbstractTest() {
}
@Test
+ fun `constructor has its own custom signature keyword in Constructor tab`() {
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/common/Test.kt
+ |package example
+ |
+ |class PrimaryConstructorClass(x: String) { }
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val constructorTabFirstElement =
+ writerPlugin.writer.renderedContent("root/example/-primary-constructor-class/index.html")
+ .tab("Constructors")
+ .first() ?: throw NoSuchElementException("No Constructors tab found or it is empty")
+
+ constructorTabFirstElement.firstSignature().match(
+ "constructor(", Parameters(Parameter("x: ", A("String"))), ")",
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
+
+ @Test
fun `primary constructor with properties check for all tokens`() {
val writerPlugin = TestOutputWriterPlugin()