aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 17:11:35 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 17:11:35 +0400
commit044e1b86602662c78bb2ed12b9d645ab10b23429 (patch)
tree91ca7ece2011b71fa10d0b184ccfa234fbe3130d /test/src
parent9fec3e15c94969f98596ac04130af6e2d9368a89 (diff)
downloaddokka-044e1b86602662c78bb2ed12b9d645ab10b23429.tar.gz
dokka-044e1b86602662c78bb2ed12b9d645ab10b23429.tar.bz2
dokka-044e1b86602662c78bb2ed12b9d645ab10b23429.zip
Setup test framework and empty DocumentationModel to kickstart test development.
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)
+}
+