diff options
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r-- | plugins/base/src/test/kotlin/model/FunctionsTest.kt | 4 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/signatures/SignatureTest.kt | 95 |
2 files changed, 58 insertions, 41 deletions
diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt index 29c81a65..fa65a477 100644 --- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt +++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt @@ -344,7 +344,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun parameters.forEach { p -> p.name equals "x" p.type.name.assertNotNull("Parameter type: ") equals "String" - p.extra[DefaultValue]?.value equals StringConstant("") + p.extra[DefaultValue]?.expression?.get(sourceSets.single()) equals StringConstant("") } } } @@ -363,7 +363,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun parameters.forEach { p -> p.name equals "x" p.type.name.assertNotNull("Parameter type: ") equals "Float" - p.extra[DefaultValue]?.value equals FloatConstant(3.14f) + p.extra[DefaultValue]?.expression?.get(sourceSets.single()) equals FloatConstant(3.14f) } } } diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index c290846e..3895eede 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -17,6 +17,25 @@ class SignatureTest : BaseAbstractTest() { } } + private val mppConfiguration = dokkaConfiguration { + moduleName = "test" + sourceSets { + sourceSet { + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + classpath = listOf(commonStdlibPath!!) + externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) + } + sourceSet { + name = "jvm" + dependentSourceSets = setOf(DokkaSourceSetID("test", "common")) + sourceRoots = listOf("src/main/kotlin/jvm/Test.kt") + classpath = listOf(commonStdlibPath!!) + externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) + } + } + } + fun source(signature: String) = """ |/src/main/kotlin/test/Test.kt @@ -419,26 +438,6 @@ class SignatureTest : BaseAbstractTest() { @Test fun `actual fun`() { - - val configuration = dokkaConfiguration { - moduleName = "test" - sourceSets { - sourceSet { - name = "common" - sourceRoots = listOf("src/main/kotlin/common/Test.kt") - classpath = listOf(commonStdlibPath!!) - externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) - } - sourceSet { - name = "jvm" - dependentSourceSets = setOf(DokkaSourceSetID("test", "common")) - sourceRoots = listOf("src/main/kotlin/jvm/Test.kt") - classpath = listOf(commonStdlibPath!!) - externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) - } - } - } - val writerPlugin = TestOutputWriterPlugin() testInline( @@ -454,7 +453,7 @@ class SignatureTest : BaseAbstractTest() { |actual fun simpleFun(): String = "Celebrimbor" | """.trimMargin(), - configuration, + mppConfiguration, pluginOverrides = listOf(writerPlugin) ) { renderingStage = { _, _ -> @@ -475,27 +474,45 @@ class SignatureTest : BaseAbstractTest() { } @Test - fun `type with an actual typealias`() { + fun `actual property with a default value`() { + val writerPlugin = TestOutputWriterPlugin() - val configuration = dokkaConfiguration { - moduleName = "test" - sourceSets { - sourceSet { - name = "common" - sourceRoots = listOf("src/main/kotlin/common/Test.kt") - classpath = listOf(commonStdlibPath!!) - externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) - } - sourceSet { - name = "jvm" - dependentSourceSets = setOf(DokkaSourceSetID("test", "common")) - sourceRoots = listOf("src/main/kotlin/jvm/Test.kt") - classpath = listOf(commonStdlibPath!!) - externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) - } + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |expect val prop: Int + | + |/src/main/kotlin/jvm/Test.kt + |package example + | + |actual val prop: Int = 2 + | + """.trimMargin(), + mppConfiguration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + val signatures = writerPlugin.writer.renderedContent("test/example/prop.html").signature().toList() + + signatures[0].match( + "expect val ", A("prop"), + ": ", A("Int"), Span(), + ignoreSpanWithTokenStyle = true + ) + signatures[1].match( + "actual val ", A("prop"), + ": ", A("Int"), + " = 2", Span(), + ignoreSpanWithTokenStyle = true + ) } } + } + @Test + fun `type with an actual typealias`() { val writerPlugin = TestOutputWriterPlugin() testInline( @@ -512,7 +529,7 @@ class SignatureTest : BaseAbstractTest() { |actual typealias Foo = Bar | """.trimMargin(), - configuration, + mppConfiguration, pluginOverrides = listOf(writerPlugin) ) { renderingStage = { _, _ -> |