aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/data/function.kt (renamed from test/data/discovery.kt)0
-rw-r--r--test/playground.kt16
-rw-r--r--test/src/DiscoveryTest.kt12
-rw-r--r--test/src/TestAPI.kt36
4 files changed, 61 insertions, 3 deletions
diff --git a/test/data/discovery.kt b/test/data/function.kt
index e69de29b..e69de29b 100644
--- a/test/data/discovery.kt
+++ b/test/data/function.kt
diff --git a/test/playground.kt b/test/playground.kt
index 80992fbd..5bc5207a 100644
--- a/test/playground.kt
+++ b/test/playground.kt
@@ -6,10 +6,10 @@ fun topLevelFunction() {
val topLevelConstantValue = "Hello"
-val topLevelValue : String
+val topLevelValue: String
get() = "Bye bye"
-var topLevelVariable : String
+var topLevelVariable: String
get() = "Modify me!"
set(value) {
}
@@ -23,6 +23,18 @@ class Class {
}
+/**
+ * This is a class with constructor and space after doc
+ */
+
+class ClassWithConstructor(val name: String)
+
+/**
+ * This is data class with constructor and comment after doc
+ */
+// irrelevant comment
+data class DataClass(val name: String, val age: Int) {}
+
object Object {
fun objectFunction() {
}
diff --git a/test/src/DiscoveryTest.kt b/test/src/DiscoveryTest.kt
index 71a8aa4f..690f0404 100644
--- a/test/src/DiscoveryTest.kt
+++ b/test/src/DiscoveryTest.kt
@@ -1,2 +1,12 @@
-public class DiscoveryTest {
+package com.jetbrains.dokka.tests
+
+import org.junit.Test
+
+
+public class FunctionTest {
+ Test fun function() {
+ verifyFiles("test/data/function.kt") {
+
+ }
+ }
} \ No newline at end of file
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt
new file mode 100644
index 00000000..80dc47d5
--- /dev/null
+++ b/test/src/TestAPI.kt
@@ -0,0 +1,36 @@
+package com.jetbrains.dokka.tests
+
+import org.jetbrains.jet.cli.common.messages.*
+import com.intellij.openapi.util.*
+import com.jetbrains.dokka.*
+import kotlin.test.fail
+
+public fun verifyFiles(vararg files: String, verifier: (DocumentationModel) -> Unit) {
+ val messageCollector = object : MessageCollector {
+ override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
+ when (severity) {
+ CompilerMessageSeverity.WARNING,
+ CompilerMessageSeverity.LOGGING,
+ CompilerMessageSeverity.OUTPUT,
+ CompilerMessageSeverity.INFO,
+ CompilerMessageSeverity.ERROR -> {
+ println("$severity: $message at $location")
+ }
+ CompilerMessageSeverity.EXCEPTION -> {
+ fail("$severity: $message at $location")
+ }
+ }
+ }
+ }
+
+ val environment = AnalysesEnvironment(messageCollector) {
+ addSources(files.toList())
+ }
+
+ val result = environment.processFiles { context, file ->
+ context.createDocumentation(file)
+ }.fold(DocumentationModel()) {(aggregate, item) -> aggregate.merge(item) }
+ verifier(result)
+ Disposer.dispose(environment)
+}
+