aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/DiscoveryTest.kt12
-rw-r--r--test/src/TestAPI.kt36
2 files changed, 47 insertions, 1 deletions
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)
+}
+