From 24710663084b0ccd964a2b8a3e0b1dacd63dac43 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Thu, 13 Aug 2020 14:18:45 +0200 Subject: Add generic typealiases proper parsing and some tests --- .../src/test/kotlin/signatures/SignatureTest.kt | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'plugins/base/src/test') diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index 421dd97f..dd3d85c1 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -425,6 +425,110 @@ class SignatureTest : AbstractCoreTest() { } } + @Test + fun `plain typealias of plain class`() { + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + moduleName = "test" + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |typealias PlainTypealias = Int + | + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("test/example.html").signature().first().match( + "typealias ", A("PlainTypealias"), " = ", A("Int"), Span() + ) + } + } + } + + @Test + fun `plain typealias of generic class`() { + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + moduleName = "test" + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |typealias PlainTypealias = Comparable + | + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("test/example.html").signature().first().match( + "typealias ", A("PlainTypealias"), " = ", A("Comparable"), + "<", A("Int"), ">", Span() + ) + } + } + } + + @Test + fun `typealias with generics params`() { + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + moduleName = "test" + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |typealias GenericTypealias = Comparable + | + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("test/example.html").signature().first().match( + "typealias ", A("GenericTypealias"), "<", A("T"), "> = ", A("Comparable"), + "<", A("T"), ">", Span() + ) + } + } + } + private fun TestOutputWriter.renderedContent(path: String = "root/example.html") = contents.getValue(path).let { Jsoup.parse(it) }.select("#content") .single() -- cgit