diff options
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r-- | plugins/base/src/test/kotlin/signatures/SignatureTest.kt | 37 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt | 60 |
2 files changed, 95 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index d271be2e..38ae2be3 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 - class SignatureTest : BaseAbstractTest() { private val configuration = dokkaConfiguration { sourceSets { @@ -36,7 +35,8 @@ class SignatureTest : BaseAbstractTest() { name = "jvm" dependentSourceSets = setOf(DokkaSourceSetID("test", "common")) sourceRoots = listOf("src/main/kotlin/jvm/Test.kt") - classpath = listOf(commonStdlibPath!!) + classpath = listOf( + commonStdlibPath ?: throw IllegalStateException("Common stdlib is not found"),) externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) } } @@ -549,6 +549,39 @@ class SignatureTest : BaseAbstractTest() { } } } + @Test + fun `actual typealias should have generic parameters and fully qualified name of the expansion type`() { + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |expect class Array<T> + | + |/src/main/kotlin/jvm/Test.kt + |package example + | + |actual typealias Array<T> = kotlin.Array<T> + """.trimMargin(), + mppConfiguration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + val signatures = writerPlugin.writer.renderedContent("test/example/-array/index.html").signature().toList() + + signatures[0].match( + "expect class ", A("Array"), "<", A("T"), ">", + ignoreSpanWithTokenStyle = true + ) + signatures[1].match( + "actual typealias ", A("Array"), "<", A("T"), "> = ", A("kotlin.Array"), "<", A("T"), ">", + ignoreSpanWithTokenStyle = true + ) + } + } + } @Test fun `type with an actual typealias`() { diff --git a/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt index 81b4db69..11996186 100644 --- a/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt +++ b/plugins/base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt @@ -1,5 +1,6 @@ package transformers +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.SourceLinkDefinitionImpl import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.junit.jupiter.api.Test @@ -64,4 +65,63 @@ class SourceLinkTransformerTest : BaseAbstractTest() { } } } + + @Test + fun `source link should be for actual typealias`() { + 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) + sourceLinks = listOf( + SourceLinkDefinitionImpl( + localDirectory = "src/main/kotlin", + remoteUrl = URL("https://github.com/user/repo/tree/master/src/main/kotlin"), + remoteLineSuffix = "#L" + ) + ) + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |expect class Foo + | + |/src/main/kotlin/jvm/Test.kt + |package example + | + |class Bar + |actual typealias Foo = Bar + | + """.trimMargin(), + mppConfiguration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + val page = writerPlugin.writer.renderedContent("test/example/-foo/index.html") + val sourceLink = page.getSourceLink() + + assertEquals( + "https://github.com/user/repo/tree/master/src/main/kotlin/jvm/Test.kt#L4", + sourceLink + ) + } + } + } }
\ No newline at end of file |