diff options
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r-- | plugins/base/src/test/kotlin/transformers/InheritedEntriesDocumentableFilterTransfromerTest.kt | 112 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/transformers/ObviousAndInheritedFunctionsDocumentableFilterTest.kt (renamed from plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt) | 101 |
2 files changed, 183 insertions, 30 deletions
diff --git a/plugins/base/src/test/kotlin/transformers/InheritedEntriesDocumentableFilterTransfromerTest.kt b/plugins/base/src/test/kotlin/transformers/InheritedEntriesDocumentableFilterTransfromerTest.kt new file mode 100644 index 00000000..9cb956ba --- /dev/null +++ b/plugins/base/src/test/kotlin/transformers/InheritedEntriesDocumentableFilterTransfromerTest.kt @@ -0,0 +1,112 @@ +package transformers + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class InheritedEntriesDocumentableFilterTransformerTest : BaseAbstractTest() { + val suppressingInheritedConfiguration = dokkaConfiguration { + suppressInheritedMembers = true + suppressObviousFunctions = false + sourceSets { + sourceSet { + sourceRoots = listOf("src") + } + } + } + + val nonSuppressingInheritedConfiguration = dokkaConfiguration { + suppressObviousFunctions = false + suppressInheritedMembers = false + sourceSets { + sourceSet { + sourceRoots = listOf("src") + } + } + } + + + @Test + fun `should suppress toString, equals and hashcode but keep custom ones`() { + testInline( + """ + /src/suppressed/Suppressed.kt + package suppressed + data class Suppressed(val x: String) { + override fun toString(): String { + return "custom" + } + } + """.trimIndent(), + suppressingInheritedConfiguration + ) { + preMergeDocumentablesTransformationStage = { modules -> + val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions } + assertEquals(listOf("toString", "copy", "component1").sorted(), functions.map { it.name }.sorted()) + } + } + } + + @Test + fun `should suppress toString, equals and hashcode`() { + testInline( + """ + /src/suppressed/Suppressed.kt + package suppressed + data class Suppressed(val x: String) + """.trimIndent(), + suppressingInheritedConfiguration + ) { + preMergeDocumentablesTransformationStage = { modules -> + val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions } + assertEquals(listOf("copy", "component1").sorted(), functions.map { it.name }.sorted()) + } + } + } + + @Test + fun `should also suppress properites`(){ + testInline( + """ + /src/suppressed/Suppressed.kt + package suppressed + open class Parent { + val parentValue = "String" + } + + class Child : Parent { + + } + """.trimIndent(), + suppressingInheritedConfiguration + ) { + preMergeDocumentablesTransformationStage = { modules -> + val properties = modules.flatMap { it.packages }.flatMap { it.classlikes }.first { it.name == "Child" }.properties + assertEquals(0, properties.size) + } + } + } + + @Test + fun `should not suppress properites if config says so`(){ + testInline( + """ + /src/suppressed/Suppressed.kt + package suppressed + open class Parent { + val parentValue = "String" + } + + class Child : Parent { + + } + """.trimIndent(), + nonSuppressingInheritedConfiguration + ) { + preMergeDocumentablesTransformationStage = { modules -> + val properties = modules.flatMap { it.packages }.flatMap { it.classlikes }.first { it.name == "Child" }.properties + assertEquals(listOf("parentValue"), properties.map { it.name }) + } + } + } +}
\ No newline at end of file diff --git a/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt b/plugins/base/src/test/kotlin/transformers/ObviousAndInheritedFunctionsDocumentableFilterTest.kt index d666b8a7..3618c8fb 100644 --- a/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ObviousAndInheritedFunctionsDocumentableFilterTest.kt @@ -1,29 +1,63 @@ package transformers +import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest -import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.MethodSource +import testApi.testRunner.dokkaConfiguration import kotlin.test.assertEquals -class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { - val suppressingConfiguration = dokkaConfiguration { - sourceSets { - sourceSet { - sourceRoots = listOf("src") +class ObviousAndInheritedFunctionsDocumentableFilterTest : BaseAbstractTest() { + companion object { + @JvmStatic + fun suppressingObviousConfiguration() = listOf(dokkaConfiguration { + suppressInheritedMembers = false + suppressObviousFunctions = true + sourceSets { + sourceSet { + sourceRoots = listOf("src") + } } - } - } + }) - val nonSuppressingConfiguration = dokkaConfiguration { - suppressObviousFunctions = false - sourceSets { - sourceSet { - sourceRoots = listOf("src") + @JvmStatic + fun nonSuppressingObviousConfiguration() = listOf(dokkaConfiguration { + suppressObviousFunctions = false + suppressInheritedMembers = false + sourceSets { + sourceSet { + sourceRoots = listOf("src") + } } - } + }) + + @JvmStatic + fun suppressingInheritedConfiguration() = listOf(dokkaConfiguration { + suppressInheritedMembers = true + suppressObviousFunctions = false + sourceSets { + sourceSet { + sourceRoots = listOf("src") + } + } + }) + + @JvmStatic + fun nonSuppressingInheritedConfiguration() = listOf(dokkaConfiguration { + suppressObviousFunctions = false + suppressInheritedMembers = false + sourceSets { + sourceSet { + sourceRoots = listOf("src") + } + } + }) } - @Test - fun `should suppress toString, equals and hashcode`() { + + @ParameterizedTest + @MethodSource(value = ["suppressingObviousConfiguration"]) + fun `should suppress toString, equals and hashcode`(suppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.kt @@ -39,8 +73,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `should suppress toString, equals and hashcode for interface`() { + @ParameterizedTest + @MethodSource(value = ["suppressingObviousConfiguration", "suppressingInheritedConfiguration"]) + fun `should suppress toString, equals and hashcode for interface`(suppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.kt @@ -56,8 +91,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `should suppress toString, equals and hashcode in Java`() { + @ParameterizedTest + @MethodSource(value = ["suppressingObviousConfiguration", "suppressingInheritedConfiguration"]) + fun `should suppress toString, equals and hashcode in Java`(suppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.java @@ -74,8 +110,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `should suppress toString, equals and hashcode but keep custom ones`() { + @ParameterizedTest + @MethodSource(value = ["suppressingObviousConfiguration"]) + fun `should suppress toString, equals and hashcode but keep custom ones`(suppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.kt @@ -95,8 +132,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `should suppress toString, equals and hashcode but keep custom ones in Java`() { + @ParameterizedTest + @MethodSource(value = ["suppressingObviousConfiguration", "suppressingInheritedConfiguration"]) + fun `should suppress toString, equals and hashcode but keep custom ones in Java`(suppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.java @@ -117,8 +155,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `should not suppress toString, equals and hashcode if custom config is provided`() { + @ParameterizedTest + @MethodSource(value = ["nonSuppressingObviousConfiguration", "nonSuppressingInheritedConfiguration"]) + fun `should not suppress toString, equals and hashcode if custom config is provided`(nonSuppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.kt @@ -137,8 +176,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `not should suppress toString, equals and hashcode for interface if custom config is provided`() { + @ParameterizedTest + @MethodSource(value = ["nonSuppressingObviousConfiguration", "nonSuppressingInheritedConfiguration"]) + fun `not should suppress toString, equals and hashcode for interface if custom config is provided`(nonSuppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.kt @@ -154,8 +194,9 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } } - @Test - fun `should not suppress toString, equals and hashcode if custom config is provided in Java`() { + @ParameterizedTest + @MethodSource(value = ["nonSuppressingObviousConfiguration", "nonSuppressingInheritedConfiguration"]) + fun `should not suppress toString, equals and hashcode if custom config is provided in Java`(nonSuppressingConfiguration: DokkaConfigurationImpl) { testInline( """ /src/suppressed/Suppressed.java |