aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/content/annotations
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-02-05 14:55:45 +0100
committerGitHub <noreply@github.com>2021-02-05 14:55:45 +0100
commit70000c87a37caa2a6b518a555f53c98514434403 (patch)
tree3a0e7a2b797b6edfffc0396bb5f9d35708120e9d /plugins/base/src/test/kotlin/content/annotations
parentb44e41ec8e3e26c73affaaa98bbd170fde352d96 (diff)
downloaddokka-70000c87a37caa2a6b518a555f53c98514434403.tar.gz
dokka-70000c87a37caa2a6b518a555f53c98514434403.tar.bz2
dokka-70000c87a37caa2a6b518a555f53c98514434403.zip
Annotations for parameters (#1710)
* Annotations for parameters * Annotations for parameters
Diffstat (limited to 'plugins/base/src/test/kotlin/content/annotations')
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt54
1 files changed, 52 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index 164e5f4a..0b9e2390 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -5,11 +5,15 @@ import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Annotations
import org.jetbrains.dokka.model.StringValue
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.ContentPage
+import org.jetbrains.dokka.pages.ContentText
+import org.jetbrains.dokka.pages.MemberPageNode
import org.jetbrains.dokka.pages.PackagePageNode
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
import org.junit.jupiter.api.Test
import utils.ParamAttributes
+import utils.assertNotNull
import utils.bareSignature
import utils.propertySignature
import kotlin.test.assertEquals
@@ -227,7 +231,7 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
}
@Test
- fun `JvmName for property with setter and getter`(){
+ fun `JvmName for property with setter and getter`() {
testInline(
"""
|/src/main/kotlin/test/source.kt
@@ -237,7 +241,8 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
|var property: String
| get() = ""
| set(value) {}
- """.trimIndent(), testConfiguration) {
+ """.trimIndent(), testConfiguration
+ ) {
documentablesCreationStage = { modules ->
fun expectedAnnotation(name: String) = Annotations.Annotation(
dri = DRI("kotlin.jvm", "JvmName"),
@@ -264,4 +269,49 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `annotated bounds in Kotlin`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |@MustBeDocumented
+ |@Target(AnnotationTarget.TYPE_PARAMETER)
+ |annotation class Hello(val bar: String)
+ |fun <T: @Hello("abc") String> foo(arg: String): List<T> = TODO()
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { root ->
+ val fooPage = root.dfs { it.name == "foo" } as MemberPageNode
+ fooPage.content.dfs { it is ContentText && it.text == "Hello" }.assertNotNull()
+ }
+ }
+ }
+
+ @Test
+ fun `annotated bounds in Java`() {
+ testInline(
+ """
+ |/src/main/java/demo/AnnotationTest.java
+ |package demo;
+ |import java.lang.annotation.*;
+ |import java.util.List;
+ |@Documented
+ |@Target({ElementType.TYPE_USE, ElementType.TYPE})
+ |@interface Hello {
+ | public String bar() default "";
+ |}
+ |public class AnnotationTest {
+ | public <T extends @Hello(bar = "baz") String> List<T> foo() {
+ | return null;
+ | }
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { root ->
+ val fooPage = root.dfs { it.name == "foo" } as MemberPageNode
+ fooPage.content.dfs { it is ContentText && it.text == "Hello" }.assertNotNull()
+ }
+ }
+ }
}