diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-03-04 15:59:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-04 15:59:35 +0100 |
commit | 2717e8505a41e188d209b81a3150a16c64ca7239 (patch) | |
tree | 7b527a145b086e92f4fdcc3d4e786f478014f12f /plugins/base/src/test/kotlin | |
parent | 69dc33255c2cd1cb77b74325c89bc6a3ba34c6fa (diff) | |
download | dokka-2717e8505a41e188d209b81a3150a16c64ca7239.tar.gz dokka-2717e8505a41e188d209b81a3150a16c64ca7239.tar.bz2 dokka-2717e8505a41e188d209b81a3150a16c64ca7239.zip |
Obvious functions should also work for interfaces (#1763)
Diffstat (limited to 'plugins/base/src/test/kotlin')
4 files changed, 44 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index 6220cc50..72342962 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -306,7 +306,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { with((this / "java" / "E").cast<DEnum>()) { name equals "E" entries counts 1 - functions.sortedBy { it.name }.map { it.dri } equals listOf( + functions.sortedBy { it.name }.filter { it.name == "valueOf" || it.name == "values" }.map { it.dri } equals listOf( DRI("java", "E", DRICallable("valueOf", null, listOf(JavaClassReference("java.lang.String"))), PointingToDeclaration), DRI("java", "E", DRICallable("values", null, emptyList()), PointingToDeclaration), ) diff --git a/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt b/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt index 1a2e9fa3..ef36d811 100644 --- a/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt +++ b/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt @@ -46,6 +46,7 @@ class DivisionSwitchTest : BaseAbstractTest() { sourceRoots = listOf("src/") } } + suppressObviousFunctions = false pluginsConfigurations.addIfNotNull( PluginConfigurationImpl( DokkaBase::class.qualifiedName!!, diff --git a/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt b/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt index 01641131..d666b8a7 100644 --- a/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ObviousFunctionsDocumentableFilterTest.kt @@ -40,6 +40,23 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } @Test + fun `should suppress toString, equals and hashcode for interface`() { + testInline( + """ + /src/suppressed/Suppressed.kt + package suppressed + interface Suppressed + """.trimIndent(), + suppressingConfiguration + ) { + preMergeDocumentablesTransformationStage = { modules -> + val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions } + assertEquals(0, functions.size) + } + } + } + + @Test fun `should suppress toString, equals and hashcode in Java`() { testInline( """ @@ -121,6 +138,23 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { } @Test + fun `not should suppress toString, equals and hashcode for interface if custom config is provided`() { + testInline( + """ + /src/suppressed/Suppressed.kt + package suppressed + interface Suppressed + """.trimIndent(), + nonSuppressingConfiguration + ) { + preMergeDocumentablesTransformationStage = { modules -> + val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions } + assertEquals(listOf("equals", "hashCode", "toString").sorted(), functions.map { it.name }.sorted()) + } + } + } + + @Test fun `should not suppress toString, equals and hashcode if custom config is provided in Java`() { testInline( """ @@ -136,7 +170,13 @@ class ObviousFunctionsDocumentableFilterTest : BaseAbstractTest() { //I would normally just assert names but this would make it JDK dependent, so this is better assertEquals( 5, - setOf("equals", "hashCode", "toString", "notify", "notifyAll").intersect(functions.map { it.name }).size + setOf( + "equals", + "hashCode", + "toString", + "notify", + "notifyAll" + ).intersect(functions.map { it.name }).size ) } } diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index 24bf87c0..116759f3 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -16,6 +16,7 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo block: DModule.() -> Unit ) { val testConfiguration = configuration ?: dokkaConfiguration { + suppressObviousFunctions = false sourceSets { sourceSet { sourceRoots = listOf("src/") |