aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-05-28 21:12:50 +0200
committerPaweł Marks <pmarks@virtuslab.com>2020-06-12 14:15:24 +0200
commitdd44b839eac1b7b647e97f2cc73dd96bd054713b (patch)
tree6ab5a393c2a7d926519626f5f45f5c8b8cd60505 /plugins/base/src/test/kotlin
parentd7be30c841cb925fd0d6322ccdd9877169730b92 (diff)
downloaddokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.tar.gz
dokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.tar.bz2
dokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.zip
Refactor of Annotations and ExtraModifiers to be platform depedent
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt38
-rw-r--r--plugins/base/src/test/kotlin/model/FunctionsTest.kt62
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt10
-rw-r--r--plugins/base/src/test/kotlin/model/PropertyTest.kt12
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt154
6 files changed, 139 insertions, 139 deletions
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index 98f572b4..d10bd151 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -149,6 +149,4 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
}
}
}
-
-
} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index 4ca34b00..5616a6c3 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -1,5 +1,6 @@
package model
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.KotlinModifier.*
import org.junit.jupiter.api.Assertions.assertNull
@@ -150,9 +151,9 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "classes" / "Klass").cast<DClass>()) {
name equals "Klass"
visibility.values allEquals KotlinVisibility.Public
- with(extra[AdditionalModifiers].assertNotNull("Extras")) {
- content counts 1
- content.first() equals ExtraModifiers.KotlinOnlyModifiers.Data
+ with(extra[AdditionalModifiers]!!.content.entries.single().value.assertNotNull("Extras")) {
+ this counts 1
+ first() equals ExtraModifiers.KotlinOnlyModifiers.Data
}
}
}
@@ -180,9 +181,9 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
"""
) {
with((this / "classes" / "Foo").cast<DClass>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- this.content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "Deprecated"
params.entries counts 1
(params["message"].assertNotNull("message") as StringValue).value equals "\"should no longer be used\""
@@ -273,9 +274,9 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "classes" / "C").cast<DClass>()) {
with((this / "D").cast<DClass>()) {
- with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
- content counts 1
- content.first() equals ExtraModifiers.KotlinOnlyModifiers.Inner
+ with(extra[AdditionalModifiers]!!.content.entries.single().value.assertNotNull("AdditionalModifiers")) {
+ this counts 1
+ first() equals ExtraModifiers.KotlinOnlyModifiers.Inner
}
}
}
@@ -359,9 +360,9 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
"""
) {
with((this / "classes" / "C").cast<DClass>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- this.content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
(params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
@@ -424,7 +425,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
"""@Suppress("abc") class Foo() {}"""
) {
with((this / "classes" / "Foo").cast<DClass>()) {
- with(extra[Annotations]?.content?.firstOrNull().assertNotNull("annotations")) {
+ with(extra[Annotations]!!.content.entries.single().value.firstOrNull().assertNotNull("annotations")) {
dri.toString() equals "kotlin/Suppress///PointingToDeclaration/"
(params["names"].assertNotNull("param") as ArrayValue).value equals listOf(StringValue("\"abc\""))
}
@@ -444,11 +445,14 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
"""
) {
with((this / "classes" / "throws").cast<DAnnotation>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "Retention"
-// params["value"].assertNotNull("value") equals "(java/lang/annotation/RetentionPolicy, SOURCE)"
+ params["value"].assertNotNull("value") equals EnumValue(
+ "RetentionPolicy.SOURCE",
+ DRI("java.lang.annotation", "RetentionPolicy.SOURCE")
+ )
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
index 38f64df5..c96e7df6 100644
--- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt
+++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
@@ -141,9 +141,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f").cast<DFunction>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "Suppress"
params.entries counts 1
(params["names"].assertNotNull("param") as ArrayValue).value equals listOf(StringValue("\"FOO\""))
@@ -161,8 +161,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f").cast<DFunction>()) {
- extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Inline
+ extra[AdditionalModifiers]!!.content.entries.single().value counts 1
+ extra[AdditionalModifiers]!!.content.entries.single().value exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -175,8 +175,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f").cast<DFunction>()) {
- extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ extra[AdditionalModifiers]!!.content.entries.single().value counts 1
+ extra[AdditionalModifiers]!!.content.entries.single().value exists ExtraModifiers.KotlinOnlyModifiers.Suspend
}
}
}
@@ -189,9 +189,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f").cast<DFunction>()) {
- extra[AdditionalModifiers]?.content counts 2
- extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
- extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Inline
+ extra[AdditionalModifiers]!!.content.entries.single().value counts 2
+ extra[AdditionalModifiers]!!.content.entries.single().value exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ extra[AdditionalModifiers]!!.content.entries.single().value exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -204,10 +204,10 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f").cast<DFunction>()) {
- with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
- content counts 2
- content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
- content exists ExtraModifiers.KotlinOnlyModifiers.Inline
+ with(extra[AdditionalModifiers]!!.content.entries.single().value.assertNotNull("AdditionalModifiers")) {
+ this counts 2
+ this exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ this exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -226,9 +226,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "Fancy").cast<DAnnotation>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- content counts 3
- with(content.map { it.dri.classNames to it }.toMap()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 3
+ with(map { it.dri.classNames to it }.toMap()) {
with(this["Target"].assertNotNull("Target")) {
(params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
EnumValue(
@@ -249,9 +249,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
}
with((this / "function" / "function" / "notInlined").cast<DParameter>()) {
- with(this.extra[Annotations].assertNotNull("Annotations")) {
- content counts 1
- with(content.first()) {
+ with(this.extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "Fancy"
params.entries counts 0
}
@@ -268,8 +268,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f" / "notInlined").cast<DParameter>()) {
- extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.NoInline
+ extra[AdditionalModifiers]!!.content.entries.single().value counts 1
+ extra[AdditionalModifiers]!!.content.entries.single().value exists ExtraModifiers.KotlinOnlyModifiers.NoInline
}
}
}
@@ -296,9 +296,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
}
}
- with(extra[Annotations].assertNotNull("Annotations")) {
- content counts 3
- with(content.map { it.dri.classNames to it }.toMap()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 3
+ with(map { it.dri.classNames to it }.toMap()) {
with(this["Target"].assertNotNull("Target")) {
(params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
EnumValue(
@@ -319,9 +319,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
}
with((this / "function" / "f").cast<DFunction>()) {
- with(this.extra[Annotations].assertNotNull("Annotations")) {
- content counts 1
- with(content.first()) {
+ with(this.extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(this.first()) {
dri.classNames equals "Fancy"
params.entries counts 1
(params["size"] as StringValue).value equals "1"
@@ -381,9 +381,9 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
"""
) {
with((this / "function" / "f").cast<DFunction>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- this.content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
(params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index fd293b5c..8f52fcc8 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -295,9 +295,9 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
"""
) {
with((this / "java" / "C" / "foo").cast<DFunction>()) {
- with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
- content counts 1
- content.first() equals ExtraModifiers.JavaOnlyModifiers.Static
+ with(extra[AdditionalModifiers]!!.content.entries.single().value.assertNotNull("AdditionalModifiers")) {
+ this counts 1
+ first() equals ExtraModifiers.JavaOnlyModifiers.Static
}
}
}
@@ -335,8 +335,8 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
"""
) {
with((this / "java" / "Attribute").cast<DAnnotation>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- with(content.single()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ with(single()) {
dri.classNames equals "Target"
(params["value"].assertNotNull("value") as ArrayValue).value equals listOf(
EnumValue("ElementType.FIELD", DRI("java.lang.annotation", "ElementType")),
diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt
index 90a9d782..e384b920 100644
--- a/plugins/base/src/test/kotlin/model/PropertyTest.kt
+++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt
@@ -150,9 +150,9 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro
"""
) {
with((this / "property" / "prop").cast<DProperty>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- this.content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
(params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
@@ -178,9 +178,9 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro
}
) {
with((this / "property" / "property").cast<DProperty>()) {
- with(extra[Annotations].assertNotNull("Annotations")) {
- this.content counts 1
- with(content.first()) {
+ with(extra[Annotations]!!.content.entries.single().value.assertNotNull("Annotations")) {
+ this counts 1
+ with(first()) {
dri.classNames equals "Strictfp"
params.entries counts 0
}
diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt
index 7e1b8bf4..c7cea1f1 100644
--- a/plugins/base/src/test/kotlin/utils/contentUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt
@@ -28,36 +28,34 @@ fun ContentMatcherBuilder<*>.bareSignature(
returnType: String? = null,
vararg params: Pair<String, ParamAttributes>
) = group { // TODO: remove it when double wrapping for signatures will be resolved
- group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
- }
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
}
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
- link { +name }
- +"("
- params.forEachIndexed { id, (n, t) ->
-
- t.annotations.forEach {
- unwrapAnnotation(it)
- }
- t.keywords.forEach {
- +it
- }
+ }
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
+ link { +name }
+ +"("
+ params.forEachIndexed { id, (n, t) ->
- +"$n:"
- group { link { +(t.type) } }
- if (id != params.lastIndex)
- +", "
+ t.annotations.forEach {
+ unwrapAnnotation(it)
}
- +")"
- if (returnType != null) {
- +(": ")
- group {
- link {
- +(returnType)
- }
+ t.keywords.forEach {
+ +it
+ }
+
+ +"$n:"
+ group { link { +(t.type) } }
+ if (id != params.lastIndex)
+ +", "
+ }
+ +")"
+ if (returnType != null) {
+ +(": ")
+ group {
+ link {
+ +(returnType)
}
}
}
@@ -87,40 +85,38 @@ fun ContentMatcherBuilder<*>.bareSignatureWithReceiver(
returnType: String? = null,
vararg params: Pair<String, ParamAttributes>
) = group { // TODO: remove it when double wrapping for signatures will be resolved
- group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
- }
- }
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
+ annotations.entries.forEach {
group {
- link { +receiver }
+ unwrapAnnotation(it)
}
- +"."
- link { +name }
- +"("
- params.forEachIndexed { id, (n, t) ->
-
- t.annotations.forEach {
- unwrapAnnotation(it)
- }
- t.keywords.forEach {
- +it
- }
+ }
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} fun")
+ group {
+ link { +receiver }
+ }
+ +"."
+ link { +name }
+ +"("
+ params.forEachIndexed { id, (n, t) ->
- +"$n:"
- group { link { +(t.type) } }
- if (id != params.lastIndex)
- +", "
+ t.annotations.forEach {
+ unwrapAnnotation(it)
}
- +")"
- if (returnType != null) {
- +(": ")
- group {
- link {
- +(returnType)
- }
+ t.keywords.forEach {
+ +it
+ }
+
+ +"$n:"
+ group { link { +(t.type) } }
+ if (id != params.lastIndex)
+ +", "
+ }
+ +")"
+ if (returnType != null) {
+ +(": ")
+ group {
+ link {
+ +(returnType)
}
}
}
@@ -148,20 +144,18 @@ fun ContentMatcherBuilder<*>.propertySignature(
link { +name }
platformHinted {
group {
- group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
- }
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
}
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
- link { +name }
- if (type != null) {
- +(": ")
- group {
- link {
- +(type)
- }
+ }
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
+ link { +name }
+ if (type != null) {
+ +(": ")
+ group {
+ link {
+ +(type)
}
}
}
@@ -184,15 +178,19 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil
group { content() }
}
-fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry<String, Set<String>>) {
- +"@"
- link { +elem.key }
- +"("
- elem.value.forEach {
- +("$it = ")
- skipAllNotMatching()
+private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry<String, Set<String>>) {
+ group {
+ +"@"
+ link { +elem.key }
+ +"("
+ elem.value.forEach {
+ group {
+ +("$it = ")
+ skipAllNotMatching()
+ }
+ }
+ +")"
}
- +")"
}
data class ParamAttributes(