aboutsummaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/kotlin/DokkaConfigurationTestImplementations.kt81
-rw-r--r--core/src/test/kotlin/NodeSelect.kt90
-rw-r--r--core/src/test/kotlin/TestAPI.kt353
-rw-r--r--core/src/test/kotlin/format/FileGeneratorTestCase.kt35
-rw-r--r--core/src/test/kotlin/format/GFMFormatTest.kt36
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt192
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt123
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt615
-rw-r--r--core/src/test/kotlin/format/PackageDocsTest.kt92
-rw-r--r--core/src/test/kotlin/issues/IssuesTest.kt34
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt333
-rw-r--r--core/src/test/kotlin/markdown/ParserTest.kt154
-rw-r--r--core/src/test/kotlin/model/ClassTest.kt318
-rw-r--r--core/src/test/kotlin/model/CommentTest.kt190
-rw-r--r--core/src/test/kotlin/model/DocumentableTest.kt108
-rw-r--r--core/src/test/kotlin/model/FunctionTest.kt281
-rw-r--r--core/src/test/kotlin/model/JavaTest.kt210
-rw-r--r--core/src/test/kotlin/model/KotlinAsJavaTest.kt64
-rw-r--r--core/src/test/kotlin/model/LinkTest.kt91
-rw-r--r--core/src/test/kotlin/model/PackageTest.kt136
-rw-r--r--core/src/test/kotlin/model/PropertyTest.kt129
-rw-r--r--core/src/test/kotlin/model/SourceLinksErrorTest.kt35
-rw-r--r--core/src/test/kotlin/model/SourceLinksTest.kt75
-rw-r--r--core/src/test/kotlin/model/TypeAliasTest.kt132
-rw-r--r--core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker1
25 files changed, 108 insertions, 3800 deletions
diff --git a/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt b/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt
deleted file mode 100644
index a6f427b1..00000000
--- a/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.Platform
-import java.io.File
-
-
-data class SourceLinkDefinitionImpl(override val path: String,
- override val url: String,
- override val lineSuffix: String?) : DokkaConfiguration.SourceLinkDefinition {
- companion object {
- fun parseSourceLinkDefinition(srcLink: String): DokkaConfiguration.SourceLinkDefinition {
- val (path, urlAndLine) = srcLink.split('=')
- return SourceLinkDefinitionImpl(
- File(path).canonicalPath,
- urlAndLine.substringBefore("#"),
- urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" })
- }
- }
-}
-
-class SourceRootImpl(path: String) : DokkaConfiguration.SourceRoot {
- override val path: String = File(path).absolutePath
-
- companion object {
- fun parseSourceRoot(sourceRoot: String): DokkaConfiguration.SourceRoot = SourceRootImpl(sourceRoot)
- }
-}
-
-data class PackageOptionsImpl(override val prefix: String,
- override val includeNonPublic: Boolean = false,
- override val reportUndocumented: Boolean = true,
- override val skipDeprecated: Boolean = false,
- override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions
-
- class DokkaConfigurationImpl(
- override val outputDir: String = "",
- override val format: String = "html",
- override val generateIndexPages: Boolean = false,
- override val cacheRoot: String? = null,
- override val impliedPlatforms: List<String> = emptyList(),
- override val passesConfigurations: List<DokkaConfiguration.PassConfiguration> = emptyList()
-) : DokkaConfiguration
-
-class PassConfigurationImpl (
- override val classpath: List<String> = emptyList(),
- override val moduleName: String = "",
- override val sourceRoots: List<DokkaConfiguration.SourceRoot> = emptyList(),
- override val samples: List<String> = emptyList(),
- override val includes: List<String> = emptyList(),
- override val includeNonPublic: Boolean = false,
- override val includeRootPackage: Boolean = false,
- override val reportUndocumented: Boolean = false,
- override val skipEmptyPackages: Boolean = false,
- override val skipDeprecated: Boolean = false,
- override val jdkVersion: Int = 6,
- override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition> = emptyList(),
- override val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(),
- externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> = emptyList(),
- override val languageVersion: String? = null,
- override val apiVersion: String? = null,
- override val noStdlibLink: Boolean = false,
- override val noJdkLink: Boolean = false,
- override val suppressedFiles: List<String> = emptyList(),
- override val collectInheritedExtensionsFromLibraries: Boolean = false,
- override val analysisPlatform: Platform = Platform.DEFAULT,
- override val targets: List<String> = emptyList(),
- override val sinceKotlin: String? = null
-): DokkaConfiguration.PassConfiguration {
- private val defaultLinks = run {
- val links = mutableListOf<DokkaConfiguration.ExternalDocumentationLink>()
- if (!noJdkLink)
- links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://docs.oracle.com/javase/$jdkVersion/docs/api/").build()
-
- if (!noStdlibLink)
- links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build()
- links
- }
- override val externalDocumentationLinks = defaultLinks + externalDocumentationLinks
-}
-
diff --git a/core/src/test/kotlin/NodeSelect.kt b/core/src/test/kotlin/NodeSelect.kt
deleted file mode 100644
index fe0394f9..00000000
--- a/core/src/test/kotlin/NodeSelect.kt
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.RefKind
-
-class SelectBuilder {
- private val root = ChainFilterNode(SubgraphTraverseFilter(), null)
- private var activeNode = root
- private val chainEnds = mutableListOf<SelectFilter>()
-
- fun withName(name: String) = matching { it.name == name }
-
- fun withKind(kind: NodeKind) = matching{ it.kind == kind }
-
- fun matching(block: (DocumentationNode) -> Boolean) {
- attachFilterAndMakeActive(PredicateFilter(block))
- }
-
- fun subgraph() {
- attachFilterAndMakeActive(SubgraphTraverseFilter())
- }
-
- fun subgraphOf(kind: RefKind) {
- attachFilterAndMakeActive(DirectEdgeFilter(kind))
- }
-
- private fun attachFilterAndMakeActive(next: SelectFilter) {
- activeNode = ChainFilterNode(next, activeNode)
- }
-
- private fun endChain() {
- chainEnds += activeNode
- }
-
- fun build(): SelectFilter {
- endChain()
- return CombineFilterNode(chainEnds)
- }
-}
-
-private class ChainFilterNode(val filter: SelectFilter, val previous: SelectFilter?): SelectFilter() {
- override fun select(roots: Sequence<DocumentationNode>): Sequence<DocumentationNode> {
- return filter.select(previous?.select(roots) ?: roots)
- }
-}
-
-private class CombineFilterNode(val previous: List<SelectFilter>): SelectFilter() {
- override fun select(roots: Sequence<DocumentationNode>): Sequence<DocumentationNode> {
- return previous.asSequence().flatMap { it.select(roots) }
- }
-}
-
-abstract class SelectFilter {
- abstract fun select(roots: Sequence<DocumentationNode>): Sequence<DocumentationNode>
-}
-
-private class SubgraphTraverseFilter: SelectFilter() {
- override fun select(roots: Sequence<DocumentationNode>): Sequence<DocumentationNode> {
- val visited = mutableSetOf<DocumentationNode>()
- return roots.flatMap {
- generateSequence(listOf(it)) { nodes ->
- nodes.flatMap { it.allReferences() }
- .map { it.to }
- .filter { visited.add(it) }
- .takeUnless { it.isEmpty() }
- }
- }.flatten()
- }
-
-}
-
-private class PredicateFilter(val condition: (DocumentationNode) -> Boolean): SelectFilter() {
- override fun select(roots: Sequence<DocumentationNode>): Sequence<DocumentationNode> {
- return roots.filter(condition)
- }
-}
-
-private class DirectEdgeFilter(val kind: RefKind): SelectFilter() {
- override fun select(roots: Sequence<DocumentationNode>): Sequence<DocumentationNode> {
- return roots.flatMap { it.references(kind).asSequence() }.map { it.to }
- }
-}
-
-
-fun selectNodes(root: DocumentationNode, block: SelectBuilder.() -> Unit): List<DocumentationNode> {
- val builder = SelectBuilder()
- builder.apply(block)
- return builder.build().select(sequenceOf(root)).toMutableSet().toList()
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt
deleted file mode 100644
index 4f9af761..00000000
--- a/core/src/test/kotlin/TestAPI.kt
+++ /dev/null
@@ -1,353 +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 com.intellij.rt.execution.junit.FileComparisonFailure
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Utilities.DokkaAnalysisModule
-import org.jetbrains.dokka.Utilities.DokkaRunModule
-import org.jetbrains.kotlin.cli.common.config.ContentRoot
-import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
-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.descriptors.DeclarationDescriptor
-import org.jetbrains.kotlin.utils.PathUtil
-import org.junit.Assert
-import org.junit.Assert.fail
-import java.io.File
-
-data class ModelConfig(
- val roots: Array<ContentRoot> = arrayOf(),
- val withJdk: Boolean = false,
- val withKotlinRuntime: Boolean = false,
- val format: String = "html",
- val includeNonPublic: Boolean = true,
- val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(),
- val analysisPlatform: Platform = Platform.DEFAULT,
- val defaultPlatforms: List<String> = emptyList(),
- val noStdlibLink: Boolean = true,
- val collectInheritedExtensionsFromLibraries: Boolean = false,
- val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition> = emptyList()
-)
-
-fun verifyModel(
- modelConfig: ModelConfig,
- verifier: (DocumentationModule) -> Unit
-) {
- val documentation = DocumentationModule("test")
-
- val passConfiguration = PassConfigurationImpl(
- includeNonPublic = modelConfig.includeNonPublic,
- skipEmptyPackages = false,
- includeRootPackage = true,
- sourceLinks = modelConfig.sourceLinks,
- perPackageOptions = modelConfig.perPackageOptions,
- noStdlibLink = modelConfig.noStdlibLink,
- noJdkLink = false,
- languageVersion = null,
- apiVersion = null,
- collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries
- )
- val configuration = DokkaConfigurationImpl(
- outputDir = "",
- format = modelConfig.format,
- generateIndexPages = false,
- cacheRoot = "default",
- passesConfigurations = listOf(passConfiguration)
- )
-
- appendDocumentation(documentation, configuration, passConfiguration, modelConfig)
- documentation.prepareForGeneration(configuration)
-
- verifier(documentation)
-}
-
-fun appendDocumentation(
- documentation: DocumentationModule,
- dokkaConfiguration: DokkaConfiguration,
- passConfiguration: DokkaConfiguration.PassConfiguration,
- modelConfig: ModelConfig
-) {
- val messageCollector = object : MessageCollector {
- override fun clear() {
-
- }
-
- override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation?) {
- when (severity) {
- CompilerMessageSeverity.STRONG_WARNING,
- CompilerMessageSeverity.WARNING,
- CompilerMessageSeverity.LOGGING,
- CompilerMessageSeverity.OUTPUT,
- CompilerMessageSeverity.INFO,
- CompilerMessageSeverity.ERROR -> {
- println("$severity: $message at $location")
- }
- CompilerMessageSeverity.EXCEPTION -> {
- fail("$severity: $message at $location")
- }
- }
- }
-
- override fun hasErrors() = false
- }
-
- val environment = AnalysisEnvironment(messageCollector, modelConfig.analysisPlatform)
- environment.apply {
- if (modelConfig.withJdk || modelConfig.withKotlinRuntime) {
- addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre())
- }
- if (modelConfig.withKotlinRuntime) {
- if (analysisPlatform == Platform.jvm) {
- val kotlinStrictfpRoot = PathManager.getResourceRoot(Strictfp::class.java, "/kotlin/jvm/Strictfp.class")
- addClasspath(File(kotlinStrictfpRoot))
- }
- if (analysisPlatform == Platform.js) {
- val kotlinStdlibJsRoot = PathManager.getResourceRoot(Any::class.java, "/kotlin/jquery")
- addClasspath(File(kotlinStdlibJsRoot))
- }
-
- if (analysisPlatform == Platform.common) {
- // TODO: Feels hacky
- val kotlinStdlibCommonRoot = ClassLoader.getSystemResource("kotlin/UInt.kotlin_metadata")
- addClasspath(File(kotlinStdlibCommonRoot.file.replace("file:", "").replaceAfter(".jar", "")))
- }
- }
- addRoots(modelConfig.roots.toList())
-
- loadLanguageVersionSettings(passConfiguration.languageVersion, passConfiguration.apiVersion)
- }
- val defaultPlatformsProvider = object : DefaultPlatformsProvider {
- override fun getDefaultPlatforms(descriptor: DeclarationDescriptor) = modelConfig.defaultPlatforms
- }
-
- val globalInjector = Guice.createInjector(
- DokkaRunModule(dokkaConfiguration)
- )
-
- val injector = globalInjector.createChildInjector(
- DokkaAnalysisModule(
- environment,
- dokkaConfiguration,
- defaultPlatformsProvider,
- documentation.nodeRefGraph,
- passConfiguration,
- DokkaConsoleLogger
- )
- )
-
- buildDocumentationModule(injector, documentation)
- Disposer.dispose(environment)
-}
-
-fun checkSourceExistsAndVerifyModel(
- source: String,
- modelConfig: ModelConfig = ModelConfig(),
- verifier: (DocumentationModule) -> Unit
-) {
- require(File(source).exists()) {
- "Cannot find test data file $source"
- }
- verifyModel(
- ModelConfig(
- roots = arrayOf(contentRootFromPath(source)),
- withJdk = modelConfig.withJdk,
- withKotlinRuntime = modelConfig.withKotlinRuntime,
- format = modelConfig.format,
- includeNonPublic = modelConfig.includeNonPublic,
- sourceLinks = modelConfig.sourceLinks,
- analysisPlatform = modelConfig.analysisPlatform
- ),
-
- verifier = verifier
- )
-}
-
-fun verifyPackageMember(
- source: String,
- modelConfig: ModelConfig = ModelConfig(),
- verifier: (DocumentationNode) -> Unit
-) {
- checkSourceExistsAndVerifyModel(
- source,
- modelConfig = ModelConfig(
- withJdk = modelConfig.withJdk,
- withKotlinRuntime = modelConfig.withKotlinRuntime,
- analysisPlatform = modelConfig.analysisPlatform
- )
- ) { model ->
- val pkg = model.members.single()
- verifier(pkg.members.single())
- }
-}
-
-fun verifyJavaModel(
- source: String,
- modelConfig: ModelConfig = ModelConfig(),
- verifier: (DocumentationModule) -> Unit
-) {
- val tempDir = FileUtil.createTempDirectory("dokka", "")
- try {
- val sourceFile = File(source)
- FileUtil.copy(sourceFile, File(tempDir, sourceFile.name))
- verifyModel(
- ModelConfig(
- roots = arrayOf(JavaSourceRoot(tempDir, null)),
- withJdk = true,
- withKotlinRuntime = modelConfig.withKotlinRuntime,
- analysisPlatform = modelConfig.analysisPlatform
- ),
- verifier = verifier
- )
- } finally {
- FileUtil.delete(tempDir)
- }
-}
-
-fun verifyJavaPackageMember(
- source: String,
- modelConfig: ModelConfig = ModelConfig(),
- verifier: (DocumentationNode) -> Unit
-) {
- verifyJavaModel(source, modelConfig) { model ->
- val pkg = model.members.single()
- verifier(pkg.members.single())
- }
-}
-
-fun verifyOutput(
- modelConfig: ModelConfig = ModelConfig(),
- outputExtension: String,
- outputGenerator: (DocumentationModule, StringBuilder) -> Unit
-) {
- verifyModel(modelConfig) {
- verifyModelOutput(it, outputExtension, modelConfig.roots.first().path, outputGenerator)
- }
-}
-
-fun verifyOutput(
- path: String,
- outputExtension: String,
- modelConfig: ModelConfig = ModelConfig(),
- outputGenerator: (DocumentationModule, StringBuilder) -> Unit
-) {
- verifyOutput(
- ModelConfig(
- roots = arrayOf(contentRootFromPath(path)) + modelConfig.roots,
- withJdk = modelConfig.withJdk,
- withKotlinRuntime = modelConfig.withKotlinRuntime,
- format = modelConfig.format,
- includeNonPublic = modelConfig.includeNonPublic,
- analysisPlatform = modelConfig.analysisPlatform,
- noStdlibLink = modelConfig.noStdlibLink,
- collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries
- ),
- outputExtension,
- outputGenerator
- )
-}
-
-fun verifyModelOutput(
- it: DocumentationModule,
- outputExtension: String,
- sourcePath: String,
- outputGenerator: (DocumentationModule, StringBuilder) -> Unit
-) {
- val output = StringBuilder()
- outputGenerator(it, output)
- val ext = outputExtension.removePrefix(".")
- val expectedFile = File(sourcePath.replaceAfterLast(".", ext, sourcePath + "." + ext))
- assertEqualsIgnoringSeparators(expectedFile, output.toString())
-}
-
-fun verifyJavaOutput(
- path: String,
- outputExtension: String,
- modelConfig: ModelConfig = ModelConfig(),
- outputGenerator: (DocumentationModule, StringBuilder) -> Unit
-) {
- verifyJavaModel(path, modelConfig) { model ->
- verifyModelOutput(model, outputExtension, path, outputGenerator)
- }
-}
-
-fun assertEqualsIgnoringSeparators(expectedFile: File, output: String) {
- if (!expectedFile.exists()) expectedFile.createNewFile()
- val expectedText = expectedFile.readText().replace("\r\n", "\n")
- val actualText = output.replace("\r\n", "\n")
-
- if (expectedText != actualText)
- throw FileComparisonFailure("", expectedText, actualText, expectedFile.canonicalPath)
-}
-
-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 -> {
- if (node.language.isNotBlank())
- appendln("[code lang=${node.language}]")
- else
- appendln("[code]")
- appendChildren(node)
- appendln()
- appendln("[/code]")
- }
- is ContentNodeLink -> {
- append("[")
- appendChildren(node)
- append(" -> ")
- append(node.node.toString())
- append("]")
- }
- is ContentBlock -> {
- appendChildren(node)
- }
- is NodeRenderContent -> {
- append("render(")
- append(node.node)
- append(",")
- append(node.mode)
- append(")")
- }
- is ContentSymbol -> {
- append(node.text)
- }
- 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()
-}
-
-val ContentRoot.path: String
- get() = when (this) {
- is KotlinSourceRoot -> path
- is JavaSourceRoot -> file.path
- else -> throw UnsupportedOperationException()
- }
diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt
deleted file mode 100644
index ef9e815d..00000000
--- a/core/src/test/kotlin/format/FileGeneratorTestCase.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.junit.Before
-import org.junit.Rule
-import org.junit.rules.TemporaryFolder
-
-
-abstract class FileGeneratorTestCase {
- abstract val formatService: FormatService
-
- @get:Rule
- var folder = TemporaryFolder()
-
- val fileGenerator = FileGenerator(folder.apply { create() }.root)
-
- @Before
- fun bindGenerator() {
- fileGenerator.formatService = formatService
- }
-
- fun buildPagesAndReadInto(nodes: List<DocumentationNode>, sb: StringBuilder) = with(fileGenerator) {
- buildPages(nodes)
- val byLocations = nodes.groupBy { location(it) }
- byLocations.forEach { (loc, _) ->
- if (byLocations.size > 1) {
- if (sb.isNotBlank() && !sb.endsWith('\n')) {
- sb.appendln()
- }
- sb.appendln("<!-- File: ${loc.file.relativeTo(root).toUnixString()} -->")
- }
- sb.append(loc.file.readText())
- }
- }
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/GFMFormatTest.kt b/core/src/test/kotlin/format/GFMFormatTest.kt
deleted file mode 100644
index 60de7d29..00000000
--- a/core/src/test/kotlin/format/GFMFormatTest.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.GFMFormatService
-import org.jetbrains.dokka.KotlinLanguageService
-import org.jetbrains.dokka.Platform
-import org.junit.Test
-
-abstract class BaseGFMFormatTest(val analysisPlatform: Platform) : FileGeneratorTestCase() {
- override val formatService = GFMFormatService(fileGenerator, KotlinLanguageService(), listOf())
- private val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
-
-
- @Test
- fun sample() {
- verifyGFMNodeByName("sample", "Foo", defaultModelConfig)
- }
-
- @Test
- fun listInTableCell() {
- verifyGFMNodeByName("listInTableCell", "Foo", defaultModelConfig)
- }
-
- private fun verifyGFMNodeByName(fileName: String, name: String, modelConfig: ModelConfig) {
- verifyOutput("testdata/format/gfm/$fileName.kt", ".md", modelConfig) { model, output ->
- buildPagesAndReadInto(
- model.members.single().members.filter { it.name == name },
- output
- )
- }
- }
-}
-
-
-class JsGFMFormatTest : BaseGFMFormatTest(Platform.js)
-class JvmGFMFormatTest : BaseGFMFormatTest(Platform.jvm)
-class CommonGFMFormatTest : BaseGFMFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
deleted file mode 100644
index 60e29006..00000000
--- a/core/src/test/kotlin/format/HtmlFormatTest.kt
+++ /dev/null
@@ -1,192 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
-import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
-import org.junit.Test
-import java.io.File
-
-abstract class BaseHtmlFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
- protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- override val formatService = HtmlFormatService(fileGenerator, KotlinLanguageService(), HtmlTemplateService.default(), listOf())
-
- @Test fun classWithCompanionObject() {
- verifyHtmlNode("classWithCompanionObject", defaultModelConfig)
- }
-
- @Test fun htmlEscaping() {
- verifyHtmlNode("htmlEscaping", defaultModelConfig)
- }
-
- @Test fun overloads() {
- verifyHtmlNodes("overloads", defaultModelConfig) { model -> model.members }
- }
-
- @Test fun overloadsWithDescription() {
- verifyHtmlNode("overloadsWithDescription", defaultModelConfig)
- }
-
- @Test fun overloadsWithDifferentDescriptions() {
- verifyHtmlNode("overloadsWithDifferentDescriptions", defaultModelConfig)
- }
-
- @Test fun deprecated() {
- verifyOutput("testdata/format/deprecated.kt", ".package.html", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- verifyOutput("testdata/format/deprecated.kt", ".class.html", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test fun brokenLink() {
- verifyHtmlNode("brokenLink", defaultModelConfig)
- }
-
- @Test fun codeSpan() {
- verifyHtmlNode("codeSpan", defaultModelConfig)
- }
-
- @Test fun parenthesis() {
- verifyHtmlNode("parenthesis", defaultModelConfig)
- }
-
- @Test fun bracket() {
- verifyHtmlNode("bracket", defaultModelConfig)
- }
-
- @Test fun see() {
- verifyHtmlNode("see", defaultModelConfig)
- }
-
- @Test fun tripleBackticks() {
- verifyHtmlNode("tripleBackticks", defaultModelConfig)
- }
-
- @Test fun typeLink() {
- verifyHtmlNodes("typeLink", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun parameterAnchor() {
- verifyHtmlNode("parameterAnchor", defaultModelConfig)
- }
-
- @Test fun codeBlock() {
- verifyHtmlNode("codeBlock", defaultModelConfig)
- }
- @Test fun orderedList() {
- verifyHtmlNodes("orderedList", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun linkWithLabel() {
- verifyHtmlNodes("linkWithLabel", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun entity() {
- verifyHtmlNodes("entity", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun uninterpretedEmphasisCharacters() {
- verifyHtmlNode("uninterpretedEmphasisCharacters", defaultModelConfig)
- }
-
- @Test fun markdownInLinks() {
- verifyHtmlNode("markdownInLinks", defaultModelConfig)
- }
-
- @Test fun returnWithLink() {
- verifyHtmlNode("returnWithLink", defaultModelConfig)
- }
-
- @Test fun linkWithStarProjection() {
- verifyHtmlNode("linkWithStarProjection", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun functionalTypeWithNamedParameters() {
- verifyHtmlNode("functionalTypeWithNamedParameters", defaultModelConfig)
- }
-
- @Test fun sinceKotlin() {
- verifyHtmlNode("sinceKotlin", defaultModelConfig)
- }
-
- @Test fun blankLineInsideCodeBlock() {
- verifyHtmlNode("blankLineInsideCodeBlock", defaultModelConfig)
- }
-
- @Test fun indentedCodeBlock() {
- verifyHtmlNode("indentedCodeBlock", defaultModelConfig)
- }
-
- private fun verifyHtmlNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
- verifyHtmlNodes(fileName, modelConfig) { model -> model.members.single().members }
- }
-
- private fun verifyHtmlNodes(fileName: String,
- modelConfig: ModelConfig = ModelConfig(),
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyOutput("testdata/format/$fileName.kt", ".html", modelConfig) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-
- protected fun verifyJavaHtmlNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
- verifyJavaHtmlNodes(fileName, modelConfig) { model -> model.members.single().members }
- }
-
- protected fun verifyJavaHtmlNodes(fileName: String,
- modelConfig: ModelConfig = ModelConfig(),
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyJavaOutput("testdata/format/$fileName.java", ".html", modelConfig) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-}
-
-class JSHtmlFormatTest: BaseHtmlFormatTest(Platform.js)
-
-class JVMHtmlFormatTest: BaseHtmlFormatTest(Platform.jvm) {
- @Test
- fun javaSeeTag() {
- verifyJavaHtmlNode("javaSeeTag", defaultModelConfig)
- }
-
- @Test fun javaDeprecated() {
- verifyJavaHtmlNodes("javaDeprecated", defaultModelConfig) { model ->
- model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }
- }
- }
-
- @Test fun crossLanguageKotlinExtendsJava() {
- verifyOutput(
- ModelConfig(
- roots = arrayOf(
- KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt", false),
- JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)
- ),
- analysisPlatform = analysisPlatform
- ), ".html") { model, output ->
- buildPagesAndReadInto(
- model.members.single().members.filter { it.name == "Bar" },
- output
- )
- }
- }
-
- @Test fun javaLinkTag() {
- verifyJavaHtmlNode("javaLinkTag", defaultModelConfig)
- }
-
- @Test fun javaLinkTagWithLabel() {
- verifyJavaHtmlNode("javaLinkTagWithLabel", defaultModelConfig)
- }
-
- @Test fun javaSupertypeLink() {
- verifyJavaHtmlNodes("JavaSupertype", defaultModelConfig) { model ->
- model.members.single().members.single { it.name == "JavaSupertype" }.members.filter { it.name == "Bar" }
- }
- }
-
-}
-
-class CommonHtmlFormatTest: BaseHtmlFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
deleted file mode 100644
index ebab5f36..00000000
--- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Generation.DocumentationMerger
-import org.junit.Test
-
-abstract class BaseKotlinWebSiteHtmlFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
- val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- override val formatService = KotlinWebsiteHtmlFormatService(fileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService)
-
- @Test fun dropImport() {
- verifyKWSNodeByName("dropImport", "foo", defaultModelConfig)
- }
-
- @Test fun sample() {
- verifyKWSNodeByName("sample", "foo", defaultModelConfig)
- }
-
- @Test fun sampleWithAsserts() {
- verifyKWSNodeByName("sampleWithAsserts", "a", defaultModelConfig)
- }
-
- @Test fun newLinesInSamples() {
- verifyKWSNodeByName("newLinesInSamples", "foo", defaultModelConfig)
- }
-
- @Test fun newLinesInImportList() {
- verifyKWSNodeByName("newLinesInImportList", "foo", defaultModelConfig)
- }
-
- @Test fun returnTag() {
- verifyKWSNodeByName("returnTag", "indexOf", defaultModelConfig)
- }
-
- @Test fun overloadGroup() {
- verifyKWSNodeByName("overloadGroup", "magic", defaultModelConfig)
- }
-
- @Test fun dataTags() {
- val module = buildMultiplePlatforms("dataTags")
- verifyMultiplatformPackage(module, "dataTags")
- }
-
- @Test fun dataTagsInGroupNode() {
- val path = "dataTagsInGroupNode"
- val module = buildMultiplePlatforms(path)
- verifyModelOutput(module, ".html", "testdata/format/website-html/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(
- listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }),
- output
- )
- }
- verifyMultiplatformPackage(module, path)
- }
-
- private fun verifyKWSNodeByName(fileName: String, name: String, modelConfig: ModelConfig) {
- verifyOutput(
- "testdata/format/website-html/$fileName.kt",
- ".html",
- ModelConfig(analysisPlatform = modelConfig.analysisPlatform, format = "kotlin-website-html")
- ) { model, output ->
- buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output)
- }
- }
-
- private fun buildMultiplePlatforms(path: String): DocumentationModule {
- val moduleName = "test"
- val passConfiguration = PassConfigurationImpl(
- noStdlibLink = true,
- noJdkLink = true,
- languageVersion = null,
- apiVersion = null
- )
-
- val dokkaConfiguration = DokkaConfigurationImpl(
- outputDir = "",
- format = "kotlin-website-html",
- generateIndexPages = false,
- passesConfigurations = listOf(
- passConfiguration
- )
-
- )
-
- val module1 = DocumentationModule(moduleName)
- appendDocumentation(
- module1, dokkaConfiguration, passConfiguration, ModelConfig(
- roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jvm.kt")),
- defaultPlatforms = listOf("JVM")
- )
- )
-
- val module2 = DocumentationModule(moduleName)
- appendDocumentation(
- module2, dokkaConfiguration, passConfiguration, ModelConfig(
- roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jre7.kt")),
- defaultPlatforms = listOf("JVM", "JRE7")
- )
- )
-
- val module3 = DocumentationModule(moduleName)
- appendDocumentation(
- module3, dokkaConfiguration, passConfiguration, ModelConfig(
- roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/js.kt")),
- defaultPlatforms = listOf("JS")
- )
- )
-
- return DocumentationMerger(listOf(module1, module2, module3), DokkaConsoleLogger).merge()
- }
-
- private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) {
- verifyModelOutput(module, ".package.html", "testdata/format/website-html/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- }
-
-}
-class JsKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.js)
-
-class JvmKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.jvm)
-
-class CommonKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
deleted file mode 100644
index 4984e1d5..00000000
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ /dev/null
@@ -1,615 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Generation.DocumentationMerger
-import org.junit.Test
-
-abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
- override val formatService = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf())
-
- protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
-
- @Test fun emptyDescription() {
- verifyMarkdownNode("emptyDescription", defaultModelConfig)
- }
-
- @Test fun classWithCompanionObject() {
- verifyMarkdownNode("classWithCompanionObject", defaultModelConfig)
- }
-
- @Test fun annotations() {
- verifyMarkdownNode("annotations", defaultModelConfig)
- }
-
- @Test fun annotationClass() {
- verifyMarkdownNode("annotationClass", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- verifyMarkdownPackage("annotationClass", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun enumClass() {
- verifyOutput("testdata/format/enumClass.kt", ".md", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- verifyOutput("testdata/format/enumClass.kt", ".value.md", defaultModelConfig) { model, output ->
- val enumClassNode = model.members.single().members[0]
- buildPagesAndReadInto(
- enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" },
- output
- )
- }
- }
-
- @Test fun varargsFunction() {
- verifyMarkdownNode("varargsFunction", defaultModelConfig)
- }
-
- @Test fun overridingFunction() {
- verifyMarkdownNodes("overridingFunction", defaultModelConfig) { model->
- val classMembers = model.members.single().members.first { it.name == "D" }.members
- classMembers.filter { it.name == "f" }
- }
- }
-
- @Test fun propertyVar() {
- verifyMarkdownNode("propertyVar", defaultModelConfig)
- }
-
- @Test fun functionWithDefaultParameter() {
- verifyMarkdownNode("functionWithDefaultParameter", defaultModelConfig)
- }
-
- @Test fun accessor() {
- verifyMarkdownNodes("accessor", defaultModelConfig) { model ->
- model.members.single().members.first { it.name == "C" }.members.filter { it.name == "x" }
- }
- }
-
- @Test fun paramTag() {
- verifyMarkdownNode("paramTag", defaultModelConfig)
- }
-
- @Test fun throwsTag() {
- verifyMarkdownNode("throwsTag", defaultModelConfig)
- }
-
- @Test fun typeParameterBounds() {
- verifyMarkdownNode("typeParameterBounds", defaultModelConfig)
- }
-
- @Test fun typeParameterVariance() {
- verifyMarkdownNode("typeParameterVariance", defaultModelConfig)
- }
-
- @Test fun typeProjectionVariance() {
- verifyMarkdownNode("typeProjectionVariance", defaultModelConfig)
- }
-
- @Test fun codeBlockNoHtmlEscape() {
- verifyMarkdownNodeByName("codeBlockNoHtmlEscape", "hackTheArithmetic", defaultModelConfig)
- }
-
- @Test fun companionObjectExtension() {
- verifyMarkdownNodeByName("companionObjectExtension", "Foo", defaultModelConfig)
- }
-
- @Test fun starProjection() {
- verifyMarkdownNode("starProjection", defaultModelConfig)
- }
-
- @Test fun extensionFunctionParameter() {
- verifyMarkdownNode("extensionFunctionParameter", defaultModelConfig)
- }
-
- @Test fun summarizeSignatures() {
- verifyMarkdownNodes("summarizeSignatures", defaultModelConfig) { model -> model.members }
- }
-
- @Test fun reifiedTypeParameter() {
- verifyMarkdownNode("reifiedTypeParameter", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun suspendInlineFunctionOrder() {
- verifyMarkdownNode("suspendInlineFunction", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun inlineSuspendFunctionOrderChanged() {
- verifyMarkdownNode("inlineSuspendFunction", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun annotatedTypeParameter() {
- verifyMarkdownNode("annotatedTypeParameter", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun inheritedMembers() {
- verifyMarkdownNodeByName("inheritedMembers", "Bar", defaultModelConfig)
- }
-
- @Test fun inheritedExtensions() {
- verifyMarkdownNodeByName("inheritedExtensions", "Bar", defaultModelConfig)
- }
-
- @Test fun genericInheritedExtensions() {
- verifyMarkdownNodeByName("genericInheritedExtensions", "Bar", defaultModelConfig)
- }
-
- @Test fun arrayAverage() {
- verifyMarkdownNodeByName("arrayAverage", "XArray", defaultModelConfig)
- }
-
- @Test fun multipleTypeParameterConstraints() {
- verifyMarkdownNode("multipleTypeParameterConstraints", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun inheritedCompanionObjectProperties() {
- verifyMarkdownNodeByName("inheritedCompanionObjectProperties", "C", defaultModelConfig)
- }
-
- @Test fun shadowedExtensionFunctions() {
- verifyMarkdownNodeByName("shadowedExtensionFunctions", "Bar", defaultModelConfig)
- }
-
- @Test fun inapplicableExtensionFunctions() {
- verifyMarkdownNodeByName("inapplicableExtensionFunctions", "Bar", defaultModelConfig)
- }
-
- @Test fun receiverParameterTypeBound() {
- verifyMarkdownNodeByName("receiverParameterTypeBound", "Foo", defaultModelConfig)
- }
-
- @Test fun extensionWithDocumentedReceiver() {
- verifyMarkdownNodes("extensionWithDocumentedReceiver", defaultModelConfig) { model ->
- model.members.single().members.single().members.filter { it.name == "fn" }
- }
- }
-
- @Test fun codeBlock() {
- verifyMarkdownNode("codeBlock", defaultModelConfig)
- }
-
- @Test fun exclInCodeBlock() {
- verifyMarkdownNodeByName("exclInCodeBlock", "foo", defaultModelConfig)
- }
-
- @Test fun backtickInCodeBlock() {
- verifyMarkdownNodeByName("backtickInCodeBlock", "foo", defaultModelConfig)
- }
-
- @Test fun qualifiedNameLink() {
- verifyMarkdownNodeByName("qualifiedNameLink", "foo",
- ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun functionalTypeWithNamedParameters() {
- verifyMarkdownNode("functionalTypeWithNamedParameters", defaultModelConfig)
- }
-
- @Test fun typeAliases() {
- verifyMarkdownNode("typeAliases", defaultModelConfig)
- verifyMarkdownPackage("typeAliases", defaultModelConfig)
- }
-
- @Test fun sampleByShortName() {
- verifyMarkdownNode("sampleByShortName", defaultModelConfig)
- }
-
-
- @Test fun suspendParam() {
- verifyMarkdownNode("suspendParam", defaultModelConfig)
- verifyMarkdownPackage("suspendParam", defaultModelConfig)
- }
-
- @Test fun sinceKotlin() {
- verifyMarkdownNode("sinceKotlin", defaultModelConfig)
- verifyMarkdownPackage("sinceKotlin", defaultModelConfig)
- }
-
- @Test fun sinceKotlinWide() {
- verifyMarkdownPackage("sinceKotlinWide", defaultModelConfig)
- }
-
- @Test fun dynamicType() {
- verifyMarkdownNode("dynamicType", defaultModelConfig)
- }
-
- @Test fun dynamicExtension() {
- verifyMarkdownNodes("dynamicExtension", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Foo" } }
- }
-
- @Test fun memberExtension() {
- verifyMarkdownNodes("memberExtension", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Foo" } }
- }
-
- @Test fun renderFunctionalTypeInParenthesisWhenItIsReceiver() {
- verifyMarkdownNode("renderFunctionalTypeInParenthesisWhenItIsReceiver", defaultModelConfig)
- }
-
- @Test fun multiplePlatforms() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/simple"), "multiplatform/simple")
- }
-
- @Test fun multiplePlatformsMerge() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/merge"), "multiplatform/merge")
- }
-
- @Test fun multiplePlatformsMergeMembers() {
- val module = buildMultiplePlatforms("multiplatform/mergeMembers")
- verifyModelOutput(module, ".md", "testdata/format/multiplatform/mergeMembers/foo.kt") { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test fun multiplePlatformsOmitRedundant() {
- val module = buildMultiplePlatforms("multiplatform/omitRedundant")
- verifyModelOutput(module, ".md", "testdata/format/multiplatform/omitRedundant/foo.kt") { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test fun multiplePlatformsImplied() {
- val module = buildMultiplePlatforms("multiplatform/implied")
- verifyModelOutput(module, ".md", "testdata/format/multiplatform/implied/foo.kt") { model, output ->
- val service = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf("JVM", "JS"))
- fileGenerator.formatService = service
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test fun packagePlatformsWithExtExtensions() {
- val path = "multiplatform/packagePlatformsWithExtExtensions"
- val module = DocumentationModule("test")
- val passConfiguration = PassConfigurationImpl(
- noStdlibLink = true,
- noJdkLink = true,
- languageVersion = null,
- apiVersion = null
- )
-
- val dokkaConfiguration = DokkaConfigurationImpl(
- outputDir = "",
- format = "html",
- generateIndexPages = false,
- passesConfigurations = listOf(
- passConfiguration
- )
- )
-
- appendDocumentation(module, dokkaConfiguration, passConfiguration, ModelConfig(
- roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")),
- defaultPlatforms = listOf("JVM"),
- withKotlinRuntime = true,
- analysisPlatform = analysisPlatform
- )
- )
- verifyMultiplatformIndex(module, path)
- verifyMultiplatformPackage(module, path)
- }
-
- @Test fun multiplePlatformsPackagePlatformFromMembers() {
- val path = "multiplatform/packagePlatformsFromMembers"
- val module = buildMultiplePlatforms(path)
- verifyMultiplatformIndex(module, path)
- verifyMultiplatformPackage(module, path)
- }
-
- @Test fun multiplePlatformsGroupNode() {
- val path = "multiplatform/groupNode"
- val module = buildMultiplePlatforms(path)
- verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(
- listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }),
- output
- )
- }
- verifyMultiplatformPackage(module, path)
- }
-
- @Test fun multiplePlatformsBreadcrumbsInMemberOfMemberOfGroupNode() {
- val path = "multiplatform/breadcrumbsInMemberOfMemberOfGroupNode"
- val module = buildMultiplePlatforms(path)
- verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(
- listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Function)),
- output
- )
- }
- }
-
- @Test fun linksInEmphasis() {
- verifyMarkdownNode("linksInEmphasis", defaultModelConfig)
- }
-
- @Test fun linksInStrong() {
- verifyMarkdownNode("linksInStrong", defaultModelConfig)
- }
-
- @Test fun linksInHeaders() {
- verifyMarkdownNode("linksInHeaders", defaultModelConfig)
- }
-
- @Test fun tokensInEmphasis() {
- verifyMarkdownNode("tokensInEmphasis", defaultModelConfig)
- }
-
- @Test fun tokensInStrong() {
- verifyMarkdownNode("tokensInStrong", defaultModelConfig)
- }
-
- @Test fun tokensInHeaders() {
- verifyMarkdownNode("tokensInHeaders", defaultModelConfig)
- }
-
- @Test fun unorderedLists() {
- verifyMarkdownNode("unorderedLists", defaultModelConfig)
- }
-
- @Test fun nestedLists() {
- verifyMarkdownNode("nestedLists", defaultModelConfig)
- }
-
- @Test fun referenceLink() {
- verifyMarkdownNode("referenceLink", defaultModelConfig)
- }
-
- @Test fun externalReferenceLink() {
- verifyMarkdownNode("externalReferenceLink", defaultModelConfig)
- }
-
- @Test fun newlineInTableCell() {
- verifyMarkdownPackage("newlineInTableCell", defaultModelConfig)
- }
-
- @Test fun indentedCodeBlock() {
- verifyMarkdownNode("indentedCodeBlock", defaultModelConfig)
- }
-
- @Test fun receiverReference() {
- verifyMarkdownNode("receiverReference", defaultModelConfig)
- }
-
- @Test fun extensionScope() {
- verifyMarkdownNodeByName("extensionScope", "test", defaultModelConfig)
- }
-
- @Test fun typeParameterReference() {
- verifyMarkdownNode("typeParameterReference", defaultModelConfig)
- }
-
- @Test fun notPublishedTypeAliasAutoExpansion() {
- verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", ModelConfig(
- analysisPlatform = analysisPlatform,
- includeNonPublic = false
- ))
- }
-
- @Test fun companionImplements() {
- verifyMarkdownNodeByName("companionImplements", "Foo", defaultModelConfig)
- }
-
-
- private fun buildMultiplePlatforms(path: String): DocumentationModule {
- val moduleName = "test"
- val passConfiguration = PassConfigurationImpl(
- noStdlibLink = true,
- noJdkLink = true,
- languageVersion = null,
- apiVersion = null
- )
- val dokkaConfiguration = DokkaConfigurationImpl(
- outputDir = "",
- format = "html",
- generateIndexPages = false,
- passesConfigurations = listOf(
- passConfiguration
- )
-
- )
- val module1 = DocumentationModule(moduleName)
- appendDocumentation(
- module1, dokkaConfiguration, passConfiguration, ModelConfig(
- roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")),
- defaultPlatforms = listOf("JVM"),
- analysisPlatform = Platform.jvm
- )
- )
-
- val module2 = DocumentationModule(moduleName)
- appendDocumentation(
- module2, dokkaConfiguration, passConfiguration, ModelConfig(
- roots = arrayOf(contentRootFromPath("testdata/format/$path/js.kt")),
- defaultPlatforms = listOf("JS"),
- analysisPlatform = Platform.js
- )
- )
-
- return DocumentationMerger(listOf(module1, module2), DokkaConsoleLogger).merge()
- }
-
- private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) {
- verifyModelOutput(module, ".package.md", "testdata/format/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- }
-
- private fun verifyMultiplatformIndex(module: DocumentationModule, path: String) {
- verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.index.kt") {
- model, output ->
- val service = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf())
- fileGenerator.formatService = service
- buildPagesAndReadInto(listOf(model), output)
- }
- }
-
- @Test fun blankLineInsideCodeBlock() {
- verifyMarkdownNode("blankLineInsideCodeBlock", defaultModelConfig)
- }
-
- protected fun verifyMarkdownPackage(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
- verifyOutput("testdata/format/$fileName.kt", ".package.md", modelConfig) { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- }
-
- protected fun verifyMarkdownNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
- verifyMarkdownNodes(fileName, modelConfig) { model -> model.members.single().members }
- }
-
- protected fun verifyMarkdownNodes(
- fileName: String,
- modelConfig: ModelConfig = ModelConfig(),
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>
- ) {
- verifyOutput(
- "testdata/format/$fileName.kt",
- ".md",
- modelConfig
- ) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-
- protected fun verifyJavaMarkdownNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
- verifyJavaMarkdownNodes(fileName, modelConfig) { model -> model.members.single().members }
- }
-
- protected fun verifyJavaMarkdownNodes(fileName: String, modelConfig: ModelConfig = ModelConfig(), nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyJavaOutput("testdata/format/$fileName.java", ".md", modelConfig) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-
- protected fun verifyMarkdownNodeByName(
- fileName: String,
- name: String,
- modelConfig: ModelConfig = ModelConfig()
- ) {
- verifyMarkdownNodes(fileName, modelConfig) { model->
- val nodesWithName = model.members.single().members.filter { it.name == name }
- if (nodesWithName.isEmpty()) {
- throw IllegalArgumentException("Found no nodes named $name")
- }
- nodesWithName
- }
- }
-
- @Test fun nullableTypeParameterFunction() {
- verifyMarkdownNode("nullableTypeParameterFunction", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-}
-
-class JSMarkdownFormatTest: BaseMarkdownFormatTest(Platform.js)
-
-class JVMMarkdownFormatTest: BaseMarkdownFormatTest(Platform.jvm) {
-
- @Test
- fun enumRef() {
- verifyMarkdownNode("enumRef", defaultModelConfig)
- }
-
- @Test
- fun javaCodeLiteralTags() {
- verifyJavaMarkdownNode("javaCodeLiteralTags", defaultModelConfig)
- }
-
- @Test
- fun nullability() {
- verifyMarkdownNode("nullability", defaultModelConfig)
- }
-
- @Test
- fun exceptionClass() {
- verifyMarkdownNode(
- "exceptionClass", ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- )
- verifyMarkdownPackage(
- "exceptionClass", ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- )
- }
-
- @Test
- fun operatorOverloading() {
- verifyMarkdownNodes("operatorOverloading", defaultModelConfig) { model->
- model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }
- }
- }
-
- @Test
- fun extensions() {
- verifyOutput("testdata/format/extensions.kt", ".package.md", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- verifyOutput("testdata/format/extensions.kt", ".class.md", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test
- fun summarizeSignaturesProperty() {
- verifyMarkdownNodes("summarizeSignaturesProperty", defaultModelConfig) { model -> model.members }
- }
-
- @Test
- fun javaSpaceInAuthor() {
- verifyJavaMarkdownNode("javaSpaceInAuthor", defaultModelConfig)
- }
-
- @Test
- fun javaCodeInParam() {
- verifyJavaMarkdownNodes("javaCodeInParam", defaultModelConfig) {
- selectNodes(it) {
- subgraphOf(RefKind.Member)
- withKind(NodeKind.Function)
- }
- }
- }
-
- @Test
- fun annotationParams() {
- verifyMarkdownNode("annotationParams", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun inheritedLink() {
- val filePath = "testdata/format/inheritedLink"
- verifyOutput(
- filePath,
- ".md",
- ModelConfig(
- roots = arrayOf(
- contentRootFromPath("$filePath.kt"),
- contentRootFromPath("$filePath.1.kt")
- ),
- withJdk = true,
- withKotlinRuntime = true,
- includeNonPublic = false,
- analysisPlatform = analysisPlatform
-
- )
- ) { model, output ->
- buildPagesAndReadInto(model.members.single { it.name == "p2" }.members.single().members, output)
- }
- }
-
- @Test
- fun javadocOrderedList() {
- verifyJavaMarkdownNodes("javadocOrderedList", defaultModelConfig) { model ->
- model.members.single().members.filter { it.name == "Bar" }
- }
- }
-
- @Test
- fun jdkLinks() {
- verifyMarkdownNode("jdkLinks", ModelConfig(withKotlinRuntime = true, analysisPlatform = analysisPlatform))
- }
-
- @Test
- fun javadocHtml() {
- verifyJavaMarkdownNode("javadocHtml", defaultModelConfig)
- }
-}
-
-class CommonMarkdownFormatTest: BaseMarkdownFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/PackageDocsTest.kt b/core/src/test/kotlin/format/PackageDocsTest.kt
deleted file mode 100644
index 3ff5f123..00000000
--- a/core/src/test/kotlin/format/PackageDocsTest.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-import com.intellij.openapi.Disposable
-import com.intellij.openapi.util.Disposer
-import com.nhaarman.mockito_kotlin.any
-import com.nhaarman.mockito_kotlin.doAnswer
-import com.nhaarman.mockito_kotlin.eq
-import com.nhaarman.mockito_kotlin.mock
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators
-import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
-import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
-import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment
-import org.jetbrains.kotlin.config.CompilerConfiguration
-import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
-import org.junit.After
-import org.junit.Assert.assertEquals
-import org.junit.Before
-import org.junit.Test
-import java.io.File
-
-class PackageDocsTest {
-
- private lateinit var testDisposable: Disposable
-
- @Before
- fun setup() {
- testDisposable = Disposer.newDisposable()
- }
-
- @After
- fun cleanup() {
- Disposer.dispose(testDisposable)
- }
-
- fun createPackageDocs(linkResolver: DeclarationLinkResolver?): PackageDocs {
- val environment = KotlinCoreEnvironment.createForTests(testDisposable, CompilerConfiguration.EMPTY, EnvironmentConfigFiles.JVM_CONFIG_FILES)
- return PackageDocs(linkResolver, DokkaConsoleLogger, environment, mock(), mock())
- }
-
- @Test fun verifyParse() {
-
- val docs = createPackageDocs(null)
- docs.parse("testdata/packagedocs/stdlib.md", emptyList())
- val packageContent = docs.packageContent["kotlin"]!!
- val block = (packageContent.children.single() as ContentBlock).children.first() as ContentText
- assertEquals("Core functions and types", block.text)
- }
-
- @Test fun testReferenceLinksInPackageDocs() {
- val mockLinkResolver = mock<DeclarationLinkResolver> {
- val exampleCom = "https://example.com"
- on { tryResolveContentLink(any(), eq(exampleCom)) } doAnswer { ContentExternalLink(exampleCom) }
- }
-
- val mockPackageDescriptor = mock<PackageFragmentDescriptor> {}
-
- val docs = createPackageDocs(mockLinkResolver)
- docs.parse("testdata/packagedocs/referenceLinks.md", listOf(mockPackageDescriptor))
-
- checkMarkdownOutput(docs, "testdata/packagedocs/referenceLinks")
- }
-
- fun checkMarkdownOutput(docs: PackageDocs, expectedFilePrefix: String) {
-
- val generator = FileGenerator(File(""))
-
- val out = StringBuilder()
- val outputBuilder = MarkdownOutputBuilder(
- out,
- FileLocation(generator.root),
- generator,
- KotlinLanguageService(),
- ".md",
- emptyList()
- )
- fun checkOutput(content: Content, filePostfix: String) {
- outputBuilder.appendContent(content)
- val expectedFile = File(expectedFilePrefix + filePostfix)
- assertEqualsIgnoringSeparators(expectedFile, out.toString())
- out.setLength(0)
- }
-
- checkOutput(docs.moduleContent, ".module.md")
-
- docs.packageContent.forEach {
- (name, content) ->
- checkOutput(content, ".$name.md")
- }
-
- }
-}
diff --git a/core/src/test/kotlin/issues/IssuesTest.kt b/core/src/test/kotlin/issues/IssuesTest.kt
deleted file mode 100644
index da5acd6e..00000000
--- a/core/src/test/kotlin/issues/IssuesTest.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package issues
-
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
-import org.junit.Test
-import kotlin.test.assertEquals
-
-abstract class BaseIssuesTest(val analysisPlatform: Platform) {
- val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
-
- @Test
- fun errorClasses() {
- checkSourceExistsAndVerifyModel("testdata/issues/errorClasses.kt",
- modelConfig = ModelConfig(analysisPlatform = analysisPlatform, withJdk = true, withKotlinRuntime = true)) { model ->
- val cls = model.members.single().members.single()
-
- fun DocumentationNode.returnType() = this.details.find { it.kind == NodeKind.Type }?.name
- assertEquals("Test", cls.members[1].returnType())
- assertEquals("Test", cls.members[2].returnType())
- assertEquals("Test", cls.members[3].returnType())
- assertEquals("List", cls.members[4].returnType())
- assertEquals("String", cls.members[5].returnType())
- assertEquals("String", cls.members[6].returnType())
- assertEquals("String", cls.members[7].returnType())
- }
- }
-}
-
-class JSIssuesTest: BaseIssuesTest(Platform.js)
-class JVMIssuesTest: BaseIssuesTest(Platform.jvm)
-class CommonIssuesTest: BaseIssuesTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
deleted file mode 100644
index 1c4dd258..00000000
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ /dev/null
@@ -1,333 +0,0 @@
-package org.jetbrains.dokka.javadoc
-
-import com.sun.javadoc.Tag
-import com.sun.javadoc.Type
-import org.jetbrains.dokka.DokkaConsoleLogger
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators
-import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
-import org.junit.Assert.*
-import org.junit.Test
-import java.lang.reflect.Modifier.*
-
-class JavadocTest {
- val defaultModelConfig = ModelConfig(analysisPlatform = Platform.jvm)
-
- @Test fun testTypes() {
- verifyJavadoc("testdata/javadoc/types.kt", ModelConfig(analysisPlatform = Platform.jvm, withJdk = true)) { doc ->
- val classDoc = doc.classNamed("foo.TypesKt")!!
- val method = classDoc.methods().find { it.name() == "foo" }!!
-
- val type = method.returnType()
- assertFalse(type.asClassDoc().isIncluded)
- assertEquals("java.lang.String", type.qualifiedTypeName())
- assertEquals("java.lang.String", type.asClassDoc().qualifiedName())
-
- val params = method.parameters()
- assertTrue(params[0].type().isPrimitive)
- assertFalse(params[1].type().asClassDoc().isIncluded)
- }
- }
-
- @Test fun testObject() {
- verifyJavadoc("testdata/javadoc/obj.kt", defaultModelConfig) { doc ->
- val classDoc = doc.classNamed("foo.O")
- assertNotNull(classDoc)
-
- val companionDoc = doc.classNamed("foo.O.Companion")
- assertNotNull(companionDoc)
-
- val pkgDoc = doc.packageNamed("foo")!!
- assertEquals(2, pkgDoc.allClasses().size)
- }
- }
-
- @Test fun testException() {
- verifyJavadoc(
- "testdata/javadoc/exception.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val classDoc = doc.classNamed("foo.MyException")!!
- val member = classDoc.methods().find { it.name() == "foo" }
- assertEquals(classDoc, member!!.containingClass())
- }
- }
-
- @Test fun testByteArray() {
- verifyJavadoc(
- "testdata/javadoc/bytearr.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val classDoc = doc.classNamed("foo.ByteArray")!!
- assertNotNull(classDoc.asClassDoc())
-
- val member = classDoc.methods().find { it.name() == "foo" }!!
- assertEquals("[]", member.returnType().dimension())
- }
- }
-
- @Test fun testStringArray() {
- verifyJavadoc(
- "testdata/javadoc/stringarr.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val classDoc = doc.classNamed("foo.Foo")!!
- assertNotNull(classDoc.asClassDoc())
-
- val member = classDoc.methods().find { it.name() == "main" }!!
- val paramType = member.parameters()[0].type()
- assertNull(paramType.asParameterizedType())
- assertEquals("String[]", paramType.typeName())
- assertEquals("String", paramType.asClassDoc().name())
- }
- }
-
- @Test fun testJvmName() {
- verifyJavadoc(
- "testdata/javadoc/jvmname.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val classDoc = doc.classNamed("foo.Apple")!!
- assertNotNull(classDoc.asClassDoc())
-
- val member = classDoc.methods().find { it.name() == "_tree" }
- assertNotNull(member)
- }
- }
-
- @Test fun testLinkWithParam() {
- verifyJavadoc(
- "testdata/javadoc/paramlink.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val classDoc = doc.classNamed("demo.Apple")!!
- assertNotNull(classDoc.asClassDoc())
- val tags = classDoc.inlineTags().filterIsInstance<SeeTagAdapter>()
- assertEquals(2, tags.size)
- val linkTag = tags[1] as SeeMethodTagAdapter
- assertEquals("cutIntoPieces", linkTag.method.name())
- }
- }
-
- @Test fun testInternalVisibility() {
- verifyJavadoc(
- "testdata/javadoc/internal.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true, includeNonPublic = false)
- ) { doc ->
- val classDoc = doc.classNamed("foo.Person")!!
- val constructors = classDoc.constructors()
- assertEquals(1, constructors.size)
- assertEquals(1, constructors.single().parameters().size)
- }
- }
-
- @Test fun testSuppress() {
- verifyJavadoc(
- "testdata/javadoc/suppress.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- assertNull(doc.classNamed("Some"))
- assertNull(doc.classNamed("SomeAgain"))
- assertNull(doc.classNamed("Interface"))
- val classSame = doc.classNamed("Same")!!
- assertTrue(classSame.fields().isEmpty())
- assertTrue(classSame.methods().isEmpty())
- }
- }
-
- @Test fun testTypeAliases() {
- verifyJavadoc(
- "testdata/javadoc/typealiases.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- assertNull(doc.classNamed("B"))
- assertNull(doc.classNamed("D"))
-
- assertEquals("A", doc.classNamed("C")!!.superclass().name())
- val methodParamType = doc.classNamed("TypealiasesKt")!!.methods()
- .find { it.name() == "some" }!!.parameters().first()
- .type()
- assertEquals("kotlin.jvm.functions.Function1", methodParamType.qualifiedTypeName())
- assertEquals("? super A, C",
- methodParamType.asParameterizedType().typeArguments().joinToString(transform = Type::qualifiedTypeName)
- )
- }
- }
-
- @Test fun testKDocKeywordsOnMethod() {
- verifyJavadoc(
- "testdata/javadoc/kdocKeywordsOnMethod.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val method = doc.classNamed("KdocKeywordsOnMethodKt")!!.methods()[0]
- assertEquals("@return [ContentText(text=value of a)]", method.tags("return").first().text())
- assertEquals("@param a [ContentText(text=Some string)]", method.paramTags().first().text())
- assertEquals("@throws FireException [ContentText(text=in case of fire)]", method.throwsTags().first().text())
- }
- }
-
- @Test
- fun testBlankLineInsideCodeBlock() {
- verifyJavadoc(
- "testdata/javadoc/blankLineInsideCodeBlock.kt",
- ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
- ) { doc ->
- val method = doc.classNamed("BlankLineInsideCodeBlockKt")!!.methods()[0]
- val text = method.inlineTags().joinToString(separator = "", transform = Tag::text)
- assertEqualsIgnoringSeparators("""
- <p><code><pre>
- This is a test
- of Dokka's code blocks.
- Here is a blank line.
-
- The previous line was blank.
- </pre></code></p>
- """.trimIndent(), text)
- }
- }
-
- @Test
- fun testCompanionMethodReference() {
- verifyJavadoc("testdata/javadoc/companionMethodReference.kt", defaultModelConfig) { doc ->
- val classDoc = doc.classNamed("foo.TestClass")!!
- val tag = classDoc.inlineTags().filterIsInstance<SeeMethodTagAdapter>().first()
- assertEquals("TestClass.Companion", tag.referencedClassName())
- assertEquals("test", tag.referencedMemberName())
- }
- }
-
- @Test
- fun testVararg() {
- verifyJavadoc("testdata/javadoc/vararg.kt") { doc ->
- val classDoc = doc.classNamed("VarargKt")!!
- val methods = classDoc.methods()
- methods.single { it.name() == "vararg" }.let { method ->
- assertTrue(method.isVarArgs)
- assertEquals("int", method.parameters().last().typeName())
- }
- methods.single { it.name() == "varargInMiddle" }.let { method ->
- assertFalse(method.isVarArgs)
- assertEquals("int[]", method.parameters()[1].typeName())
- }
- }
- }
-
- @Test
- fun shouldHaveValidVisibilityModifiers() {
- verifyJavadoc("testdata/javadoc/visibilityModifiers.kt", ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)) { doc ->
- val classDoc = doc.classNamed("foo.Apple")!!
- val methods = classDoc.methods()
-
- val getName = methods[0]
- val setName = methods[1]
- val getWeight = methods[2]
- val setWeight = methods[3]
- val getRating = methods[4]
- val setRating = methods[5]
- val getCode = methods[6]
- val color = classDoc.fields()[3]
- val code = classDoc.fields()[4]
-
- assertTrue(getName.isProtected)
- assertEquals(PROTECTED, getName.modifierSpecifier())
- assertTrue(setName.isProtected)
- assertEquals(PROTECTED, setName.modifierSpecifier())
-
- assertTrue(getWeight.isPublic)
- assertEquals(PUBLIC, getWeight.modifierSpecifier())
- assertTrue(setWeight.isPublic)
- assertEquals(PUBLIC, setWeight.modifierSpecifier())
-
- assertTrue(getRating.isPublic)
- assertEquals(PUBLIC, getRating.modifierSpecifier())
- assertTrue(setRating.isPublic)
- assertEquals(PUBLIC, setRating.modifierSpecifier())
-
- assertTrue(getCode.isPublic)
- assertEquals(PUBLIC or STATIC, getCode.modifierSpecifier())
-
- assertEquals(methods.size, 7)
-
- assertTrue(color.isPrivate)
- assertEquals(PRIVATE, color.modifierSpecifier())
-
- assertTrue(code.isPrivate)
- assertTrue(code.isStatic)
- assertEquals(PRIVATE or STATIC, code.modifierSpecifier())
- }
- }
-
- @Test
- fun shouldNotHaveDuplicatedConstructorParameters() {
- verifyJavadoc("testdata/javadoc/constructorParameters.kt") { doc ->
- val classDoc = doc.classNamed("bar.Banana")!!
- val paramTags = classDoc.constructors()[0].paramTags()
-
- assertEquals(3, paramTags.size)
- }
- }
-
- @Test fun shouldHaveAllFunctionMarkedAsDeprecated() {
- verifyJavadoc("testdata/javadoc/deprecated.java") { doc ->
- val classDoc = doc.classNamed("bar.Banana")!!
-
- classDoc.methods().forEach { method ->
- assertTrue(method.tags().any { it.kind() == "deprecated" })
- }
- }
- }
-
- @Test
- fun testDefaultNoArgConstructor() {
- verifyJavadoc("testdata/javadoc/defaultNoArgConstructor.kt") { doc ->
- val classDoc = doc.classNamed("foo.Peach")!!
- assertTrue(classDoc.constructors()[0].tags()[2].text() == "print peach")
- }
- }
-
- @Test
- fun testNoArgConstructor() {
- verifyJavadoc("testdata/javadoc/noArgConstructor.kt") { doc ->
- val classDoc = doc.classNamed("foo.Plum")!!
- assertTrue(classDoc.constructors()[0].tags()[2].text() == "print plum")
- }
- }
-
- @Test
- fun testArgumentReference() {
- verifyJavadoc("testdata/javadoc/argumentReference.kt") { doc ->
- val classDoc = doc.classNamed("ArgumentReferenceKt")!!
- val method = classDoc.methods().first()
- val tag = method.seeTags().first()
- assertEquals("argNamedError", tag.referencedMemberName())
- assertEquals("error", tag.label())
- }
- }
-
- @Test
- fun functionParameters() {
- verifyJavadoc("testdata/javadoc/functionParameters.java") { doc ->
- val tags = doc.classNamed("bar.Foo")!!.methods().first().paramTags()
- assertEquals((tags.first() as ParamTagAdapter).content.size, 1)
- assertEquals((tags[1] as ParamTagAdapter).content.size, 1)
- }
- }
-
- private fun verifyJavadoc(name: String,
- modelConfig: ModelConfig = ModelConfig(),
- callback: (ModuleNodeAdapter) -> Unit) {
-
- checkSourceExistsAndVerifyModel(name,
- ModelConfig(
- analysisPlatform = Platform.jvm,
- format = "javadoc",
- withJdk = modelConfig.withJdk,
- withKotlinRuntime = modelConfig.withKotlinRuntime,
- includeNonPublic = modelConfig.includeNonPublic
- )) { model ->
- val doc = ModuleNodeAdapter(model, StandardReporter(DokkaConsoleLogger), "")
- callback(doc)
- }
- }
-}
diff --git a/core/src/test/kotlin/markdown/ParserTest.kt b/core/src/test/kotlin/markdown/ParserTest.kt
deleted file mode 100644
index b0ec68ff..00000000
--- a/core/src/test/kotlin/markdown/ParserTest.kt
+++ /dev/null
@@ -1,154 +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 underscoresNoEmph() {
- runTestFor("text_with_underscores")
- }
-
- @Test fun emphUnderscores() {
- runTestFor("_text_")
- }
-
- @Test fun singleStar() {
- runTestFor("Embedded*Star")
- }
-
- @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/core/src/test/kotlin/model/ClassTest.kt b/core/src/test/kotlin/model/ClassTest.kt
deleted file mode 100644
index 35ec1d09..00000000
--- a/core/src/test/kotlin/model/ClassTest.kt
+++ /dev/null
@@ -1,318 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.RefKind
-import org.junit.Assert
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertTrue
-import org.junit.Test
-
-abstract class BaseClassTest(val analysisPlatform: Platform) {
- protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun emptyClass() {
- checkSourceExistsAndVerifyModel("testdata/classes/emptyClass.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(NodeKind.Class, kind)
- assertEquals("Klass", name)
- assertEquals(Content.Empty, content)
- assertEquals("<init>", members.single().name)
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun emptyObject() {
- checkSourceExistsAndVerifyModel("testdata/classes/emptyObject.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(NodeKind.Object, kind)
- assertEquals("Obj", name)
- assertEquals(Content.Empty, content)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun classWithConstructor() {
- checkSourceExistsAndVerifyModel("testdata/classes/classWithConstructor.kt", defaultModelConfig) { model ->
- with (model.members.single().members.single()) {
- assertEquals(NodeKind.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(NodeKind.Constructor, kind)
- assertEquals(3, details.count())
- assertEquals("public", details.elementAt(0).name)
- with(details.elementAt(2)) {
- assertEquals("name", name)
- assertEquals(NodeKind.Parameter, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(NodeKind.Type).name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
- }
-
- @Test fun classWithFunction() {
- checkSourceExistsAndVerifyModel("testdata/classes/classWithFunction.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(NodeKind.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(NodeKind.Constructor, kind)
- assertEquals(2, 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(NodeKind.Function, kind)
- assertEquals("Unit", detail(NodeKind.Type).name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
- }
-
- @Test fun classWithProperty() {
- checkSourceExistsAndVerifyModel("testdata/classes/classWithProperty.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(NodeKind.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(NodeKind.Constructor, kind)
- assertEquals(2, 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(NodeKind.Property, kind)
- assertEquals("String", detail(NodeKind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
- }
-
- @Test fun classWithCompanionObject() {
- checkSourceExistsAndVerifyModel("testdata/classes/classWithCompanionObject.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(NodeKind.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(NodeKind.CompanionObjectProperty, kind)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(members.elementAt(2)) {
- assertEquals("foo", name)
- assertEquals(NodeKind.CompanionObjectFunction, kind)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
- }
-
- @Test fun dataClass() {
- verifyPackageMember("testdata/classes/dataClass.kt", defaultModelConfig) { cls ->
- val modifiers = cls.details(NodeKind.Modifier).map { it.name }
- assertTrue("data" in modifiers)
- }
- }
-
- @Test fun sealedClass() {
- verifyPackageMember("testdata/classes/sealedClass.kt", defaultModelConfig) { cls ->
- val modifiers = cls.details(NodeKind.Modifier).map { it.name }
- assertEquals(1, modifiers.count { it == "sealed" })
- }
- }
-
- @Test fun annotatedClassWithAnnotationParameters() {
- checkSourceExistsAndVerifyModel(
- "testdata/classes/annotatedClassWithAnnotationParameters.kt",
- defaultModelConfig
- ) { model ->
- with(model.members.single().members.single()) {
- with(deprecation!!) {
- assertEquals("Deprecated", name)
- assertEquals(Content.Empty, content)
- assertEquals(NodeKind.Annotation, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(NodeKind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(NodeKind.Value, kind)
- assertEquals("\"should no longer be used\"", name)
- }
- }
- }
- }
- }
- }
-
- @Test fun notOpenClass() {
- checkSourceExistsAndVerifyModel("testdata/classes/notOpenClass.kt", defaultModelConfig) { model ->
- with(model.members.single().members.first { it.name == "D"}.members.first { it.name == "f" }) {
- val modifiers = details(NodeKind.Modifier)
- assertEquals(2, modifiers.size)
- assertEquals("final", modifiers[1].name)
-
- val overrideReferences = references(RefKind.Override)
- assertEquals(1, overrideReferences.size)
- }
- }
- }
-
- @Test fun indirectOverride() {
- checkSourceExistsAndVerifyModel("testdata/classes/indirectOverride.kt", defaultModelConfig) { model ->
- with(model.members.single().members.first { it.name == "E"}.members.first { it.name == "foo" }) {
- val modifiers = details(NodeKind.Modifier)
- assertEquals(2, modifiers.size)
- assertEquals("final", modifiers[1].name)
-
- val overrideReferences = references(RefKind.Override)
- assertEquals(1, overrideReferences.size)
- }
- }
- }
-
- @Test fun innerClass() {
- verifyPackageMember("testdata/classes/innerClass.kt", defaultModelConfig) { cls ->
- val innerClass = cls.members.single { it.name == "D" }
- val modifiers = innerClass.details(NodeKind.Modifier)
- assertEquals(3, modifiers.size)
- assertEquals("inner", modifiers[2].name)
- }
- }
-
- @Test fun companionObjectExtension() {
- checkSourceExistsAndVerifyModel("testdata/classes/companionObjectExtension.kt", defaultModelConfig) { model ->
- val pkg = model.members.single()
- val cls = pkg.members.single { it.name == "Foo" }
- val extensions = cls.extensions.filter { it.kind == NodeKind.CompanionObjectProperty }
- assertEquals(1, extensions.size)
- }
- }
-
- @Test fun secondaryConstructor() {
- verifyPackageMember("testdata/classes/secondaryConstructor.kt", defaultModelConfig) { cls ->
- val constructors = cls.members(NodeKind.Constructor)
- assertEquals(2, constructors.size)
- with (constructors.first { it.details(NodeKind.Parameter).size == 1}) {
- assertEquals("<init>", name)
- assertEquals("This is a secondary constructor.", summary.toTestString())
- }
- }
- }
-
- @Test fun sinceKotlin() {
- checkSourceExistsAndVerifyModel("testdata/classes/sinceKotlin.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("1.1", sinceKotlin)
- }
- }
- }
-
- @Test fun privateCompanionObject() {
- checkSourceExistsAndVerifyModel(
- "testdata/classes/privateCompanionObject.kt",
- modelConfig = ModelConfig(analysisPlatform = analysisPlatform, includeNonPublic = false)
- ) { model ->
- with(model.members.single().members.single()) {
- assertEquals(0, members(NodeKind.CompanionObjectFunction).size)
- assertEquals(0, members(NodeKind.CompanionObjectProperty).size)
- }
- }
- }
-
-}
-
-class JSClassTest: BaseClassTest(Platform.js) {}
-
-class JVMClassTest: BaseClassTest(Platform.jvm) {
- @Test
- fun annotatedClass() {
- verifyPackageMember("testdata/classes/annotatedClass.kt", ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- ) { cls ->
- Assert.assertEquals(1, cls.annotations.count())
- with(cls.annotations[0]) {
- Assert.assertEquals("Strictfp", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
-
-
- @Test fun javaAnnotationClass() {
- checkSourceExistsAndVerifyModel(
- "testdata/classes/javaAnnotationClass.kt",
- modelConfig = ModelConfig(analysisPlatform = analysisPlatform, withJdk = true)
- ) { model ->
- with(model.members.single().members.single()) {
- Assert.assertEquals(1, annotations.count())
- with(annotations[0]) {
- Assert.assertEquals("Retention", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- with(details[0]) {
- Assert.assertEquals(NodeKind.Parameter, kind)
- Assert.assertEquals(1, details.count())
- with(details[0]) {
- Assert.assertEquals(NodeKind.Value, kind)
- Assert.assertEquals("RetentionPolicy.SOURCE", name)
- }
- }
- }
- }
- }
- }
-
-}
-
-class CommonClassTest: BaseClassTest(Platform.common) {} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/CommentTest.kt b/core/src/test/kotlin/model/CommentTest.kt
deleted file mode 100644
index 08aa3572..00000000
--- a/core/src/test/kotlin/model/CommentTest.kt
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.junit.Test
-import org.junit.Assert.*
-import org.jetbrains.dokka.*
-
-abstract class BaseCommentTest(val analysisPlatform: Platform) {
- val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun codeBlockComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/codeBlockComment.kt", defaultModelConfig) { model ->
- with(model.members.single().members.first()) {
- assertEqualsIgnoringSeparators("""[code lang=brainfuck]
- |
- |++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
- |
- |[/code]
- |""".trimMargin(),
- content.toTestString())
- }
- with(model.members.single().members.last()) {
- assertEqualsIgnoringSeparators("""[code]
- |
- |a + b - c
- |
- |[/code]
- |""".trimMargin(),
- content.toTestString())
- }
- }
- }
-
- @Test fun emptyDoc() {
- checkSourceExistsAndVerifyModel("testdata/comments/emptyDoc.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(Content.Empty, content)
- }
- }
- }
-
- @Test fun emptyDocButComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/emptyDocButComment.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals(Content.Empty, content)
- }
- }
- }
-
- @Test fun multilineDoc() {
- checkSourceExistsAndVerifyModel("testdata/comments/multilineDoc.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc1", content.summary.toTestString())
- assertEquals("doc2\ndoc3", content.description.toTestString())
- }
- }
- }
-
- @Test fun multilineDocWithComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/multilineDocWithComment.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc1", content.summary.toTestString())
- assertEquals("doc2\ndoc3", content.description.toTestString())
- }
- }
- }
-
- @Test fun oneLineDoc() {
- checkSourceExistsAndVerifyModel("testdata/comments/oneLineDoc.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc", content.summary.toTestString())
- }
- }
- }
-
- @Test fun oneLineDocWithComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithComment.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc", content.summary.toTestString())
- }
- }
- }
-
- @Test fun oneLineDocWithEmptyLine() {
- checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithEmptyLine.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc", content.summary.toTestString())
- }
- }
- }
-
- @Test fun emptySection() {
- checkSourceExistsAndVerifyModel("testdata/comments/emptySection.kt", defaultModelConfig) { 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 quotes() {
- checkSourceExistsAndVerifyModel("testdata/comments/quotes.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("it's \"useful\"", content.summary.toTestString())
- }
- }
- }
-
- @Test fun section1() {
- checkSourceExistsAndVerifyModel("testdata/comments/section1.kt", defaultModelConfig) { 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() {
- checkSourceExistsAndVerifyModel("testdata/comments/section2.kt", defaultModelConfig) { 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() {
- checkSourceExistsAndVerifyModel("testdata/comments/multilineSection.kt", defaultModelConfig) { 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() {
- checkSourceExistsAndVerifyModel("testdata/comments/directive.kt", defaultModelConfig) { model ->
- with(model.members.single().members.first()) {
- assertEquals("Summary", content.summary.toTestString())
- with (content.description) {
- assertEqualsIgnoringSeparators("""
- |[code lang=kotlin]
- |if (true) {
- | println(property)
- |}
- |[/code]
- |[code lang=kotlin]
- |if (true) {
- | println(property)
- |}
- |[/code]
- |[code lang=kotlin]
- |if (true) {
- | println(property)
- |}
- |[/code]
- |[code lang=kotlin]
- |if (true) {
- | println(property)
- |}
- |[/code]
- |""".trimMargin(), toTestString())
- }
- }
- }
- }
-}
-
-class JSCommentTest: BaseCommentTest(Platform.js)
-class JVMCommentTest: BaseCommentTest(Platform.jvm)
-class CommonCommentTest: BaseCommentTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/DocumentableTest.kt b/core/src/test/kotlin/model/DocumentableTest.kt
new file mode 100644
index 00000000..a801d549
--- /dev/null
+++ b/core/src/test/kotlin/model/DocumentableTest.kt
@@ -0,0 +1,108 @@
+package model
+
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.*
+import org.jetbrains.dokka.model.properties.PropertyContainer
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class DocumentableTest {
+
+ @Test
+ fun withDescendents() {
+ val dClass = DClass(
+ dri = DRI(),
+ name = "TestClass",
+ constructors = emptyList(),
+ classlikes = emptyList(),
+ companion = null,
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ visibility = emptyMap(),
+ generics = emptyList(),
+ modifier = emptyMap(),
+ properties = emptyList(),
+ sources = emptyMap(),
+ sourceSets = emptySet(),
+ supertypes = emptyMap(),
+ functions = listOf(
+ DFunction(
+ dri = DRI(),
+ name = "function0",
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ visibility = emptyMap(),
+ generics = emptyList(),
+ modifier = emptyMap(),
+ sources = emptyMap(),
+ sourceSets = emptySet(),
+ type = Void,
+ receiver = null,
+ isConstructor = false,
+ parameters = listOf(
+ DParameter(
+ dri = DRI(),
+ name = "f0p0",
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ sourceSets = emptySet(),
+ type = Void
+ ),
+ DParameter(
+ dri = DRI(),
+ name = "f0p1",
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ sourceSets = emptySet(),
+ type = Void
+ )
+ )
+ ),
+ DFunction(
+ dri = DRI(),
+ name = "function1",
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ visibility = emptyMap(),
+ generics = emptyList(),
+ modifier = emptyMap(),
+ sources = emptyMap(),
+ sourceSets = emptySet(),
+ type = Void,
+ receiver = null,
+ isConstructor = false,
+ parameters = listOf(
+ DParameter(
+ dri = DRI(),
+ name = "f1p0",
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ sourceSets = emptySet(),
+ type = Void
+ ),
+ DParameter(
+ dri = DRI(),
+ name = "f1p1",
+ documentation = emptyMap(),
+ expectPresentInSet = null,
+ extra = PropertyContainer.empty(),
+ sourceSets = emptySet(),
+ type = Void
+ )
+ )
+ )
+ )
+ )
+
+ assertEquals(
+ listOf("TestClass", "function0", "f0p0", "f0p1", "function1", "f1p0", "f1p1"),
+ dClass.withDescendants().map { it.name }.toList()
+ )
+ }
+} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt
deleted file mode 100644
index 4c6bfb74..00000000
--- a/core/src/test/kotlin/model/FunctionTest.kt
+++ /dev/null
@@ -1,281 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.kotlin.analyzer.PlatformAnalysisParameters
-import org.junit.Assert
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertTrue
-import org.junit.Test
-
-abstract class BaseFunctionTest(val analysisPlatform: Platform) {
- protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun function() {
- checkSourceExistsAndVerifyModel("testdata/functions/function.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("fn", name)
- assertEquals(NodeKind.Function, kind)
- assertEquals("Function fn", content.summary.toTestString())
- assertEquals("Unit", detail(NodeKind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun functionWithReceiver() {
- checkSourceExistsAndVerifyModel("testdata/functions/functionWithReceiver.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("kotlin.String", name)
- assertEquals(NodeKind.ExternalClass, kind)
- assertEquals(2, members.count())
- with(members[0]) {
- assertEquals("fn", name)
- assertEquals(NodeKind.Function, kind)
- assertEquals("Function with receiver", content.summary.toTestString())
- assertEquals("public", details.elementAt(0).name)
- assertEquals("final", details.elementAt(1).name)
- with(details.elementAt(3)) {
- assertEquals("<this>", name)
- assertEquals(NodeKind.Receiver, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", details.single().name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(4).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(members[1]) {
- assertEquals("fn", name)
- assertEquals(NodeKind.Function, kind)
- }
- }
- }
- }
-
- @Test fun genericFunction() {
- checkSourceExistsAndVerifyModel("testdata/functions/genericFunction.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("generic", name)
- assertEquals(NodeKind.Function, kind)
- assertEquals("generic function", content.summary.toTestString())
-
- assertEquals("private", details.elementAt(0).name)
- assertEquals("final", details.elementAt(1).name)
- with(details.elementAt(3)) {
- assertEquals("T", name)
- assertEquals(NodeKind.TypeParameter, kind)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(4).name)
-
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
- @Test fun genericFunctionWithConstraints() {
- checkSourceExistsAndVerifyModel("testdata/functions/genericFunctionWithConstraints.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("generic", name)
- assertEquals(NodeKind.Function, kind)
- assertEquals("generic function", content.summary.toTestString())
-
- val functionDetails = details
- assertEquals("public", functionDetails.elementAt(0).name)
- assertEquals("final", functionDetails.elementAt(1).name)
- with(functionDetails.elementAt(3)) {
- assertEquals("T", name)
- assertEquals(NodeKind.TypeParameter, kind)
- assertEquals(Content.Empty, content)
- with(details.single()) {
- assertEquals("R", name)
- assertEquals(NodeKind.UpperBound, kind)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.singleOrNull() == functionDetails.elementAt(4))
- }
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(functionDetails.elementAt(4)) {
- assertEquals("R", name)
- assertEquals(NodeKind.TypeParameter, kind)
- assertEquals(Content.Empty, content)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", functionDetails.elementAt(5).name)
-
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun functionWithParams() {
- checkSourceExistsAndVerifyModel("testdata/functions/functionWithParams.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("function", name)
- assertEquals(NodeKind.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(3)) {
- assertEquals("x", name)
- assertEquals(NodeKind.Parameter, kind)
- assertEquals("parameter", content.summary.toTestString())
- assertEquals("Int", detail(NodeKind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(4).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun functionWithNotDocumentedAnnotation() {
- verifyPackageMember("testdata/functions/functionWithNotDocumentedAnnotation.kt", defaultModelConfig) { func ->
- assertEquals(0, func.annotations.count())
- }
- }
-
- @Test fun inlineFunction() {
- verifyPackageMember("testdata/functions/inlineFunction.kt", defaultModelConfig) { func ->
- val modifiers = func.details(NodeKind.Modifier).map { it.name }
- assertTrue("inline" in modifiers)
- }
- }
-
- @Test fun suspendFunction() {
- verifyPackageMember("testdata/functions/suspendFunction.kt") { func ->
- val modifiers = func.details(NodeKind.Modifier).map { it.name }
- assertTrue("suspend" in modifiers)
- }
- }
-
- @Test fun suspendInlineFunctionOrder() {
- verifyPackageMember("testdata/functions/suspendInlineFunction.kt") { func ->
- val modifiers = func.details(NodeKind.Modifier).map { it.name }.filter {
- it == "suspend" || it == "inline"
- }
-
- assertEquals(listOf("suspend", "inline"), modifiers)
- }
- }
-
- @Test fun inlineSuspendFunctionOrderChanged() {
- verifyPackageMember("testdata/functions/inlineSuspendFunction.kt") { func ->
- val modifiers = func.details(NodeKind.Modifier).map { it.name }.filter {
- it == "suspend" || it == "inline"
- }
-
- assertEquals(listOf("suspend", "inline"), modifiers)
- }
- }
-
- @Test fun functionWithAnnotatedParam() {
- checkSourceExistsAndVerifyModel("testdata/functions/functionWithAnnotatedParam.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single { it.name == "function" }) {
- with(details(NodeKind.Parameter).first()) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("Fancy", name)
- assertEquals(Content.Empty, content)
- assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
- }
- }
-
- @Test fun functionWithNoinlineParam() {
- verifyPackageMember("testdata/functions/functionWithNoinlineParam.kt", defaultModelConfig) { func ->
- with(func.details(NodeKind.Parameter).first()) {
- val modifiers = details(NodeKind.Modifier).map { it.name }
- assertTrue("noinline" in modifiers)
- }
- }
- }
-
- @Test fun annotatedFunctionWithAnnotationParameters() {
- checkSourceExistsAndVerifyModel(
- "testdata/functions/annotatedFunctionWithAnnotationParameters.kt",
- defaultModelConfig
- ) { 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(NodeKind.Annotation, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(NodeKind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(NodeKind.Value, kind)
- assertEquals("1", name)
- }
- }
- }
- }
- }
- }
-
- @Test fun functionWithDefaultParameter() {
- checkSourceExistsAndVerifyModel("testdata/functions/functionWithDefaultParameter.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- with(details.elementAt(3)) {
- val value = details(NodeKind.Value)
- assertEquals(1, value.count())
- with(value[0]) {
- assertEquals("\"\"", name)
- }
- }
- }
- }
- }
-
- @Test fun sinceKotlin() {
- checkSourceExistsAndVerifyModel("testdata/functions/sinceKotlin.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("1.1", sinceKotlin)
- }
- }
- }
-}
-
-class JSFunctionTest: BaseFunctionTest(Platform.js)
-
-class JVMFunctionTest: BaseFunctionTest(Platform.jvm) {
- @Test
- fun annotatedFunction() {
- verifyPackageMember("testdata/functions/annotatedFunction.kt", ModelConfig(
- analysisPlatform = Platform.jvm,
- withKotlinRuntime = true
- )) { func ->
- Assert.assertEquals(1, func.annotations.count())
- with(func.annotations[0]) {
- Assert.assertEquals("Strictfp", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
-
-}
-
-class CommonFunctionTest: BaseFunctionTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JavaTest.kt b/core/src/test/kotlin/model/JavaTest.kt
deleted file mode 100644
index da9da624..00000000
--- a/core/src/test/kotlin/model/JavaTest.kt
+++ /dev/null
@@ -1,210 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.RefKind
-import org.junit.Assert.*
-import org.junit.Ignore
-import org.junit.Test
-
-public class JavaTest {
- private val defaultModelConfig = ModelConfig(analysisPlatform = Platform.jvm)
- @Test fun function() {
- verifyJavaPackageMember("testdata/java/member.java", defaultModelConfig) { cls ->
- assertEquals("Test", cls.name)
- assertEquals(NodeKind.Class, cls.kind)
- with(cls.members(NodeKind.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("render(Type:String,SUMMARY): is String parameter", toTestString())
- }
- with(content.sections[1]) {
- assertEquals("Parameters", tag)
- assertEquals("value", subjectName)
- assertEquals("render(Type:Int,SUMMARY): is int parameter", toTestString())
- }
- with(content.sections[2]) {
- assertEquals("Author", tag)
- assertEquals("yole", toTestString())
- }
- assertEquals("Unit", detail(NodeKind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- with(details.first { it.name == "name" }) {
- assertEquals(NodeKind.Parameter, kind)
- assertEquals("String", detail(NodeKind.Type).name)
- }
- with(details.first { it.name == "value" }) {
- assertEquals(NodeKind.Parameter, kind)
- assertEquals("Int", detail(NodeKind.Type).name)
- }
- }
- }
- }
-
- @Test fun memberWithModifiers() {
- verifyJavaPackageMember("testdata/java/memberWithModifiers.java", defaultModelConfig) { cls ->
- val modifiers = cls.details(NodeKind.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("testdata/java/superClass.java", defaultModelConfig) { cls ->
- val superTypes = cls.details(NodeKind.Supertype)
- assertEquals(2, superTypes.size)
- assertEquals("Exception", superTypes[0].name)
- assertEquals("Cloneable", superTypes[1].name)
- }
- }
-
- @Test fun arrayType() {
- verifyJavaPackageMember("testdata/java/arrayType.java", defaultModelConfig) { cls ->
- with(cls.members(NodeKind.Function).single()) {
- val type = detail(NodeKind.Type)
- assertEquals("Array", type.name)
- assertEquals("String", type.detail(NodeKind.Type).name)
- with(details(NodeKind.Parameter).single()) {
- val parameterType = detail(NodeKind.Type)
- assertEquals("IntArray", parameterType.name)
- }
- }
- }
- }
-
- @Test fun typeParameter() {
- verifyJavaPackageMember("testdata/java/typeParameter.java", defaultModelConfig) { cls ->
- val typeParameters = cls.details(NodeKind.TypeParameter)
- with(typeParameters.single()) {
- assertEquals("T", name)
- with(detail(NodeKind.UpperBound)) {
- assertEquals("Comparable", name)
- assertEquals("T", detail(NodeKind.Type).name)
- }
- }
- with(cls.members(NodeKind.Function).single()) {
- val methodTypeParameters = details(NodeKind.TypeParameter)
- with(methodTypeParameters.single()) {
- assertEquals("E", name)
- }
- }
- }
- }
-
- @Test fun constructors() {
- verifyJavaPackageMember("testdata/java/constructors.java", defaultModelConfig) { cls ->
- val constructors = cls.members(NodeKind.Constructor)
- assertEquals(2, constructors.size)
- with(constructors[0]) {
- assertEquals("<init>", name)
- }
- }
- }
-
- @Test fun innerClass() {
- verifyJavaPackageMember("testdata/java/InnerClass.java", defaultModelConfig) { cls ->
- val innerClass = cls.members(NodeKind.Class).single()
- assertEquals("D", innerClass.name)
- }
- }
-
- @Test fun varargs() {
- verifyJavaPackageMember("testdata/java/varargs.java", defaultModelConfig) { cls ->
- val fn = cls.members(NodeKind.Function).single()
- val param = fn.detail(NodeKind.Parameter)
- assertEquals("vararg", param.details(NodeKind.Modifier).first().name)
- val psiType = param.detail(NodeKind.Type)
- assertEquals("String", psiType.name)
- assertTrue(psiType.details(NodeKind.Type).isEmpty())
- }
- }
-
- @Test fun fields() {
- verifyJavaPackageMember("testdata/java/field.java", defaultModelConfig) { cls ->
- val i = cls.members(NodeKind.Property).single { it.name == "i" }
- assertEquals("Int", i.detail(NodeKind.Type).name)
- assertTrue("var" in i.details(NodeKind.Modifier).map { it.name })
-
- val s = cls.members(NodeKind.Property).single { it.name == "s" }
- assertEquals("String", s.detail(NodeKind.Type).name)
- assertFalse("var" in s.details(NodeKind.Modifier).map { it.name })
- assertTrue("static" in s.details(NodeKind.Modifier).map { it.name })
- }
- }
-
- @Test fun staticMethod() {
- verifyJavaPackageMember("testdata/java/staticMethod.java", defaultModelConfig) { cls ->
- val m = cls.members(NodeKind.Function).single { it.name == "foo" }
- assertTrue("static" in m.details(NodeKind.Modifier).map { it.name })
- }
- }
-
- /**
- * `@suppress` not supported in Java!
- *
- * [Proposed tags](https://www.oracle.com/technetwork/java/javase/documentation/proposed-tags-142378.html)
- * Proposed tag `@exclude` for it, but not supported yet
- */
- @Ignore("@suppress not supported in Java!") @Test fun suppressTag() {
- verifyJavaPackageMember("testdata/java/suppressTag.java", defaultModelConfig) { cls ->
- assertEquals(1, cls.members(NodeKind.Function).size)
- }
- }
-
- @Test fun annotatedAnnotation() {
- verifyJavaPackageMember("testdata/java/annotatedAnnotation.java", defaultModelConfig) { cls ->
- assertEquals(1, cls.annotations.size)
- with(cls.annotations[0]) {
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(NodeKind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(NodeKind.Value, kind)
- assertEquals("[AnnotationTarget.FIELD, AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]", name)
- }
- }
- }
- }
- }
-
- @Test fun deprecation() {
- verifyJavaPackageMember("testdata/java/deprecation.java", defaultModelConfig) { cls ->
- val fn = cls.members(NodeKind.Function).single()
- assertEquals("This should no longer be used", fn.deprecation!!.content.toTestString())
- }
- }
-
- @Test fun javaLangObject() {
- verifyJavaPackageMember("testdata/java/javaLangObject.java", defaultModelConfig) { cls ->
- val fn = cls.members(NodeKind.Function).single()
- assertEquals("Any", fn.detail(NodeKind.Type).name)
- }
- }
-
- @Test fun enumValues() {
- verifyJavaPackageMember("testdata/java/enumValues.java", defaultModelConfig) { cls ->
- val superTypes = cls.details(NodeKind.Supertype)
- assertEquals(1, superTypes.size)
- assertEquals(1, cls.members(NodeKind.EnumItem).size)
- }
- }
-
- @Test fun inheritorLinks() {
- verifyJavaPackageMember("testdata/java/InheritorLinks.java", defaultModelConfig) { cls ->
- val fooClass = cls.members.single { it.name == "Foo" }
- val inheritors = fooClass.references(RefKind.Inheritor)
- assertEquals(1, inheritors.size)
- }
- }
-}
diff --git a/core/src/test/kotlin/model/KotlinAsJavaTest.kt b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
deleted file mode 100644
index c29776be..00000000
--- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.DocumentationModule
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.RefKind
-import org.junit.Assert
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
-class KotlinAsJavaTest {
- @Test fun function() {
- verifyModelAsJava("testdata/functions/function.kt") { model ->
- val pkg = model.members.single()
-
- val facadeClass = pkg.members.single { it.name == "FunctionKt" }
- assertEquals(NodeKind.Class, facadeClass.kind)
-
- val fn = facadeClass.members.single { it.kind == NodeKind.Function}
- assertEquals("fn", fn.name)
- }
- }
-
- @Test fun propertyWithComment() {
- verifyModelAsJava("testdata/comments/oneLineDoc.kt") { model ->
- val facadeClass = model.members.single().members.single { it.name == "OneLineDocKt" }
- val getter = facadeClass.members.single { it.name == "getProperty" }
- assertEquals(NodeKind.Function, getter.kind)
- assertEquals("doc", getter.content.summary.toTestString())
- }
- }
-
-
- @Test fun constants() {
- verifyModelAsJava("testdata/java/constants.java") { cls ->
- selectNodes(cls) {
- subgraphOf(RefKind.Member)
- matching { it.name == "constStr" || it.name == "refConst" }
- }.forEach {
- assertEquals("In $it", "\"some value\"", it.detailOrNull(NodeKind.Value)?.name)
- }
- val nullConstNode = selectNodes(cls) {
- subgraphOf(RefKind.Member)
- withName("nullConst")
- }.single()
-
- Assert.assertNull(nullConstNode.detailOrNull(NodeKind.Value))
- }
- }
-}
-
-fun verifyModelAsJava(source: String,
- modelConfig: ModelConfig = ModelConfig(),
- verifier: (DocumentationModule) -> Unit) {
- checkSourceExistsAndVerifyModel(
- source,
- modelConfig = ModelConfig(
- withJdk = modelConfig.withJdk,
- withKotlinRuntime = modelConfig.withKotlinRuntime,
- format = "html-as-java",
- analysisPlatform = Platform.jvm),
- verifier = verifier
- )
-}
diff --git a/core/src/test/kotlin/model/LinkTest.kt b/core/src/test/kotlin/model/LinkTest.kt
deleted file mode 100644
index 6526a4db..00000000
--- a/core/src/test/kotlin/model/LinkTest.kt
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.ContentBlock
-import org.jetbrains.dokka.ContentNodeLazyLink
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
-abstract class BaseLinkTest(val analysisPlatform: Platform) {
- private val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun linkToSelf() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToSelf.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(NodeKind.Class, kind)
- assertEquals("This is link to [Foo -> Class:Foo]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToExternalSite() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToExternalSite.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(NodeKind.Class, kind)
- assertEquals("This is link to http://example.com/#example", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToMember() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToMember.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(NodeKind.Class, kind)
- assertEquals("This is link to [member -> Function:member]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToConstantWithUnderscores() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToConstantWithUnderscores.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(NodeKind.Class, kind)
- assertEquals("This is link to [MY_CONSTANT_VALUE -> CompanionObjectProperty:MY_CONSTANT_VALUE]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToQualifiedMember() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToQualifiedMember.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(NodeKind.Class, kind)
- assertEquals("This is link to [Foo.member -> Function:member]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToParam() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToParam.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(NodeKind.Function, kind)
- assertEquals("This is link to [param -> Parameter:param]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToPackage() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToPackage.kt", defaultModelConfig) { model ->
- val packageNode = model.members.single()
- with(packageNode) {
- assertEquals(this.name, "test.magic")
- }
- with(packageNode.members.single()) {
- assertEquals("Magic", name)
- assertEquals(NodeKind.Class, kind)
- assertEquals("Basic implementations of [Magic -> Class:Magic] are located in [test.magic -> Package:test.magic] package", content.summary.toTestString())
- assertEquals(packageNode, ((this.content.summary as ContentBlock).children.filterIsInstance<ContentNodeLazyLink>().last()).lazyNode.invoke())
- }
- }
- }
-
-}
-
-class JSLinkTest: BaseLinkTest(Platform.js)
-class JVMLinkTest: BaseLinkTest(Platform.jvm)
-class CommonLinkTest: BaseLinkTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/PackageTest.kt b/core/src/test/kotlin/model/PackageTest.kt
deleted file mode 100644
index 47c88385..00000000
--- a/core/src/test/kotlin/model/PackageTest.kt
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
-import org.junit.Assert.*
-import org.junit.Test
-
-abstract class BasePackageTest(val analysisPlatform: Platform) {
- val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun rootPackage() {
- checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt", defaultModelConfig) { model ->
- with(model.members.single()) {
- assertEquals(NodeKind.Package, kind)
- assertEquals("", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun simpleNamePackage() {
- checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt", defaultModelConfig) { model ->
- with(model.members.single()) {
- assertEquals(NodeKind.Package, kind)
- assertEquals("simple", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun dottedNamePackage() {
- checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt", defaultModelConfig) { model ->
- with(model.members.single()) {
- assertEquals(NodeKind.Package, kind)
- assertEquals("dot.name", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun multipleFiles() {
- verifyModel(
- ModelConfig(
- roots = arrayOf(
- KotlinSourceRoot("testdata/packages/dottedNamePackage.kt", false),
- KotlinSourceRoot("testdata/packages/simpleNamePackage.kt", false)
- ),
- analysisPlatform = analysisPlatform
- )
- ) { model ->
- assertEquals(2, model.members.count())
- with(model.members.single { it.name == "simple" }) {
- assertEquals(NodeKind.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(NodeKind.Package, kind)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun multipleFilesSamePackage() {
- verifyModel(
- ModelConfig(
- roots = arrayOf(
- KotlinSourceRoot("testdata/packages/simpleNamePackage.kt", false),
- KotlinSourceRoot("testdata/packages/simpleNamePackage2.kt", false)
- ),
- analysisPlatform = analysisPlatform
- )
- ) { model ->
- assertEquals(1, model.members.count())
- with(model.members.elementAt(0)) {
- assertEquals(NodeKind.Package, kind)
- assertEquals("simple", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun classAtPackageLevel() {
- verifyModel(
- ModelConfig(
- roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt", false)),
- analysisPlatform = analysisPlatform
- )
- ) { model ->
- assertEquals(1, model.members.count())
- with(model.members.elementAt(0)) {
- assertEquals(NodeKind.Package, kind)
- assertEquals("simple.name", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertEquals(1, members.size)
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun suppressAtPackageLevel() {
- verifyModel(
- ModelConfig(
- roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt", false)),
- perPackageOptions = listOf(
- PackageOptionsImpl(prefix = "simple.name", suppress = true)
- ),
- analysisPlatform = analysisPlatform
- )
- ) { model ->
- assertEquals(0, model.members.count())
- }
- }
-}
-
-class JSPackageTest : BasePackageTest(Platform.js)
-class JVMPackageTest : BasePackageTest(Platform.jvm)
-class CommonPackageTest : BasePackageTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/PropertyTest.kt b/core/src/test/kotlin/model/PropertyTest.kt
deleted file mode 100644
index 9f070862..00000000
--- a/core/src/test/kotlin/model/PropertyTest.kt
+++ /dev/null
@@ -1,129 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.junit.Assert
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertTrue
-import org.junit.Test
-
-abstract class BasePropertyTest(val analysisPlatform: Platform) {
-
- protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun valueProperty() {
- checkSourceExistsAndVerifyModel("testdata/properties/valueProperty.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(NodeKind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(NodeKind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun variableProperty() {
- checkSourceExistsAndVerifyModel("testdata/properties/variableProperty.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(NodeKind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(NodeKind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun valuePropertyWithGetter() {
- checkSourceExistsAndVerifyModel("testdata/properties/valuePropertyWithGetter.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(NodeKind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(NodeKind.Type).name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
-
- @Test fun variablePropertyWithAccessors() {
- checkSourceExistsAndVerifyModel("testdata/properties/variablePropertyWithAccessors.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(NodeKind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(NodeKind.Type).name)
- val modifiers = details(NodeKind.Modifier).map { it.name }
- assertTrue("final" in modifiers)
- assertTrue("public" in modifiers)
- assertTrue("var" in modifiers)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
-
- @Test fun propertyWithReceiver() {
- checkSourceExistsAndVerifyModel(
- "testdata/properties/propertyWithReceiver.kt",
- defaultModelConfig
- ) { model ->
- with(model.members.single().members.single()) {
- assertEquals("kotlin.String", name)
- assertEquals(NodeKind.ExternalClass, kind)
- with(members.single()) {
- assertEquals("foobar", name)
- assertEquals(NodeKind.Property, kind)
- }
- }
- }
- }
-
- @Test fun propertyOverride() {
- checkSourceExistsAndVerifyModel("testdata/properties/propertyOverride.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) {
- assertEquals("xyzzy", name)
- val override = references(RefKind.Override).single().to
- assertEquals("xyzzy", override.name)
- assertEquals("Foo", override.owner!!.name)
- }
- }
- }
-
- @Test fun sinceKotlin() {
- checkSourceExistsAndVerifyModel("testdata/properties/sinceKotlin.kt", defaultModelConfig) { model ->
- with(model.members.single().members.single()) {
- assertEquals("1.1", sinceKotlin)
- }
- }
- }
-}
-
-class JSPropertyTest: BasePropertyTest(Platform.js) {}
-
-class JVMPropertyTest : BasePropertyTest(Platform.jvm) {
- @Test
- fun annotatedProperty() {
- checkSourceExistsAndVerifyModel(
- "testdata/properties/annotatedProperty.kt",
- modelConfig = ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- ) { model ->
- with(model.members.single().members.single()) {
- Assert.assertEquals(1, annotations.count())
- with(annotations[0]) {
- Assert.assertEquals("Strictfp", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
- }
-
-}
-
-class CommonPropertyTest: BasePropertyTest(Platform.common) {} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/SourceLinksErrorTest.kt b/core/src/test/kotlin/model/SourceLinksErrorTest.kt
deleted file mode 100644
index 9812569d..00000000
--- a/core/src/test/kotlin/model/SourceLinksErrorTest.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.SourceLinkDefinitionImpl
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
-import org.junit.Assert
-import org.junit.Test
-import java.io.File
-
-class SourceLinksErrorTest {
-
- @Test
- fun absolutePath_notMatching() {
- val sourceLink = SourceLinkDefinitionImpl(File("testdata/nonExisting").absolutePath, "http://...", null)
- verifyNoSourceUrl(sourceLink)
- }
-
- @Test
- fun relativePath_notMatching() {
- val sourceLink = SourceLinkDefinitionImpl("testdata/nonExisting", "http://...", null)
- verifyNoSourceUrl(sourceLink)
- }
-
- private fun verifyNoSourceUrl(sourceLink: SourceLinkDefinitionImpl) {
- checkSourceExistsAndVerifyModel("testdata/sourceLinks/dummy.kt", ModelConfig(sourceLinks = listOf(sourceLink))) { model ->
- with(model.members.single().members.single()) {
- Assert.assertEquals("foo", name)
- Assert.assertEquals(NodeKind.Function, kind)
- Assert.assertTrue("should not have source urls", details(NodeKind.SourceUrl).isEmpty())
- }
- }
- }
-}
-
diff --git a/core/src/test/kotlin/model/SourceLinksTest.kt b/core/src/test/kotlin/model/SourceLinksTest.kt
deleted file mode 100644
index a4ba870c..00000000
--- a/core/src/test/kotlin/model/SourceLinksTest.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.SourceLinkDefinitionImpl
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
-import org.junit.Assert
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.Parameterized
-import java.io.File
-
-@RunWith(Parameterized::class)
-class SourceLinksTest(
- private val srcLink: String,
- private val url: String,
- private val lineSuffix: String?,
- private val expectedUrl: String
-) {
-
- @Test
- fun test() {
- val link = if(srcLink.contains(sourceLinks)){
- srcLink.substringBeforeLast(sourceLinks) + sourceLinks
- } else {
- srcLink.substringBeforeLast(testdata) + testdata
- }
- val sourceLink = SourceLinkDefinitionImpl(link, url, lineSuffix)
-
- checkSourceExistsAndVerifyModel(filePath, ModelConfig(sourceLinks = listOf(sourceLink))) { model ->
- with(model.members.single().members.single()) {
- Assert.assertEquals("foo", name)
- Assert.assertEquals(NodeKind.Function, kind)
- Assert.assertEquals(expectedUrl, details(NodeKind.SourceUrl).single().name)
- }
- }
- }
-
- companion object {
- private const val testdata = "testdata"
- private const val sourceLinks = "sourceLinks"
- private const val dummy = "dummy.kt"
- private const val pathSuffix = "$sourceLinks/$dummy"
- private const val filePath = "$testdata/$pathSuffix"
- private const val url = "https://example.com"
-
- @Parameterized.Parameters(name = "{index}: {0}, {1}, {2} = {3}")
- @JvmStatic
- fun data(): Collection<Array<String?>> {
- val longestPath = File(testdata).absolutePath.removeSuffix("/") + "/../$testdata/"
- val maxLength = longestPath.length
- val list = listOf(
- arrayOf(File(testdata).absolutePath.removeSuffix("/"), "$url/$pathSuffix"),
- arrayOf(File("$testdata/$sourceLinks").absolutePath.removeSuffix("/") + "/", "$url/$dummy"),
- arrayOf(longestPath, "$url/$pathSuffix"),
-
- arrayOf(testdata, "$url/$pathSuffix"),
- arrayOf("./$testdata", "$url/$pathSuffix"),
- arrayOf("../core/$testdata", "$url/$pathSuffix"),
- arrayOf("$testdata/$sourceLinks", "$url/$dummy"),
- arrayOf("./$testdata/../$testdata/$sourceLinks", "$url/$dummy")
- )
-
- return list.map { arrayOf(it[0].padEnd(maxLength, '_'), url, null, it[1]) } +
- listOf(
- // check that it also works if url ends with /
- arrayOf((File(testdata).absolutePath.removeSuffix("/") + "/").padEnd(maxLength, '_'), "$url/", null, "$url/$pathSuffix"),
- // check if line suffix work
- arrayOf<String?>("../core/../core/./$testdata/$sourceLinks/".padEnd(maxLength, '_'), "$url/", "#L", "$url/$dummy#L4")
- )
- }
- }
-
-}
-
diff --git a/core/src/test/kotlin/model/TypeAliasTest.kt b/core/src/test/kotlin/model/TypeAliasTest.kt
deleted file mode 100644
index 71976dc3..00000000
--- a/core/src/test/kotlin/model/TypeAliasTest.kt
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import junit.framework.TestCase.assertEquals
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.junit.Test
-
-class TypeAliasTest {
- @Test
- fun testSimple() {
- checkSourceExistsAndVerifyModel("testdata/typealias/simple.kt") {
- val pkg = it.members.single()
- with(pkg.member(NodeKind.TypeAlias)) {
- assertEquals(Content.Empty, content)
- assertEquals("B", name)
- assertEquals("A", detail(NodeKind.TypeAliasUnderlyingType).name)
- }
- }
- }
-
- @Test
- fun testInheritanceFromTypeAlias() {
- checkSourceExistsAndVerifyModel("testdata/typealias/inheritanceFromTypeAlias.kt") {
- val pkg = it.members.single()
- with(pkg.member(NodeKind.TypeAlias)) {
- assertEquals(Content.Empty, content)
- assertEquals("Same", name)
- assertEquals("Some", detail(NodeKind.TypeAliasUnderlyingType).name)
- assertEquals("My", inheritors.single().name)
- }
- with(pkg.members(NodeKind.Class).find { it.name == "My" }!!) {
- assertEquals("Same", detail(NodeKind.Supertype).name)
- }
- }
- }
-
- @Test
- fun testChain() {
- checkSourceExistsAndVerifyModel("testdata/typealias/chain.kt") {
- val pkg = it.members.single()
- with(pkg.members(NodeKind.TypeAlias).find { it.name == "B" }!!) {
- assertEquals(Content.Empty, content)
- assertEquals("A", detail(NodeKind.TypeAliasUnderlyingType).name)
- }
- with(pkg.members(NodeKind.TypeAlias).find { it.name == "C" }!!) {
- assertEquals(Content.Empty, content)
- assertEquals("B", detail(NodeKind.TypeAliasUnderlyingType).name)
- }
- }
- }
-
- @Test
- fun testDocumented() {
- checkSourceExistsAndVerifyModel("testdata/typealias/documented.kt") {
- val pkg = it.members.single()
- with(pkg.member(NodeKind.TypeAlias)) {
- assertEquals("Just typealias", content.summary.toTestString())
- }
- }
- }
-
- @Test
- fun testDeprecated() {
- checkSourceExistsAndVerifyModel("testdata/typealias/deprecated.kt") {
- val pkg = it.members.single()
- with(pkg.member(NodeKind.TypeAlias)) {
- assertEquals(Content.Empty, content)
- assertEquals("Deprecated", deprecation!!.name)
- assertEquals("\"Not mainstream now\"", deprecation!!.detail(NodeKind.Parameter).detail(NodeKind.Value).name)
- }
- }
- }
-
- @Test
- fun testGeneric() {
- checkSourceExistsAndVerifyModel("testdata/typealias/generic.kt") {
- val pkg = it.members.single()
- with(pkg.members(NodeKind.TypeAlias).find { it.name == "B" }!!) {
- assertEquals("Any", detail(NodeKind.TypeAliasUnderlyingType).detail(NodeKind.Type).name)
- }
-
- with(pkg.members(NodeKind.TypeAlias).find { it.name == "C" }!!) {
- assertEquals("T", detail(NodeKind.TypeAliasUnderlyingType).detail(NodeKind.Type).name)
- assertEquals("T", detail(NodeKind.TypeParameter).name)
- }
- }
- }
-
- @Test
- fun testFunctional() {
- checkSourceExistsAndVerifyModel("testdata/typealias/functional.kt") {
- val pkg = it.members.single()
- with(pkg.member(NodeKind.TypeAlias)) {
- assertEquals("Function1", detail(NodeKind.TypeAliasUnderlyingType).name)
- val typeParams = detail(NodeKind.TypeAliasUnderlyingType).details(NodeKind.Type)
- assertEquals("A", typeParams.first().name)
- assertEquals("B", typeParams.last().name)
- }
-
- with(pkg.member(NodeKind.Function)) {
- assertEquals("Spell", detail(NodeKind.Parameter).detail(NodeKind.Type).name)
- }
- }
- }
-
- @Test
- fun testAsTypeBoundWithVariance() {
- checkSourceExistsAndVerifyModel("testdata/typealias/asTypeBoundWithVariance.kt") {
- val pkg = it.members.single()
- with(pkg.members(NodeKind.Class).find { it.name == "C" }!!) {
- val tParam = detail(NodeKind.TypeParameter)
- assertEquals("out", tParam.detail(NodeKind.Modifier).name)
- assertEquals("B", tParam.detail(NodeKind.Type).link(NodeKind.TypeAlias).name)
- }
-
- with(pkg.members(NodeKind.Class).find { it.name == "D" }!!) {
- val tParam = detail(NodeKind.TypeParameter)
- assertEquals("in", tParam.detail(NodeKind.Modifier).name)
- assertEquals("B", tParam.detail(NodeKind.Type).link(NodeKind.TypeAlias).name)
- }
- }
- }
-
- @Test
- fun sinceKotlin() {
- checkSourceExistsAndVerifyModel("testdata/typealias/sinceKotlin.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("1.1", sinceKotlin)
- }
- }
- }
-} \ No newline at end of file
diff --git a/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
deleted file mode 100644
index ca6ee9ce..00000000
--- a/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
+++ /dev/null
@@ -1 +0,0 @@
-mock-maker-inline \ No newline at end of file