aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test/kotlin
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2022-06-08 01:15:23 +0300
committerGitHub <noreply@github.com>2022-06-08 01:15:23 +0300
commit8c2a79f39377892be44d752d0958efb9b83f1fce (patch)
tree8ee91d4fa05fa31fb82df9ac1639812ff2840d4c /plugins/kotlin-as-java/src/test/kotlin
parent2e4121457a0fbae1a216007aee6c84a01be628f5 (diff)
downloaddokka-8c2a79f39377892be44d752d0958efb9b83f1fce.tar.gz
dokka-8c2a79f39377892be44d752d0958efb9b83f1fce.tar.bz2
dokka-8c2a79f39377892be44d752d0958efb9b83f1fce.zip
Support definitely non-nullable types (#2520)
* Support definitely non-nullable types [Definitely non-nullable types](https://github.com/Kotlin/KEEP/blob/c72601cf35c1e95a541bb4b230edb474a6d1d1a8/proposals/definitely-non-nullable-types.md) are enabled since Kotlin 1.7
Diffstat (limited to 'plugins/kotlin-as-java/src/test/kotlin')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt59
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
new file mode 100644
index 00000000..5f755ff3
--- /dev/null
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
@@ -0,0 +1,59 @@
+package kotlinAsJavaPlugin
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.jdk
+import org.junit.jupiter.api.Test
+import signatures.firstSignature
+import signatures.renderedContent
+import utils.*
+
+class KotlinAsJavaSignatureTest : BaseAbstractTest() {
+
+ private val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ externalDocumentationLinks = listOf(
+ DokkaConfiguration.ExternalDocumentationLink.jdk(8),
+ stdlibExternalDocumentationLink
+ )
+ }
+ }
+ }
+
+ @Suppress("SameParameterValue")
+ private fun source(signature: String) =
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt
+ |package kotlinAsJavaPlugin
+ |
+ | $signature
+ """.trimIndent()
+
+ @Test
+ fun `fun with definitely non-nullable types as java`() {
+ val source = source("fun <T> elvisLike(x: T, y: T & Any): T & Any = x ?: y")
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ source,
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val signature = writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-test-kt/elvis-like.html").firstSignature()
+ signature.match(
+ "public final static ", Span("T"), A("elvisLike"),
+ "<T extends ", A("Any"), ">(",
+ Span(
+ Span(Span(), " x, "),
+ Span(Span(), " y")
+ ),
+ ")", Span(),
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
+} \ No newline at end of file