diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/src/TestAPI.kt | 47 | ||||
-rw-r--r-- | test/src/format/HtmlFormatTest.kt | 7 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 12 | ||||
-rw-r--r-- | test/src/model/ClassTest.kt | 4 | ||||
-rw-r--r-- | test/src/model/FunctionTest.kt | 2 | ||||
-rw-r--r-- | test/src/model/JavaTest.kt | 15 | ||||
-rw-r--r-- | test/src/model/PropertyTest.kt | 2 |
7 files changed, 56 insertions, 33 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index ce200bfe..59b6495b 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -13,7 +13,10 @@ import org.junit.Assert import java.io.File import kotlin.test.fail -public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule) -> Unit) { +public fun verifyModel(vararg roots: ContentRoot, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationModule) -> Unit) { val messageCollector = object : MessageCollector { override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) { when (severity) { @@ -32,10 +35,14 @@ public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule } val environment = AnalysisEnvironment(messageCollector) { - 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)) + if (withJdk || withKotlinRuntime) { + val stringRoot = PathManager.getResourceRoot(String::class.java, "/java/lang/String.class") + addClasspath(File(stringRoot)) + } + if (withKotlinRuntime) { + 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>()) @@ -44,19 +51,29 @@ public fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule Disposer.dispose(environment) } -public fun verifyModel(source: String, verifier: (DocumentationModule) -> Unit) { - verifyModel(contentRootFromPath(source), verifier = verifier) +public fun verifyModel(source: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationModule) -> Unit) { + verifyModel(contentRootFromPath(source), withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, verifier = verifier) } -public fun verifyPackageMember(kotlinSource: String, verifier: (DocumentationNode) -> Unit) { - verifyModel(kotlinSource) { model -> +public fun verifyPackageMember(kotlinSource: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + verifier: (DocumentationNode) -> Unit) { + verifyModel(kotlinSource, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime) { model -> val pkg = model.members.single() verifier(pkg.members.single()) } } -public fun verifyOutput(roots: Array<ContentRoot>, outputExtension: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyModel(*roots) { +public fun verifyOutput(roots: Array<ContentRoot>, + outputExtension: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { + verifyModel(*roots, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime) { val output = StringBuilder() outputGenerator(it, output) val ext = outputExtension.removePrefix(".") @@ -66,8 +83,12 @@ public fun verifyOutput(roots: Array<ContentRoot>, outputExtension: String, outp } } -public fun verifyOutput(path: String, outputExtension: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyOutput(arrayOf(contentRootFromPath(path)), outputExtension, outputGenerator) +public fun verifyOutput(path: String, + outputExtension: String, + withJdk: Boolean = false, + withKotlinRuntime: Boolean = false, + outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { + verifyOutput(arrayOf(contentRootFromPath(path)), outputExtension, withJdk, withKotlinRuntime, outputGenerator) } public fun assertEqualsIgnoringSeparators(expectedOutput: String, output: String) { diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index 5c7a63b3..2f450d0d 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -3,7 +3,6 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.HtmlFormatService import org.jetbrains.dokka.KotlinLanguageService import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot -import org.jetbrains.kotlin.config.ContentRoot import org.jetbrains.kotlin.config.KotlinSourceRoot import org.junit.Test import java.io.File @@ -105,19 +104,19 @@ public class HtmlFormatTest { } @Test fun javaLinkTag() { - verifyOutput("test/data/format/javaLinkTag.java", ".html") { model, output -> + verifyOutput("test/data/format/javaLinkTag.java", ".html", withJdk = true) { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } @Test fun javaLinkTagWithLabel() { - verifyOutput("test/data/format/javaLinkTagWithLabel.java", ".html") { model, output -> + verifyOutput("test/data/format/javaLinkTagWithLabel.java", ".html", withJdk = true) { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } @Test fun javaSeeTag() { - verifyOutput("test/data/format/javaSeeTag.java", ".html") { model, output -> + verifyOutput("test/data/format/javaSeeTag.java", ".html", withJdk = true) { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 64c8eeae..c5874b9f 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -32,7 +32,7 @@ public class MarkdownFormatTest { } @Test fun annotationParams() { - verifyOutput("test/data/format/annotationParams.kt", ".md") { model, output -> + verifyOutput("test/data/format/annotationParams.kt", ".md", withKotlinRuntime = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } @@ -121,25 +121,25 @@ public class MarkdownFormatTest { } @Test fun javadocHtml() { - verifyOutput("test/data/format/javadocHtml.java", ".md") { model, output -> + verifyOutput("test/data/format/javadocHtml.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } @Test fun javaCodeLiteralTags() { - verifyOutput("test/data/format/javaCodeLiteralTags.java", ".md") { model, output -> + verifyOutput("test/data/format/javaCodeLiteralTags.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } @Test fun javaCodeInParam() { - verifyOutput("test/data/format/javaCodeInParam.java", ".md") { model, output -> + verifyOutput("test/data/format/javaCodeInParam.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } @Test fun javaSpaceInAuthor() { - verifyOutput("test/data/format/javaSpaceInAuthor.java", ".md") { model, output -> + verifyOutput("test/data/format/javaSpaceInAuthor.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } @@ -157,7 +157,7 @@ public class MarkdownFormatTest { } @Test fun javadocOrderedList() { - verifyOutput("test/data/format/javadocOrderedList.java", ".md") { model, output -> + verifyOutput("test/data/format/javadocOrderedList.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index 0e2323c1..ce4b4683 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -152,7 +152,7 @@ public class ClassTest { } @Test fun annotatedClass() { - verifyPackageMember("test/data/classes/annotatedClass.kt") { cls -> + verifyPackageMember("test/data/classes/annotatedClass.kt", withKotlinRuntime = true) { cls -> assertEquals(1, cls.annotations.count()) with(cls.annotations[0]) { assertEquals("Strictfp", name) @@ -198,7 +198,7 @@ public class ClassTest { } @Test fun javaAnnotationClass() { - verifyModel("test/data/classes/javaAnnotationClass.kt") { model -> + verifyModel("test/data/classes/javaAnnotationClass.kt", withJdk = true) { model -> with(model.members.single().members.single()) { assertEquals(1, annotations.count()) with(annotations[0]) { diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index 9a5a67b4..b185e71a 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -142,7 +142,7 @@ Documentation""", content.description.toTestString()) } @Test fun annotatedFunction() { - verifyPackageMember("test/data/functions/annotatedFunction.kt") { func -> + verifyPackageMember("test/data/functions/annotatedFunction.kt", withKotlinRuntime = true) { func -> assertEquals(1, func.annotations.count()) with(func.annotations[0]) { assertEquals("Strictfp", name) diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt index 688cc8d9..5ec29b25 100644 --- a/test/src/model/JavaTest.kt +++ b/test/src/model/JavaTest.kt @@ -1,8 +1,11 @@ package org.jetbrains.dokka.tests -import kotlin.test.* -import org.jetbrains.dokka.* -import org.junit.* +import org.jetbrains.dokka.DocumentationNode +import org.jetbrains.dokka.DocumentationReference +import org.junit.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue public class JavaTest { @Test fun function() { @@ -162,7 +165,7 @@ public class JavaTest { } @Test fun deprecation() { - verifyPackageMember("test/data/java/deprecation.java") { cls -> + verifyPackageMember("test/data/java/deprecation.java", withJdk = true) { cls -> val fn = cls.members(DocumentationNode.Kind.Function).single() with(fn.deprecation!!) { assertEquals(1, details.count()) @@ -179,14 +182,14 @@ public class JavaTest { } @Test fun javaLangObject() { - verifyPackageMember("test/data/java/javaLangObject.java") { cls -> + verifyPackageMember("test/data/java/javaLangObject.java", withJdk = true) { cls -> val fn = cls.members(DocumentationNode.Kind.Function).single() assertEquals("Any", fn.detail(DocumentationNode.Kind.Type).name) } } @Test fun enumValues() { - verifyPackageMember("test/data/java/enumValues.java") { cls -> + verifyPackageMember("test/data/java/enumValues.java", withJdk = true) { cls -> val superTypes = cls.details(DocumentationNode.Kind.Supertype) assertEquals(0, superTypes.size) assertEquals(1, cls.members(DocumentationNode.Kind.EnumItem).size) diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index 0da510ed..310bc0ae 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -65,7 +65,7 @@ public class PropertyTest { } @Test fun annotatedProperty() { - verifyModel("test/data/properties/annotatedProperty.kt") { model -> + verifyModel("test/data/properties/annotatedProperty.kt", withKotlinRuntime = true) { model -> with(model.members.single().members.single()) { assertEquals(1, annotations.count()) with(annotations[0]) { |