aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-08-13 14:18:45 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-17 11:53:29 +0200
commit24710663084b0ccd964a2b8a3e0b1dacd63dac43 (patch)
tree2f09197b8388362e375ddcd6694a6f3e6a2d8116 /plugins/base/src/test/kotlin/signatures/SignatureTest.kt
parent9a074919f4c0258cf2bf0cb61238a6005844e20b (diff)
downloaddokka-24710663084b0ccd964a2b8a3e0b1dacd63dac43.tar.gz
dokka-24710663084b0ccd964a2b8a3e0b1dacd63dac43.tar.bz2
dokka-24710663084b0ccd964a2b8a3e0b1dacd63dac43.zip
Add generic typealiases proper parsing and some tests
Diffstat (limited to 'plugins/base/src/test/kotlin/signatures/SignatureTest.kt')
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt104
1 files changed, 104 insertions, 0 deletions
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<Int>
+ |
+ """.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<T> = Comparable<T>
+ |
+ """.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()