aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/TestAPI.kt5
-rw-r--r--test/src/format/MarkdownFormatTest.kt5
-rw-r--r--test/src/model/ClassTest.kt30
-rw-r--r--test/src/model/FunctionTest.kt54
-rw-r--r--test/src/model/PropertyTest.kt2
5 files changed, 63 insertions, 33 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt
index 165278f9..88d19036 100644
--- a/test/src/TestAPI.kt
+++ b/test/src/TestAPI.kt
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.config.ContentRoot
import org.jetbrains.kotlin.config.KotlinSourceRoot
-import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
import org.junit.Assert
import java.io.File
import kotlin.test.fail
@@ -33,8 +32,10 @@ public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule
}
val environment = AnalysisEnvironment(messageCollector) {
- val stringRoot = PathManager.getResourceRoot(javaClass<String>(), "/java/lang/String.class")
+ val stringRoot = PathManager.getResourceRoot(String::class.java, "/java/lang/String.class")
addClasspath(File(stringRoot))
+ val kotlinPairRoot = PathManager.getResourceRoot(Pair::class.java, "/kotlin/Pair.class")
+ addClasspath(File(kotlinPairRoot))
addRoots(roots.toList())
}
val options = DocumentationOptions(includeNonPublic = true, skipEmptyPackages = false, sourceLinks = listOf<SourceLinkDefinition>())
diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt
index 059b491b..88003051 100644
--- a/test/src/format/MarkdownFormatTest.kt
+++ b/test/src/format/MarkdownFormatTest.kt
@@ -1,7 +1,8 @@
package org.jetbrains.dokka.tests
+import org.jetbrains.dokka.KotlinLanguageService
+import org.jetbrains.dokka.MarkdownFormatService
import org.junit.Test
-import org.jetbrains.dokka.*
public class MarkdownFormatTest {
private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService())
@@ -30,7 +31,7 @@ public class MarkdownFormatTest {
}
}
- Test fun annotationParams() {
+ @Test fun annotationParams() {
verifyOutput("test/data/format/annotationParams.kt", ".md") { model, output ->
markdownService.appendNodes(tempLocation, output, model.members.single().members)
}
diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt
index 05fc2fc3..bcedf49c 100644
--- a/test/src/model/ClassTest.kt
+++ b/test/src/model/ClassTest.kt
@@ -1,8 +1,11 @@
package org.jetbrains.dokka.tests
+import org.jetbrains.dokka.Content
+import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.DocumentationReference
import org.junit.Test
-import kotlin.test.*
-import org.jetbrains.dokka.*
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
public class ClassTest {
Test fun emptyClass() {
@@ -148,19 +151,24 @@ public class ClassTest {
}
}
- Test fun annotatedClass() {
- verifyModel("test/data/classes/annotatedClass.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("data", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- }
+ @Test fun annotatedClass() {
+ verifyPackageMember("test/data/classes/annotatedClass.kt") { cls ->
+ assertEquals(1, cls.annotations.count())
+ with(cls.annotations[0]) {
+ assertEquals("Strictfp", name)
+ assertEquals(Content.Empty, content)
+ assertEquals(DocumentationNode.Kind.Annotation, kind)
}
}
}
+ @Test fun dataClass() {
+ verifyPackageMember("test/data/classes/dataClass.kt") { cls ->
+ val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
+ assertTrue("data" in modifiers)
+ }
+ }
+
Test fun annotatedClassWithAnnotationParameters() {
verifyModel("test/data/classes/annotatedClassWithAnnotationParameters.kt") { model ->
with(model.members.single().members.single()) {
diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt
index 80ae223d..734675de 100644
--- a/test/src/model/FunctionTest.kt
+++ b/test/src/model/FunctionTest.kt
@@ -7,7 +7,7 @@ import kotlin.test.assertEquals
import kotlin.test.assertTrue
public class FunctionTest {
- Test fun function() {
+ @Test fun function() {
verifyModel("test/data/functions/function.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("fn", name)
@@ -20,7 +20,7 @@ public class FunctionTest {
}
}
- Test fun functionWithReceiver() {
+ @Test fun functionWithReceiver() {
verifyModel("test/data/functions/functionWithReceiver.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("String", name)
@@ -52,7 +52,7 @@ public class FunctionTest {
}
}
- Test fun genericFunction() {
+ @Test fun genericFunction() {
verifyModel("test/data/functions/genericFunction.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("generic", name)
@@ -76,7 +76,7 @@ public class FunctionTest {
}
}
}
- Test fun genericFunctionWithConstraints() {
+ @Test fun genericFunctionWithConstraints() {
verifyModel("test/data/functions/genericFunctionWithConstraints.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("generic", name)
@@ -115,7 +115,7 @@ public class FunctionTest {
}
}
- Test fun functionWithParams() {
+ @Test fun functionWithParams() {
verifyModel("test/data/functions/functionWithParams.kt") { model ->
with(model.members.single().members.single()) {
assertEquals("function", name)
@@ -141,26 +141,37 @@ Documentation""", content.description.toTestString())
}
}
- Test fun annotatedFunction() {
- verifyModel("test/data/functions/annotatedFunction.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("inline", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- }
+ @Test fun annotatedFunction() {
+ verifyPackageMember("test/data/functions/annotatedFunction.kt") { func ->
+ assertEquals(1, func.annotations.count())
+ with(func.annotations[0]) {
+ assertEquals("Strictfp", name)
+ assertEquals(Content.Empty, content)
+ assertEquals(DocumentationNode.Kind.Annotation, kind)
}
}
}
- Test fun functionWithAnnotatedParam() {
+ @Test fun functionWithNotDocumentedAnnotation() {
+ verifyPackageMember("test/data/functions/functionWithNotDocumentedAnnotation.kt") { func ->
+ assertEquals(0, func.annotations.count())
+ }
+ }
+
+ @Test fun inlineFunction() {
+ verifyPackageMember("test/data/functions/inlineFunction.kt") { func ->
+ val modifiers = func.details(DocumentationNode.Kind.Modifier).map { it.name }
+ assertTrue("inline" in modifiers)
+ }
+ }
+
+ @Test fun functionWithAnnotatedParam() {
verifyModel("test/data/functions/functionWithAnnotatedParam.kt") { model ->
- with(model.members.single().members.single()) {
+ with(model.members.single().members.single { it.name == "function"} ) {
with(details.elementAt(2)) {
assertEquals(1, annotations.count())
with(annotations[0]) {
- assertEquals("noinline", name)
+ assertEquals("Fancy", name)
assertEquals(Content.Empty, content)
assertEquals(DocumentationNode.Kind.Annotation, kind)
}
@@ -169,6 +180,15 @@ Documentation""", content.description.toTestString())
}
}
+ @Test fun functionWithNoinlineParam() {
+ verifyPackageMember("test/data/functions/functionWithNoinlineParam.kt") { func ->
+ with(func.details.elementAt(2)) {
+ val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name }
+ assertTrue("noinline" in modifiers)
+ }
+ }
+ }
+
Test fun annotatedFunctionWithAnnotationParameters() {
verifyModel("test/data/functions/annotatedFunctionWithAnnotationParameters.kt") { model ->
with(model.members.single().members.single()) {
diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt
index 405b260f..0853cbc5 100644
--- a/test/src/model/PropertyTest.kt
+++ b/test/src/model/PropertyTest.kt
@@ -69,7 +69,7 @@ public class PropertyTest {
with(model.members.single().members.single()) {
assertEquals(1, annotations.count())
with(annotations[0]) {
- assertEquals("inline", name)
+ assertEquals("Volatile", name)
assertEquals(Content.Empty, content)
assertEquals(DocumentationNode.Kind.Annotation, kind)
}