diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-12-03 16:22:11 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-12-03 16:22:49 +0100 |
commit | 39631054c58df5841ea268b7002b820ec55f6e0a (patch) | |
tree | cefedd8411c859243bd181568e16fcdd372a38c8 /test/src | |
parent | 797cb4732c53bf1e3b2091add8cf731fc436607f (diff) | |
download | dokka-39631054c58df5841ea268b7002b820ec55f6e0a.tar.gz dokka-39631054c58df5841ea268b7002b820ec55f6e0a.tar.bz2 dokka-39631054c58df5841ea268b7002b820ec55f6e0a.zip |
restructure Dokka build to use Gradle for everything except for the Maven plugin
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/TestAPI.kt | 211 | ||||
-rw-r--r-- | test/src/format/HtmlFormatTest.kt | 157 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 218 | ||||
-rw-r--r-- | test/src/format/PackageDocsTest.kt | 18 | ||||
-rw-r--r-- | test/src/markdown/ParserTest.kt | 142 | ||||
-rw-r--r-- | test/src/model/ClassTest.kt | 275 | ||||
-rw-r--r-- | test/src/model/CommentTest.kt | 153 | ||||
-rw-r--r-- | test/src/model/FunctionTest.kt | 227 | ||||
-rw-r--r-- | test/src/model/JavaTest.kt | 197 | ||||
-rw-r--r-- | test/src/model/KotlinAsJavaTest.kt | 40 | ||||
-rw-r--r-- | test/src/model/LinkTest.kt | 48 | ||||
-rw-r--r-- | test/src/model/PackageTest.kt | 86 | ||||
-rw-r--r-- | test/src/model/PropertyTest.kt | 103 |
13 files changed, 0 insertions, 1875 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt deleted file mode 100644 index 6b21b7da..00000000 --- a/test/src/TestAPI.kt +++ /dev/null @@ -1,211 +0,0 @@ -package org.jetbrains.dokka.tests - -import com.google.inject.Guice -import com.intellij.openapi.application.PathManager -import com.intellij.openapi.util.Disposer -import com.intellij.openapi.util.io.FileUtil -import org.jetbrains.dokka.* -import org.jetbrains.dokka.Utilities.DokkaModule -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot -import org.jetbrains.kotlin.config.ContentRoot -import org.jetbrains.kotlin.config.KotlinSourceRoot -import org.junit.Assert -import java.io.File -import kotlin.test.fail - -public fun verifyModel(vararg roots: ContentRoot, - withJdk: Boolean = false, - withKotlinRuntime: Boolean = false, - format: String = "html", - verifier: (DocumentationModule) -> 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 = AnalysisEnvironment(messageCollector) - environment.apply { - 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("", format, includeNonPublic = true, skipEmptyPackages = false, sourceLinks = listOf<SourceLinkDefinition>()) - val injector = Guice.createInjector(DokkaModule(environment, options, DokkaConsoleLogger)) - val documentation = buildDocumentationModule(injector, "test") - verifier(documentation) - Disposer.dispose(environment) -} - -public fun verifyModel(source: String, - withJdk: Boolean = false, - withKotlinRuntime: Boolean = false, - format: String = "html", - verifier: (DocumentationModule) -> Unit) { - if (!File(source).exists()) { - throw IllegalArgumentException("Can't find test data file $source") - } - verifyModel(contentRootFromPath(source), - withJdk = withJdk, - withKotlinRuntime = withKotlinRuntime, - format = format, - verifier = verifier) -} - -public fun verifyPackageMember(source: String, - withJdk: Boolean = false, - withKotlinRuntime: Boolean = false, - verifier: (DocumentationNode) -> Unit) { - verifyModel(source, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime) { model -> - val pkg = model.members.single() - verifier(pkg.members.single()) - } -} - -public fun verifyJavaModel(source: String, - withKotlinRuntime: Boolean = false, - verifier: (DocumentationModule) -> Unit) { - val tempDir = FileUtil.createTempDirectory("dokka", "") - try { - val sourceFile = File(source) - FileUtil.copy(sourceFile, File(tempDir, sourceFile.name)) - verifyModel(JavaSourceRoot(tempDir, null), withJdk = true, withKotlinRuntime = withKotlinRuntime, verifier = verifier) - } - finally { - FileUtil.delete(tempDir) - } -} - -public fun verifyJavaPackageMember(source: String, - withKotlinRuntime: Boolean = false, - verifier: (DocumentationNode) -> Unit) { - verifyJavaModel(source, withKotlinRuntime) { model -> - val pkg = model.members.single() - verifier(pkg.members.single()) - } -} - -public fun verifyOutput(roots: Array<ContentRoot>, - outputExtension: String, - withJdk: Boolean = false, - withKotlinRuntime: Boolean = false, - outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyModel(*roots, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime) { - verifyModelOutput(it, outputExtension, outputGenerator, roots.first().path) - } -} - -private fun verifyModelOutput(it: DocumentationModule, - outputExtension: String, - outputGenerator: (DocumentationModule, StringBuilder) -> Unit, - sourcePath: String) { - val output = StringBuilder() - outputGenerator(it, output) - val ext = outputExtension.removePrefix(".") - val path = sourcePath - val expectedOutput = File(path.replaceAfterLast(".", ext, path + "." + ext)).readText() - assertEqualsIgnoringSeparators(expectedOutput, output.toString()) -} - -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 verifyJavaOutput(path: String, - outputExtension: String, - withKotlinRuntime: Boolean = false, - outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyJavaModel(path, withKotlinRuntime) { model -> - verifyModelOutput(model, outputExtension, outputGenerator, path) - } -} - -public fun assertEqualsIgnoringSeparators(expectedOutput: String, output: String) { - Assert.assertEquals(expectedOutput.replace("\r\n", "\n"), output.replace("\r\n", "\n")) -} - -fun StringBuilder.appendChildren(node: ContentBlock): StringBuilder { - for (child in node.children) { - val childText = child.toTestString() - append(childText) - } - return this -} - -fun StringBuilder.appendNode(node: ContentNode): StringBuilder { - when (node) { - is ContentText -> { - append(node.text) - } - is ContentEmphasis -> append("*").appendChildren(node).append("*") - is ContentBlockCode -> { - appendln("[code]") - appendChildren(node) - appendln() - appendln("[/code]") - } - is ContentNodeLink -> { - append("[") - appendChildren(node) - append(" -> ") - append(node.node.toString()) - append("]") - } - is ContentBlock -> { - appendChildren(node) - } - is ContentEmpty -> { /* nothing */ } - else -> throw IllegalStateException("Don't know how to format node $node") - } - return this -} - -fun ContentNode.toTestString(): String { - val node = this - return StringBuilder().apply { - appendNode(node) - }.toString() -} - -class InMemoryLocation(override val path: String): Location { - override fun relativePathTo(other: Location, anchor: String?): String = - if (anchor != null) other.path + "#" + anchor else other.path -} - -object InMemoryLocationService: LocationService { - override fun location(qualifiedName: List<String>, hasMembers: Boolean) = - InMemoryLocation(relativePathToNode(qualifiedName, hasMembers)) -} - -val tempLocation = InMemoryLocation("") - -val ContentRoot.path: String - get() = when(this) { - is KotlinSourceRoot -> path - is JavaSourceRoot -> file.path - else -> throw UnsupportedOperationException() - } diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt deleted file mode 100644 index 90291bff..00000000 --- a/test/src/format/HtmlFormatTest.kt +++ /dev/null @@ -1,157 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.HtmlFormatService -import org.jetbrains.dokka.HtmlTemplateService -import org.jetbrains.dokka.KotlinLanguageService -import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot -import org.jetbrains.kotlin.config.KotlinSourceRoot -import org.junit.Test -import java.io.File - -public class HtmlFormatTest { - private val htmlService = HtmlFormatService(InMemoryLocationService, KotlinLanguageService(), HtmlTemplateService.default()) - - @Test fun classWithCompanionObject() { - verifyOutput("test/data/format/classWithCompanionObject.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun htmlEscaping() { - verifyOutput("test/data/format/htmlEscaping.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun overloads() { - verifyOutput("test/data/format/overloads.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members) - } - } - - @Test fun overloadsWithDescription() { - verifyOutput("test/data/format/overloadsWithDescription.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun overloadsWithDifferentDescriptions() { - verifyOutput("test/data/format/overloadsWithDifferentDescriptions.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun deprecated() { - verifyOutput("test/data/format/deprecated.kt", ".package.html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members) - } - verifyOutput("test/data/format/deprecated.kt", ".class.html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun brokenLink() { - verifyOutput("test/data/format/brokenLink.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun codeSpan() { - verifyOutput("test/data/format/codeSpan.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun parenthesis() { - verifyOutput("test/data/format/parenthesis.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun bracket() { - verifyOutput("test/data/format/bracket.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun see() { - verifyOutput("test/data/format/see.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun tripleBackticks() { - verifyOutput("test/data/format/tripleBackticks.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun typeLink() { - verifyOutput("test/data/format/typeLink.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar"} ) - } - } - - @Test fun parameterAnchor() { - verifyOutput("test/data/format/parameterAnchor.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaSupertypeLink() { - verifyJavaOutput("test/data/format/javaSupertype.java", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C"}.members.filter { it.name == "Bar"} ) - } - } - - @Test fun javaLinkTag() { - verifyJavaOutput("test/data/format/javaLinkTag.java", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaLinkTagWithLabel() { - verifyJavaOutput("test/data/format/javaLinkTagWithLabel.java", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaSeeTag() { - verifyJavaOutput("test/data/format/javaSeeTag.java", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaDeprecated() { - verifyJavaOutput("test/data/format/javaDeprecated.java", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }) - } - } - - @Test fun crossLanguageKotlinExtendsJava() { - verifyOutput(arrayOf(KotlinSourceRoot("test/data/format/crossLanguage/kotlinExtendsJava/Bar.kt"), - JavaSourceRoot(File("test/data/format/crossLanguage/kotlinExtendsJava"), null)), - ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } - - @Test fun orderedList() { - verifyOutput("test/data/format/orderedList.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } - - @Test fun linkWithLabel() { - verifyOutput("test/data/format/linkWithLabel.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } - - @Test fun entity() { - verifyOutput("test/data/format/entity.kt", ".html") { model, output -> - htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } -} - diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt deleted file mode 100644 index 1a09ae60..00000000 --- a/test/src/format/MarkdownFormatTest.kt +++ /dev/null @@ -1,218 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.KotlinLanguageService -import org.jetbrains.dokka.MarkdownFormatService -import org.junit.Test - -public class MarkdownFormatTest { - private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService()) - - @Test fun emptyDescription() { - verifyOutput("test/data/format/emptyDescription.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun classWithCompanionObject() { - verifyOutput("test/data/format/classWithCompanionObject.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun annotations() { - verifyOutput("test/data/format/annotations.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun annotationClass() { - verifyOutput("test/data/format/annotationClass.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun annotationParams() { - verifyOutput("test/data/format/annotationParams.kt", ".md", withKotlinRuntime = true) { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun extensions() { - verifyOutput("test/data/format/extensions.kt", ".package.md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members) - } - verifyOutput("test/data/format/extensions.kt", ".class.md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun enumClass() { - verifyOutput("test/data/format/enumClass.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - verifyOutput("test/data/format/enumClass.kt", ".value.md") { model, output -> - val enumClassNode = model.members.single().members[0] - markdownService.appendNodes(tempLocation, output, - enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" }) - } - } - - @Test fun varargsFunction() { - verifyOutput("test/data/format/varargsFunction.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun overridingFunction() { - verifyOutput("test/data/format/overridingFunction.kt", ".md") { model, output -> - val classMembers = model.members.single().members.first { it.name == "D" }.members - markdownService.appendNodes(tempLocation, output, classMembers.filter { it.name == "f" }) - } - - } - - @Test fun propertyVar() { - verifyOutput("test/data/format/propertyVar.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun functionWithDefaultParameter() { - verifyOutput("test/data/format/functionWithDefaultParameter.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun accessor() { - verifyOutput("test/data/format/accessor.kt", ".md") { model, output -> - val propertyNode = model.members.single().members.first { it.name == "C" }.members.filter { it.name == "x" } - markdownService.appendNodes(tempLocation, output, propertyNode) - } - } - - @Test fun paramTag() { - verifyOutput("test/data/format/paramTag.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun throwsTag() { - verifyOutput("test/data/format/throwsTag.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun typeParameterBounds() { - verifyOutput("test/data/format/typeParameterBounds.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun typeParameterVariance() { - verifyOutput("test/data/format/typeParameterVariance.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun typeProjectionVariance() { - verifyOutput("test/data/format/typeProjectionVariance.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javadocHtml() { - verifyJavaOutput("test/data/format/javadocHtml.java", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaCodeLiteralTags() { - verifyJavaOutput("test/data/format/javaCodeLiteralTags.java", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaCodeInParam() { - verifyJavaOutput("test/data/format/javaCodeInParam.java", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun javaSpaceInAuthor() { - verifyJavaOutput("test/data/format/javaSpaceInAuthor.java", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun nullability() { - verifyOutput("test/data/format/nullability.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun operatorOverloading() { - verifyOutput("test/data/format/operatorOverloading.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }) - } - } - - @Test fun javadocOrderedList() { - verifyJavaOutput("test/data/format/javadocOrderedList.java", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } - - @Test fun companionObjectExtension() { - verifyOutput("test/data/format/companionObjectExtension.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Foo" }) - } - } - - @Test fun starProjection() { - verifyOutput("test/data/format/starProjection.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun extensionFunctionParameter() { - verifyOutput("test/data/format/extensionFunctionParameter.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun summarizeSignatures() { - verifyOutput("test/data/format/summarizeSignatures.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members) - } - } - - @Test fun summarizeSignaturesProperty() { - verifyOutput("test/data/format/summarizeSignaturesProperty.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members) - } - } - - @Test fun reifiedTypeParameter() { - verifyOutput("test/data/format/reifiedTypeParameter.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun annotatedTypeParameter() { - verifyOutput("test/data/format/annotatedTypeParameter.kt", ".md", withKotlinRuntime = true) { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members) - } - } - - @Test fun inheritedMembers() { - verifyOutput("test/data/format/inheritedMembers.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } - - @Test fun inheritedExtensions() { - verifyOutput("test/data/format/inheritedExtensions.kt", ".md") { model, output -> - markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) - } - } -} diff --git a/test/src/format/PackageDocsTest.kt b/test/src/format/PackageDocsTest.kt deleted file mode 100644 index 57a08563..00000000 --- a/test/src/format/PackageDocsTest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.jetbrains.dokka.tests.format - -import org.jetbrains.dokka.ContentBlock -import org.jetbrains.dokka.ContentText -import org.jetbrains.dokka.DokkaConsoleLogger -import org.jetbrains.dokka.PackageDocs -import org.junit.Test -import kotlin.test.assertEquals - -public class PackageDocsTest { - @Test fun verifyParse() { - val docs = PackageDocs(null, DokkaConsoleLogger) - docs.parse("test/data/packagedocs/stdlib.md", null) - val packageContent = docs.packageContent["kotlin"]!! - val block = (packageContent.children.single() as ContentBlock).children.first() as ContentText - assertEquals("Core functions and types", block.text) - } -} diff --git a/test/src/markdown/ParserTest.kt b/test/src/markdown/ParserTest.kt deleted file mode 100644 index 5a7adf05..00000000 --- a/test/src/markdown/ParserTest.kt +++ /dev/null @@ -1,142 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.junit.Test -import org.jetbrains.dokka.toTestString -import org.jetbrains.dokka.parseMarkdown -import org.junit.Ignore - -@Ignore public class ParserTest { - fun runTestFor(text : String) { - println("MD: ---") - println(text) - val markdownTree = parseMarkdown(text) - println("AST: ---") - println(markdownTree.toTestString()) - println() - } - - @Test fun text() { - runTestFor("text") - } - - @Test fun textWithSpaces() { - runTestFor("text and string") - } - - @Test fun textWithColon() { - runTestFor("text and string: cool!") - } - - @Test fun link() { - runTestFor("text [links]") - } - - @Test fun linkWithHref() { - runTestFor("text [links](http://google.com)") - } - - @Test fun multiline() { - runTestFor( - """ -text -and -string -""") - } - - @Test fun para() { - runTestFor( - """ -paragraph number -one - -paragraph -number two -""") - } - - @Test fun bulletList() { - runTestFor( - """* list item 1 -* list item 2 -""") - } - - @Test fun bulletListWithLines() { - runTestFor( - """ -* list item 1 - continue 1 -* list item 2 - continue 2 - """) - } - - @Test fun bulletListStrong() { - runTestFor( - """ -* list *item* 1 - continue 1 -* list *item* 2 - continue 2 - """) - } - - @Test fun emph() { - runTestFor("*text*") - } - - @Test fun directive() { - runTestFor("A text \${code with.another.value} with directive") - } - - @Test fun emphAndEmptySection() { - runTestFor("*text*\n\$sec:\n") - } - - @Test fun emphAndSection() { - runTestFor("*text*\n\$sec: some text\n") - } - - @Test fun emphAndBracedSection() { - runTestFor("Text *bold* text \n\${sec}: some text") - } - - @Test fun section() { - runTestFor( - "Plain text \n\$one: Summary \n\${two}: Description with *emphasis* \n\${An example of a section}: Example") - } - - @Test fun anonymousSection() { - runTestFor("Summary\n\nDescription\n") - } - - @Test fun specialSection() { - runTestFor( - "Plain text \n\$\$summary: Summary \n\${\$description}: Description \n\${\$An example of a section}: Example") - } - - @Test fun emptySection() { - runTestFor( - "Plain text \n\$summary:") - } - - val b = "$" - @Test fun pair() { - runTestFor( - """Represents a generic pair of two values. - -There is no meaning attached to values in this class, it can be used for any purpose. -Pair exhibits value semantics, i.e. two pairs are equal if both components are equal. - -An example of decomposing it into values: -${b}{code test.tuples.PairTest.pairMultiAssignment} - -${b}constructor: Creates new instance of [Pair] -${b}first: First value -${b}second: Second value"""" - ) - } - -} - diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt deleted file mode 100644 index ce4b4683..00000000 --- a/test/src/model/ClassTest.kt +++ /dev/null @@ -1,275 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.DocumentationNode -import org.jetbrains.dokka.DocumentationReference -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -public class ClassTest { - @Test fun emptyClass() { - verifyModel("test/data/classes/emptyClass.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("Klass", name) - assertEquals(Content.Empty, content) - assertEquals("<init>", members.single().name) - assertTrue(links.none()) - } - } - } - - @Test fun emptyObject() { - verifyModel("test/data/classes/emptyObject.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(DocumentationNode.Kind.Object, kind) - assertEquals("Obj", name) - assertEquals(Content.Empty, content) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun classWithConstructor() { - verifyModel("test/data/classes/classWithConstructor.kt") { model -> - with (model.members.single().members.single()) { - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("Klass", name) - assertEquals(Content.Empty, content) - assertTrue(links.none()) - - assertEquals(1, members.count()) - with(members.elementAt(0)) { - assertEquals("<init>", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Constructor, kind) - assertEquals(2, details.count()) - assertEquals("public", details.elementAt(0).name) - with(details.elementAt(1)) { - assertEquals("name", name) - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals(Content.Empty, content) - assertEquals("String", details.single().name) - assertTrue(links.none()) - assertTrue(members.none()) - } - assertTrue(links.none()) - assertTrue(members.none()) - } - } - } - } - - @Test fun classWithFunction() { - verifyModel("test/data/classes/classWithFunction.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("Klass", name) - assertEquals(Content.Empty, content) - assertTrue(links.none()) - - assertEquals(2, members.count()) - with(members.elementAt(0)) { - assertEquals("<init>", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Constructor, kind) - assertEquals(1, details.count()) - assertEquals("public", details.elementAt(0).name) - assertTrue(links.none()) - assertTrue(members.none()) - } - with(members.elementAt(1)) { - assertEquals("fn", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("Unit", detail(DocumentationNode.Kind.Type).name) - assertTrue(links.none()) - assertTrue(members.none()) - } - } - } - } - - @Test fun classWithProperty() { - verifyModel("test/data/classes/classWithProperty.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("Klass", name) - assertEquals(Content.Empty, content) - assertTrue(links.none()) - - assertEquals(2, members.count()) - with(members.elementAt(0)) { - assertEquals("<init>", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Constructor, kind) - assertEquals(1, details.count()) - assertEquals("public", details.elementAt(0).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - with(members.elementAt(1)) { - assertEquals("name", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Property, kind) - assertEquals("String", detail(DocumentationNode.Kind.Type).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - } - - @Test fun classWithCompanionObject() { - verifyModel("test/data/classes/classWithCompanionObject.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("Klass", name) - assertEquals(Content.Empty, content) - assertTrue(links.none()) - - assertEquals(3, members.count()) - with(members.elementAt(0)) { - assertEquals("<init>", name) - assertEquals(Content.Empty, content) - } - with(members.elementAt(1)) { - assertEquals("x", name) - assertEquals(DocumentationNode.Kind.CompanionObjectProperty, kind) - assertTrue(members.none()) - assertTrue(links.none()) - } - with(members.elementAt(2)) { - assertEquals("foo", name) - assertEquals(DocumentationNode.Kind.CompanionObjectFunction, kind) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - } - - @Test fun annotatedClass() { - verifyPackageMember("test/data/classes/annotatedClass.kt", withKotlinRuntime = true) { cls -> - assertEquals(1, cls.annotations.count()) - with(cls.annotations[0]) { - assertEquals("Strictfp", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - } - } - } - - @Test fun dataClass() { - verifyPackageMember("test/data/classes/dataClass.kt") { cls -> - val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name } - assertTrue("data" in modifiers) - } - } - - @Test fun sealedClass() { - verifyPackageMember("test/data/classes/sealedClass.kt") { cls -> - val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name } - assertEquals(1, modifiers.count { it == "sealed" }) - } - } - - @Test fun annotatedClassWithAnnotationParameters() { - verifyModel("test/data/classes/annotatedClassWithAnnotationParameters.kt") { model -> - with(model.members.single().members.single()) { - with(deprecation!!) { - assertEquals("Deprecated", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Value, kind) - assertEquals("\"should no longer be used\"", name) - } - } - } - } - } - } - - @Test fun javaAnnotationClass() { - verifyModel("test/data/classes/javaAnnotationClass.kt", withJdk = true) { model -> - with(model.members.single().members.single()) { - assertEquals(1, annotations.count()) - with(annotations[0]) { - assertEquals("Retention", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Value, kind) - assertEquals("RetentionPolicy.SOURCE", name) - } - } - } - } - } - } - - @Test fun notOpenClass() { - verifyModel("test/data/classes/notOpenClass.kt") { model -> - with(model.members.single().members.first { it.name == "D"}.members.first { it.name == "f" }) { - val modifiers = details(DocumentationNode.Kind.Modifier) - assertEquals(2, modifiers.size) - assertEquals("final", modifiers[1].name) - - val overrideReferences = references(DocumentationReference.Kind.Override) - assertEquals(1, overrideReferences.size) - } - } - } - - @Test fun indirectOverride() { - verifyModel("test/data/classes/indirectOverride.kt") { model -> - with(model.members.single().members.first { it.name == "E"}.members.first { it.name == "foo" }) { - val modifiers = details(DocumentationNode.Kind.Modifier) - assertEquals(2, modifiers.size) - assertEquals("final", modifiers[1].name) - - val overrideReferences = references(DocumentationReference.Kind.Override) - assertEquals(1, overrideReferences.size) - } - } - } - - @Test fun innerClass() { - verifyPackageMember("test/data/classes/innerClass.kt") { cls -> - val innerClass = cls.members.single { it.name == "D" } - val modifiers = innerClass.details(DocumentationNode.Kind.Modifier) - assertEquals(3, modifiers.size) - assertEquals("inner", modifiers[2].name) - } - } - - @Test fun companionObjectExtension() { - verifyModel("test/data/classes/companionObjectExtension.kt") { model -> - val pkg = model.members.single() - val cls = pkg.members.single { it.name == "Foo" } - val extensions = cls.extensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectProperty } - assertEquals(1, extensions.size) - } - } - - @Test fun secondaryConstructor() { - verifyPackageMember("test/data/classes/secondaryConstructor.kt") { cls -> - val constructors = cls.members(DocumentationNode.Kind.Constructor) - assertEquals(2, constructors.size) - with (constructors.first { it.details(DocumentationNode.Kind.Parameter).size == 1}) { - assertEquals("<init>", name) - assertEquals("This is a secondary constructor.", summary.toTestString()) - } - } - } -} diff --git a/test/src/model/CommentTest.kt b/test/src/model/CommentTest.kt deleted file mode 100644 index c4d867fb..00000000 --- a/test/src/model/CommentTest.kt +++ /dev/null @@ -1,153 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.junit.Test -import kotlin.test.* -import org.jetbrains.dokka.* - -public class CommentTest { - @Test fun emptyDoc() { - verifyModel("test/data/comments/emptyDoc.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(Content.Empty, content) - } - } - } - - @Test fun emptyDocButComment() { - verifyModel("test/data/comments/emptyDocButComment.kt") { model -> - with(model.members.single().members.single()) { - assertEquals(Content.Empty, content) - } - } - } - - @Test fun multilineDoc() { - verifyModel("test/data/comments/multilineDoc.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("doc1", content.summary.toTestString()) - assertEquals("doc2\ndoc3", content.description.toTestString()) - } - } - } - - @Test fun multilineDocWithComment() { - verifyModel("test/data/comments/multilineDocWithComment.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("doc1", content.summary.toTestString()) - assertEquals("doc2\ndoc3", content.description.toTestString()) - } - } - } - - @Test fun oneLineDoc() { - verifyModel("test/data/comments/oneLineDoc.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("doc", content.summary.toTestString()) - } - } - } - - @Test fun oneLineDocWithComment() { - verifyModel("test/data/comments/oneLineDocWithComment.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("doc", content.summary.toTestString()) - } - } - } - - @Test fun oneLineDocWithEmptyLine() { - verifyModel("test/data/comments/oneLineDocWithEmptyLine.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("doc", content.summary.toTestString()) - } - } - } - - @Test fun emptySection() { - verifyModel("test/data/comments/emptySection.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Summary", content.summary.toTestString()) - assertEquals(1, content.sections.count()) - with (content.findSectionByTag("one")!!) { - assertEquals("One", tag) - assertEquals("", toTestString()) - } - } - } - } - - @Test fun section1() { - verifyModel("test/data/comments/section1.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Summary", content.summary.toTestString()) - assertEquals(1, content.sections.count()) - with (content.findSectionByTag("one")!!) { - assertEquals("One", tag) - assertEquals("section one", toTestString()) - } - } - } - } - - @Test fun section2() { - verifyModel("test/data/comments/section2.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Summary", content.summary.toTestString()) - assertEquals(2, content.sections.count()) - with (content.findSectionByTag("one")!!) { - assertEquals("One", tag) - assertEquals("section one", toTestString()) - } - with (content.findSectionByTag("two")!!) { - assertEquals("Two", tag) - assertEquals("section two", toTestString()) - } - } - } - } - - @Test fun multilineSection() { - verifyModel("test/data/comments/multilineSection.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Summary", content.summary.toTestString()) - assertEquals(1, content.sections.count()) - with (content.findSectionByTag("one")!!) { - assertEquals("One", tag) - assertEquals("""line one -line two""", toTestString()) - } - } - } - } - - @Test fun directive() { - verifyModel("test/data/comments/directive.kt") { model -> - with(model.members.single().members.first()) { - assertEquals("Summary", content.summary.toTestString()) - with (content.description) { - assertEqualsIgnoringSeparators("""[code] -if (true) { - println(property) -} -[/code] -[code] -if (true) { - println(property) -} -[/code] -[code] -if (true) { - println(property) -} -[/code] -[code] -if (true) { - println(property) -} -[/code] -""", toTestString()) - } - } - } - } -} diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt deleted file mode 100644 index 8d1cf609..00000000 --- a/test/src/model/FunctionTest.kt +++ /dev/null @@ -1,227 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.DocumentationNode -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -public class FunctionTest { - @Test fun function() { - verifyModel("test/data/functions/function.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("fn", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("Function fn", content.summary.toTestString()) - assertEquals("Unit", detail(DocumentationNode.Kind.Type).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun functionWithReceiver() { - verifyModel("test/data/functions/functionWithReceiver.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("kotlin.String", name) - assertEquals(DocumentationNode.Kind.ExternalClass, kind) - assertEquals(2, members.count()) - with(members[0]) { - assertEquals("fn", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("Function with receiver", content.summary.toTestString()) - assertEquals("public", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - with(details.elementAt(2)) { - assertEquals("<this>", name) - assertEquals(DocumentationNode.Kind.Receiver, kind) - assertEquals(Content.Empty, content) - assertEquals("String", details.single().name) - assertTrue(members.none()) - assertTrue(links.none()) - } - assertEquals("Unit", details.elementAt(3).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - with(members[1]) { - assertEquals("fn", name) - assertEquals(DocumentationNode.Kind.Function, kind) - } - } - } - } - - @Test fun genericFunction() { - verifyModel("test/data/functions/genericFunction.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("generic", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("generic function", content.summary.toTestString()) - - assertEquals("private", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - with(details.elementAt(2)) { - assertEquals("T", name) - assertEquals(DocumentationNode.Kind.TypeParameter, kind) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - assertEquals("Unit", details.elementAt(3).name) - - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - @Test fun genericFunctionWithConstraints() { - verifyModel("test/data/functions/genericFunctionWithConstraints.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("generic", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("generic function", content.summary.toTestString()) - - assertEquals("public", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - with(details.elementAt(2)) { - assertEquals("T", name) - assertEquals(DocumentationNode.Kind.TypeParameter, kind) - assertEquals(Content.Empty, content) - with(details.single()) { - assertEquals("R", name) - assertEquals(DocumentationNode.Kind.UpperBound, kind) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - assertTrue(members.none()) - assertTrue(links.none()) - } - with(details.elementAt(3)) { - assertEquals("R", name) - assertEquals(DocumentationNode.Kind.TypeParameter, kind) - assertEquals(Content.Empty, content) - assertTrue(members.none()) - assertTrue(links.none()) - } - assertEquals("Unit", details.elementAt(4).name) - - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun functionWithParams() { - verifyModel("test/data/functions/functionWithParams.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("function", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("Multiline", content.summary.toTestString()) - assertEquals("""Function -Documentation""", content.description.toTestString()) - - assertEquals("public", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - with(details.elementAt(2)) { - assertEquals("x", name) - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals("parameter", content.summary.toTestString()) - assertEquals("Int", details.single().name) - assertTrue(members.none()) - assertTrue(links.none()) - } - assertEquals("Unit", details.elementAt(3).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun annotatedFunction() { - verifyPackageMember("test/data/functions/annotatedFunction.kt", withKotlinRuntime = true) { func -> - assertEquals(1, func.annotations.count()) - with(func.annotations[0]) { - assertEquals("Strictfp", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - } - } - } - - @Test fun functionWithNotDocumentedAnnotation() { - verifyPackageMember("test/data/functions/functionWithNotDocumentedAnnotation.kt") { func -> - assertEquals(0, func.annotations.count()) - } - } - - @Test fun inlineFunction() { - verifyPackageMember("test/data/functions/inlineFunction.kt") { func -> - val modifiers = func.details(DocumentationNode.Kind.Modifier).map { it.name } - assertTrue("inline" in modifiers) - } - } - - @Test fun functionWithAnnotatedParam() { - verifyModel("test/data/functions/functionWithAnnotatedParam.kt") { model -> - with(model.members.single().members.single { it.name == "function"} ) { - with(details.elementAt(2)) { - assertEquals(1, annotations.count()) - with(annotations[0]) { - assertEquals("Fancy", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - } - } - } - } - } - - @Test fun functionWithNoinlineParam() { - verifyPackageMember("test/data/functions/functionWithNoinlineParam.kt") { func -> - with(func.details.elementAt(2)) { - val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } - assertTrue("noinline" in modifiers) - } - } - } - - @Test fun annotatedFunctionWithAnnotationParameters() { - verifyModel("test/data/functions/annotatedFunctionWithAnnotationParameters.kt") { model -> - with(model.members.single().members.single { it.name == "f"}) { - assertEquals(1, annotations.count()) - with(annotations[0]) { - assertEquals("Fancy", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Value, kind) - assertEquals("1", name) - } - } - } - } - } - } - - @Test fun functionWithDefaultParameter() { - verifyModel("test/data/functions/functionWithDefaultParameter.kt") { model -> - with(model.members.single().members.single()) { - with(details.elementAt(2)) { - val value = details(DocumentationNode.Kind.Value) - assertEquals(1, value.count()) - with(value[0]) { - assertEquals("\"\"", name) - } - } - } - } - } -} diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt deleted file mode 100644 index 0633a5cc..00000000 --- a/test/src/model/JavaTest.kt +++ /dev/null @@ -1,197 +0,0 @@ -package org.jetbrains.dokka.tests - -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() { - verifyJavaPackageMember("test/data/java/member.java") { cls -> - assertEquals("Test", cls.name) - assertEquals(DocumentationNode.Kind.Class, cls.kind) - with(cls.members(DocumentationNode.Kind.Function).single()) { - assertEquals("fn", name) - assertEquals("Summary for Function", content.summary.toTestString().trimEnd()) - assertEquals(3, content.sections.size) - with(content.sections[0]) { - assertEquals("Parameters", tag) - assertEquals("name", subjectName) - assertEquals("is String parameter ", toTestString()) - } - with(content.sections[1]) { - assertEquals("Parameters", tag) - assertEquals("value", subjectName) - assertEquals("is int parameter ", toTestString()) - } - with(content.sections[2]) { - assertEquals("Author", tag) - assertEquals("yole", toTestString()) - } - assertEquals("Unit", detail(DocumentationNode.Kind.Type).name) - assertTrue(members.none()) - assertTrue(links.none()) - with(details.first { it.name == "name" }) { - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals("String", detail(DocumentationNode.Kind.Type).name) - } - with(details.first { it.name == "value" }) { - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals("Int", detail(DocumentationNode.Kind.Type).name) - } - } - } - } - - @Test fun memberWithModifiers() { - verifyJavaPackageMember("test/data/java/memberWithModifiers.java") { cls -> - val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name } - assertTrue("abstract" in modifiers) - with(cls.members.single { it.name == "fn" }) { - assertEquals("protected", details[0].name) - } - with(cls.members.single { it.name == "openFn" }) { - assertEquals("open", details[1].name) - } - } - } - - @Test fun superClass() { - verifyJavaPackageMember("test/data/java/superClass.java") { cls -> - val superTypes = cls.details(DocumentationNode.Kind.Supertype) - assertEquals(2, superTypes.size) - assertEquals("Exception", superTypes[0].name) - assertEquals("Cloneable", superTypes[1].name) - } - } - - @Test fun arrayType() { - verifyJavaPackageMember("test/data/java/arrayType.java") { cls -> - with(cls.members(DocumentationNode.Kind.Function).single()) { - val type = detail(DocumentationNode.Kind.Type) - assertEquals("Array", type.name) - assertEquals("String", type.detail(DocumentationNode.Kind.Type).name) - with(details(DocumentationNode.Kind.Parameter).single()) { - val parameterType = detail(DocumentationNode.Kind.Type) - assertEquals("IntArray", parameterType.name) - } - } - } - } - - @Test fun typeParameter() { - verifyJavaPackageMember("test/data/java/typeParameter.java") { cls -> - val typeParameters = cls.details(DocumentationNode.Kind.TypeParameter) - with(typeParameters.single()) { - assertEquals("T", name) - with(detail(DocumentationNode.Kind.UpperBound)) { - assertEquals("Comparable", name) - assertEquals("T", detail(DocumentationNode.Kind.Type).name) - } - } - with(cls.members(DocumentationNode.Kind.Function).single()) { - val methodTypeParameters = details(DocumentationNode.Kind.TypeParameter) - with(methodTypeParameters.single()) { - assertEquals("E", name) - } - } - } - } - - @Test fun constructors() { - verifyJavaPackageMember("test/data/java/constructors.java") { cls -> - val constructors = cls.members(DocumentationNode.Kind.Constructor) - assertEquals(2, constructors.size) - with(constructors[0]) { - assertEquals("<init>", name) - } - } - } - - @Test fun innerClass() { - verifyJavaPackageMember("test/data/java/innerClass.java") { cls -> - val innerClass = cls.members(DocumentationNode.Kind.Class).single() - assertEquals("D", innerClass.name) - } - } - - @Test fun varargs() { - verifyJavaPackageMember("test/data/java/varargs.java") { cls -> - val fn = cls.members(DocumentationNode.Kind.Function).single() - val param = fn.detail(DocumentationNode.Kind.Parameter) - assertEquals("vararg", param.details(DocumentationNode.Kind.Modifier).first().name) - val psiType = param.detail(DocumentationNode.Kind.Type) - assertEquals("String", psiType.name) - assertTrue(psiType.details(DocumentationNode.Kind.Type).isEmpty()) - } - } - - @Test fun fields() { - verifyJavaPackageMember("test/data/java/field.java") { cls -> - val i = cls.members(DocumentationNode.Kind.Property).single { it.name == "i" } - assertEquals("Int", i.detail(DocumentationNode.Kind.Type).name) - assertTrue("var" in i.details(DocumentationNode.Kind.Modifier).map { it.name }) - - val s = cls.members(DocumentationNode.Kind.Property).single { it.name == "s" } - assertEquals("String", s.detail(DocumentationNode.Kind.Type).name) - assertFalse("var" in s.details(DocumentationNode.Kind.Modifier).map { it.name }) - assertTrue("static" in s.details(DocumentationNode.Kind.Modifier).map { it.name }) - } - } - - @Test fun staticMethod() { - verifyJavaPackageMember("test/data/java/staticMethod.java") { cls -> - val m = cls.members(DocumentationNode.Kind.Function).single { it.name == "foo" } - assertTrue("static" in m.details(DocumentationNode.Kind.Modifier).map { it.name }) - } - } - - @Test fun annotatedAnnotation() { - verifyJavaPackageMember("test/data/java/annotatedAnnotation.java") { cls -> - assertEquals(1, cls.annotations.size) - with(cls.annotations[0]) { - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Parameter, kind) - assertEquals(1, details.count()) - with(details[0]) { - assertEquals(DocumentationNode.Kind.Value, kind) - assertEquals("[AnnotationTarget.FIELD, AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]", name) - } - } - } - } - } - - @Test fun deprecation() { - verifyJavaPackageMember("test/data/java/deprecation.java") { cls -> - val fn = cls.members(DocumentationNode.Kind.Function).single() - assertEquals("This should no longer be used", fn.deprecation!!.content.toTestString()) - } - } - - @Test fun javaLangObject() { - verifyJavaPackageMember("test/data/java/javaLangObject.java") { cls -> - val fn = cls.members(DocumentationNode.Kind.Function).single() - assertEquals("Any", fn.detail(DocumentationNode.Kind.Type).name) - } - } - - @Test fun enumValues() { - verifyJavaPackageMember("test/data/java/enumValues.java") { cls -> - val superTypes = cls.details(DocumentationNode.Kind.Supertype) - assertEquals(0, superTypes.size) - assertEquals(1, cls.members(DocumentationNode.Kind.EnumItem).size) - } - } - - @Test fun inheritorLinks() { - verifyJavaPackageMember("test/data/java/inheritorLinks.java") { cls -> - val fooClass = cls.members.single { it.name == "Foo" } - val inheritors = fooClass.references(DocumentationReference.Kind.Inheritor) - assertEquals(1, inheritors.size) - } - } -} diff --git a/test/src/model/KotlinAsJavaTest.kt b/test/src/model/KotlinAsJavaTest.kt deleted file mode 100644 index 18a1cfef..00000000 --- a/test/src/model/KotlinAsJavaTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.DocumentationModule -import org.jetbrains.dokka.DocumentationNode -import org.junit.Test -import kotlin.test.assertEquals - -class KotlinAsJavaTest { - @Test fun function() { - verifyModelAsJava("test/data/functions/function.kt") { model -> - val pkg = model.members.single() - - val facadeClass = pkg.members.single { it.name == "FunctionKt" } - assertEquals(DocumentationNode.Kind.Class, facadeClass.kind) - - val fn = facadeClass.members.single() - assertEquals("fn", fn.name) - assertEquals(DocumentationNode.Kind.Function, fn.kind) - } - } - - @Test fun propertyWithComment() { - verifyModelAsJava("test/data/comments/oneLineDoc.kt") { model -> - val facadeClass = model.members.single().members.single { it.name == "OneLineDocKt" } - val getter = facadeClass.members.single { it.name == "getProperty" } - assertEquals(DocumentationNode.Kind.Function, getter.kind) - assertEquals("doc", getter.content.summary.toTestString()) - } - } -} - -fun verifyModelAsJava(source: String, - withJdk: Boolean = false, - withKotlinRuntime: Boolean = false, - verifier: (DocumentationModule) -> Unit) { - verifyModel(source, - withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, - format = "html-as-java", - verifier = verifier) -} diff --git a/test/src/model/LinkTest.kt b/test/src/model/LinkTest.kt deleted file mode 100644 index a8004367..00000000 --- a/test/src/model/LinkTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.junit.Test -import kotlin.test.* -import org.jetbrains.dokka.* - -public class LinkTest { - @Test fun linkToSelf() { - verifyModel("test/data/links/linkToSelf.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Foo", name) - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("This is link to [Foo -> Class:Foo]", content.summary.toTestString()) - } - } - } - - @Test fun linkToMember() { - verifyModel("test/data/links/linkToMember.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Foo", name) - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("This is link to [member -> Function:member]", content.summary.toTestString()) - } - } - } - - @Test fun linkToQualifiedMember() { - verifyModel("test/data/links/linkToQualifiedMember.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Foo", name) - assertEquals(DocumentationNode.Kind.Class, kind) - assertEquals("This is link to [Foo.member -> Function:member]", content.summary.toTestString()) - } - } - } - - @Test fun linkToParam() { - verifyModel("test/data/links/linkToParam.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("Foo", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("This is link to [param -> Parameter:param]", content.summary.toTestString()) - } - } - } - -}
\ No newline at end of file diff --git a/test/src/model/PackageTest.kt b/test/src/model/PackageTest.kt deleted file mode 100644 index 52324f1d..00000000 --- a/test/src/model/PackageTest.kt +++ /dev/null @@ -1,86 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.DocumentationNode -import org.jetbrains.kotlin.config.KotlinSourceRoot -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -public class PackageTest { - @Test fun rootPackage() { - verifyModel("test/data/packages/rootPackage.kt") { model -> - with(model.members.single()) { - assertEquals(DocumentationNode.Kind.Package, kind) - assertEquals("", name) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun simpleNamePackage() { - verifyModel("test/data/packages/simpleNamePackage.kt") { model -> - with(model.members.single()) { - assertEquals(DocumentationNode.Kind.Package, kind) - assertEquals("simple", name) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun dottedNamePackage() { - verifyModel("test/data/packages/dottedNamePackage.kt") { model -> - with(model.members.single()) { - assertEquals(DocumentationNode.Kind.Package, kind) - assertEquals("dot.name", name) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun multipleFiles() { - verifyModel(KotlinSourceRoot("test/data/packages/dottedNamePackage.kt"), - KotlinSourceRoot("test/data/packages/simpleNamePackage.kt")) { model -> - assertEquals(2, model.members.count()) - with(model.members.single { it.name == "simple" }) { - assertEquals(DocumentationNode.Kind.Package, kind) - assertEquals("simple", name) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - with(model.members.single { it.name == "dot.name" }) { - assertEquals(DocumentationNode.Kind.Package, kind) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun multipleFilesSamePackage() { - verifyModel(KotlinSourceRoot("test/data/packages/simpleNamePackage.kt"), - KotlinSourceRoot("test/data/packages/simpleNamePackage2.kt")) { model -> - assertEquals(1, model.members.count()) - with(model.members.elementAt(0)) { - assertEquals(DocumentationNode.Kind.Package, kind) - assertEquals("simple", name) - assertEquals(Content.Empty, content) - assertTrue(details.none()) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } -}
\ No newline at end of file diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt deleted file mode 100644 index 093772b4..00000000 --- a/test/src/model/PropertyTest.kt +++ /dev/null @@ -1,103 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.DocumentationNode -import org.jetbrains.dokka.DocumentationReference -import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -public class PropertyTest { - @Test fun valueProperty() { - verifyModel("test/data/properties/valueProperty.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("property", name) - assertEquals(DocumentationNode.Kind.Property, kind) - assertEquals(Content.Empty, content) - assertEquals("String", detail(DocumentationNode.Kind.Type).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun variableProperty() { - verifyModel("test/data/properties/variableProperty.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("property", name) - assertEquals(DocumentationNode.Kind.Property, kind) - assertEquals(Content.Empty, content) - assertEquals("String", detail(DocumentationNode.Kind.Type).name) - assertTrue(members.none()) - assertTrue(links.none()) - } - } - } - - @Test fun valuePropertyWithGetter() { - verifyModel("test/data/properties/valuePropertyWithGetter.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("property", name) - assertEquals(DocumentationNode.Kind.Property, kind) - assertEquals(Content.Empty, content) - assertEquals("String", detail(DocumentationNode.Kind.Type).name) - assertTrue(links.none()) - assertTrue(members.none()) - } - } - } - - @Test fun variablePropertyWithAccessors() { - verifyModel("test/data/properties/variablePropertyWithAccessors.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("property", name) - assertEquals(DocumentationNode.Kind.Property, kind) - assertEquals(Content.Empty, content) - assertEquals("String", detail(DocumentationNode.Kind.Type).name) - val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name } - assertTrue("final" in modifiers) - assertTrue("public" in modifiers) - assertTrue("var" in modifiers) - assertTrue(links.none()) - assertTrue(members.none()) - } - } - } - - @Test fun annotatedProperty() { - verifyModel("test/data/properties/annotatedProperty.kt", withKotlinRuntime = true) { model -> - with(model.members.single().members.single()) { - assertEquals(1, annotations.count()) - with(annotations[0]) { - assertEquals("Volatile", name) - assertEquals(Content.Empty, content) - assertEquals(DocumentationNode.Kind.Annotation, kind) - } - } - } - } - - @Test fun propertyWithReceiver() { - verifyModel("test/data/properties/propertyWithReceiver.kt") { model -> - with(model.members.single().members.single()) { - assertEquals("kotlin.String", name) - assertEquals(DocumentationNode.Kind.ExternalClass, kind) - with(members.single()) { - assertEquals("foobar", name) - assertEquals(DocumentationNode.Kind.Property, kind) - } - } - } - } - - @Test fun propertyOverride() { - verifyModel("test/data/properties/propertyOverride.kt") { model -> - with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) { - assertEquals("xyzzy", name) - val override = references(DocumentationReference.Kind.Override).single().to - assertEquals("xyzzy", override.name) - assertEquals("Foo", override.owner!!.name) - } - } - } -} |