From 044e1b86602662c78bb2ed12b9d645ab10b23429 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 11 Jul 2014 17:11:35 +0400 Subject: Setup test framework and empty DocumentationModel to kickstart test development. --- test/data/discovery.kt | 0 test/data/function.kt | 0 test/playground.kt | 16 ++++++++++++++-- test/src/DiscoveryTest.kt | 12 +++++++++++- test/src/TestAPI.kt | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) delete mode 100644 test/data/discovery.kt create mode 100644 test/data/function.kt create mode 100644 test/src/TestAPI.kt (limited to 'test') diff --git a/test/data/discovery.kt b/test/data/discovery.kt deleted file mode 100644 index e69de29b..00000000 diff --git a/test/data/function.kt b/test/data/function.kt new file mode 100644 index 00000000..e69de29b 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) +} + -- cgit