aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt14
-rw-r--r--plugins/base/src/test/kotlin/model/ObjectTest.kt39
-rw-r--r--plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt28
3 files changed, 65 insertions, 16 deletions
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index 6a3e80cd..1583e0c9 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -29,20 +29,6 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
}
@Test
- fun emptyObject() {
- inlineModelTest(
- """
- |object Obj {}
- """
- ) {
- with((this / "classes" / "Obj").cast<DObject>()) {
- name equals "Obj"
- children counts 3
- }
- }
- }
-
- @Test
fun classWithConstructor() {
inlineModelTest(
"""
diff --git a/plugins/base/src/test/kotlin/model/ObjectTest.kt b/plugins/base/src/test/kotlin/model/ObjectTest.kt
new file mode 100644
index 00000000..86045110
--- /dev/null
+++ b/plugins/base/src/test/kotlin/model/ObjectTest.kt
@@ -0,0 +1,39 @@
+package model
+
+import org.jetbrains.dokka.model.AdditionalModifiers
+import org.jetbrains.dokka.model.DObject
+import org.jetbrains.dokka.model.ExtraModifiers
+import org.junit.jupiter.api.Test
+import utils.AbstractModelTest
+
+class ObjectTest : AbstractModelTest("/src/main/kotlin/objects/Test.kt", "objects") {
+
+ @Test
+ fun emptyObject() {
+ inlineModelTest(
+ """
+ |object Obj {}
+ """.trimIndent()
+ ) {
+ with((this / "objects" / "Obj").cast<DObject>()) {
+ name equals "Obj"
+ children counts 3
+ }
+ }
+ }
+
+ @Test
+ fun `data object class`() {
+ inlineModelTest(
+ """
+ |data object KotlinDataObject {}
+ """.trimIndent()
+ ) {
+ with((this / "objects" / "KotlinDataObject").cast<DObject>()) {
+ name equals "KotlinDataObject"
+ extra[AdditionalModifiers]?.content?.values?.single()
+ ?.single() equals ExtraModifiers.KotlinOnlyModifiers.Data
+ }
+ }
+ }
+}
diff --git a/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt
index 9a96ad29..3a440af0 100644
--- a/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt
+++ b/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt
@@ -1,13 +1,13 @@
package translators
import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.modifiers
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.*
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertNull
+import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import utils.text
@@ -1049,6 +1049,30 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
}
}
}
+
+ @Test
+ fun `should add data modifier to data objects`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/KotlinDataObject.kt
+ |package test
+ |
+ |data object KotlinDataObject {}
+ """.trimIndent(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val pckg = module.packages.single { it.name == "test" }
+
+ val dataObject = pckg.classlikes.single { it.name == "KotlinDataObject" }
+ assertInstanceOf(DObject::class.java, dataObject)
+
+ val modifiers = (dataObject as DObject).modifiers().values.flatten()
+ assertEquals(1, modifiers.size)
+ assertEquals(ExtraModifiers.KotlinOnlyModifiers.Data, modifiers[0])
+ }
+ }
+ }
}
private sealed class TestSuite {