aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-07-29 14:32:24 +0200
committerGitHub <noreply@github.com>2022-07-29 14:32:24 +0200
commit7a875ee7d20b67725debd4c2c9e1f93e1889c302 (patch)
tree075210f83e5e5a7679194ba8c88dc426dead0777 /plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
parent26dde5b201b3c7e66212b07ddef333a3e340022a (diff)
downloaddokka-7a875ee7d20b67725debd4c2c9e1f93e1889c302.tar.gz
dokka-7a875ee7d20b67725debd4c2c9e1f93e1889c302.tar.bz2
dokka-7a875ee7d20b67725debd4c2c9e1f93e1889c302.zip
Add member icons to navigation menu (#2578)
Diffstat (limited to 'plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt')
-rw-r--r--plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt57
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt b/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
index 6a59a57e..939163ca 100644
--- a/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/JavaEnumsTest.kt
@@ -2,14 +2,25 @@ package enums
import org.jetbrains.dokka.SourceLinkDefinitionImpl
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.model.DEnum
+import org.jetbrains.dokka.model.ObviousMember
import org.junit.jupiter.api.Test
import signatures.renderedContent
import utils.TestOutputWriterPlugin
import java.net.URL
import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
class JavaEnumsTest : BaseAbstractTest() {
+ private val basicConfiguration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+
// Shouldn't try to give source links to synthetic methods (values, valueOf) if any are present
// https://github.com/Kotlin/dokka/issues/2544
@Test
@@ -57,4 +68,50 @@ class JavaEnumsTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `should mark synthetic functions generated for Kotlin as obvious`() {
+ val writerPlugin = TestOutputWriterPlugin()
+ testInline(
+ """
+ |/src/main/java/basic/JavaEnum.java
+ |package testpackage
+ |
+ |public enum JavaEnum {
+ | ONE, TWO
+ |}
+ """.trimMargin(),
+ basicConfiguration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ documentablesCreationStage = { modules ->
+ val pckg = modules.flatMap { it.packages }.single { it.packageName == "testpackage" }
+ val enum = pckg.children.single { it is DEnum } as DEnum
+
+ // there's two with the same name, one inherited from
+ // java.lang.Enum and one is synthetic for Kotlin interop
+ enum.functions.filter { it.name == "valueOf" }.let { valueOfMethods ->
+ assertEquals(2, valueOfMethods.size)
+
+ val valueOfFromKotlin = valueOfMethods[0]
+ assertEquals(
+ "testpackage/JavaEnum/valueOf/#java.lang.String/PointingToDeclaration/",
+ valueOfFromKotlin.dri.toString()
+ )
+ assertNotNull(valueOfFromKotlin.extra[ObviousMember])
+
+ val valueOfFromJava = valueOfMethods[1]
+ assertEquals(
+ "java.lang/Enum/valueOf/#java.lang.Class<T>#java.lang.String/PointingToDeclaration/",
+ valueOfFromJava.dri.toString()
+ )
+ assertNotNull(valueOfFromJava.extra[ObviousMember])
+ }
+
+ val valuesMethod = enum.functions.single { it.name == "values" }
+ assertEquals("testpackage/JavaEnum/values/#/PointingToDeclaration/", valuesMethod.dri.toString())
+ assertNotNull(valuesMethod.extra[ObviousMember])
+ }
+ }
+ }
}