diff options
Diffstat (limited to 'core/src/test')
24 files changed, 412 insertions, 400 deletions
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index bcbbf2fc..7042f41b 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot import org.jetbrains.kotlin.config.ContentRoot import org.jetbrains.kotlin.config.KotlinSourceRoot 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 @@ -24,7 +25,7 @@ data class ModelConfig( val format: String = "html", val includeNonPublic: Boolean = true, val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(), - val analysisPlatform: Platform = Platform.js, + val analysisPlatform: Platform = Platform.DEFAULT, val defaultPlatforms: List<String> = emptyList() ) @@ -84,18 +85,22 @@ fun appendDocumentation(documentation: DocumentationModule, val environment = AnalysisEnvironment(messageCollector, modelConfig.analysisPlatform) environment.apply { if (modelConfig.withJdk || modelConfig.withKotlinRuntime) { - val stringRoot = PathManager.getResourceRoot(String::class.java, "/java/lang/String.class") - addClasspath(File(stringRoot)) + addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) } if (modelConfig.withKotlinRuntime) { - val kotlinStrictfpRoot = PathManager.getResourceRoot(Strictfp::class.java, "/kotlin/jvm/Strictfp.class") - addClasspath(File(kotlinStrictfpRoot)) + if (analysisPlatform == Platform.jvm) { + val kotlinStrictfpRoot = PathManager.getResourceRoot(Strictfp::class.java, "/kotlin/jvm/Strictfp.class") + addClasspath(File(kotlinStrictfpRoot)) + } // TODO: Fix concrete path to correct gradle path providing if (analysisPlatform == Platform.js) { addClasspath(File("/home/jetbrains/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.5281.24/plugins/Kotlin/kotlinc/lib/kotlin-jslib.jar")) addClasspath(File("/home/jetbrains/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.5281.24/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-js.jar")) addClasspath(File("/home/jetbrains/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.5281.24/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-js-sources.jar")) } + if (analysisPlatform == Platform.common) { + addClasspath(File("/home/jetbrains/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.2.51/e4a9d4b13ab19ed1e6531fce6df98e8cfa7f7301/kotlin-stdlib-common-1.2.51.jar")) + } } addRoots(modelConfig.roots.toList()) diff --git a/core/src/test/kotlin/format/GFMFormatTest.kt b/core/src/test/kotlin/format/GFMFormatTest.kt index b90ab2bf..60de7d29 100644 --- a/core/src/test/kotlin/format/GFMFormatTest.kt +++ b/core/src/test/kotlin/format/GFMFormatTest.kt @@ -2,23 +2,26 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.GFMFormatService import org.jetbrains.dokka.KotlinLanguageService +import org.jetbrains.dokka.Platform import org.junit.Test -class GFMFormatTest : FileGeneratorTestCase() { +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") + verifyGFMNodeByName("sample", "Foo", defaultModelConfig) } @Test fun listInTableCell() { - verifyGFMNodeByName("listInTableCell", "Foo") + verifyGFMNodeByName("listInTableCell", "Foo", defaultModelConfig) } - private fun verifyGFMNodeByName(fileName: String, name: String) { - verifyOutput("testdata/format/gfm/$fileName.kt", ".md") { model, output -> + 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 @@ -26,3 +29,8 @@ class GFMFormatTest : FileGeneratorTestCase() { } } } + + +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/BaseHtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt index 7fd331cf..20891963 100644 --- a/core/src/test/kotlin/format/BaseHtmlFormatTest.kt +++ b/core/src/test/kotlin/format/HtmlFormatTest.kt @@ -144,3 +144,50 @@ abstract class BaseHtmlFormatTest(val analysisPlatform: Platform): FileGenerator } } +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"), + 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/JSHtmlFormatTest.kt b/core/src/test/kotlin/format/JSHtmlFormatTest.kt deleted file mode 100644 index afa0ce0a..00000000 --- a/core/src/test/kotlin/format/JSHtmlFormatTest.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.dokka.tests.format - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseHtmlFormatTest - -class JSHtmlFormatTest: BaseHtmlFormatTest(Platform.js) {}
\ No newline at end of file diff --git a/core/src/test/kotlin/format/JSMarkdownFormatTest.kt b/core/src/test/kotlin/format/JSMarkdownFormatTest.kt deleted file mode 100644 index ca92d9f6..00000000 --- a/core/src/test/kotlin/format/JSMarkdownFormatTest.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.jetbrains.dokka.tests.format - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseMarkdownFormatTest - -class JSMarkdownFormatTest: BaseMarkdownFormatTest(Platform.js) { -}
\ No newline at end of file diff --git a/core/src/test/kotlin/format/JVMHtmlFormatTest.kt b/core/src/test/kotlin/format/JVMHtmlFormatTest.kt deleted file mode 100644 index 1696ffb2..00000000 --- a/core/src/test/kotlin/format/JVMHtmlFormatTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -package org.jetbrains.dokka.tests.format - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseHtmlFormatTest -import org.jetbrains.dokka.tests.ModelConfig -import org.jetbrains.dokka.tests.verifyOutput -import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot -import org.jetbrains.kotlin.config.KotlinSourceRoot -import org.junit.Test -import java.io.File - -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"), - 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" } - } - } - -}
\ No newline at end of file diff --git a/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt b/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt deleted file mode 100644 index ee8169af..00000000 --- a/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt +++ /dev/null @@ -1,117 +0,0 @@ -package org.jetbrains.dokka.tests.format - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.contentRootFromPath -import org.jetbrains.dokka.tests.BaseMarkdownFormatTest -import org.jetbrains.dokka.tests.ModelConfig -import org.jetbrains.dokka.tests.verifyOutput -import org.junit.Test - -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() { - verifyJavaMarkdownNode("javaCodeInParam", defaultModelConfig) - } - - @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) - } -} diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt index c02d3ad4..5df43017 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt @@ -3,35 +3,36 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.* import org.junit.Test -class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { +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") + verifyKWSNodeByName("dropImport", "foo", defaultModelConfig) } @Test fun sample() { - verifyKWSNodeByName("sample", "foo") + verifyKWSNodeByName("sample", "foo", defaultModelConfig) } @Test fun sampleWithAsserts() { - verifyKWSNodeByName("sampleWithAsserts", "a") + verifyKWSNodeByName("sampleWithAsserts", "a", defaultModelConfig) } @Test fun newLinesInSamples() { - verifyKWSNodeByName("newLinesInSamples", "foo") + verifyKWSNodeByName("newLinesInSamples", "foo", defaultModelConfig) } @Test fun newLinesInImportList() { - verifyKWSNodeByName("newLinesInImportList", "foo") + verifyKWSNodeByName("newLinesInImportList", "foo", defaultModelConfig) } @Test fun returnTag() { - verifyKWSNodeByName("returnTag", "indexOf") + verifyKWSNodeByName("returnTag", "indexOf", defaultModelConfig) } @Test fun overloadGroup() { - verifyKWSNodeByName("overloadGroup", "magic") + verifyKWSNodeByName("overloadGroup", "magic", defaultModelConfig) } @Test fun dataTags() { @@ -51,8 +52,12 @@ class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { verifyMultiplatformPackage(module, path) } - private fun verifyKWSNodeByName(fileName: String, name: String) { - verifyOutput("testdata/format/website-html/$fileName.kt", ".html", ModelConfig(format = "kotlin-website-html")) { model, output -> + 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) } } @@ -96,3 +101,7 @@ class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { } } + +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/BaseMarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 5612b1fd..6c62587b 100644 --- a/core/src/test/kotlin/format/BaseMarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -465,3 +465,116 @@ abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGener } } } + +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() { + verifyJavaMarkdownNode("javaCodeInParam", defaultModelConfig) + } + + @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/issues/IssuesTest.kt b/core/src/test/kotlin/issues/IssuesTest.kt index 58b3a2d2..da5acd6e 100644 --- a/core/src/test/kotlin/issues/IssuesTest.kt +++ b/core/src/test/kotlin/issues/IssuesTest.kt @@ -2,18 +2,19 @@ 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 - -class IssuesTest { +abstract class BaseIssuesTest(val analysisPlatform: Platform) { + val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform) @Test fun errorClasses() { checkSourceExistsAndVerifyModel("testdata/issues/errorClasses.kt", - modelConfig = ModelConfig(withJdk = true, withKotlinRuntime = true)) { model -> + 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 @@ -27,3 +28,7 @@ class IssuesTest { } } } + +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 index dc576b61..7976fccc 100644 --- a/core/src/test/kotlin/javadoc/JavadocTest.kt +++ b/core/src/test/kotlin/javadoc/JavadocTest.kt @@ -11,8 +11,10 @@ import org.junit.Assert.* import org.junit.Test class JavadocTest { + val defaultModelConfig = ModelConfig(analysisPlatform = Platform.jvm) + @Test fun testTypes() { - verifyJavadoc("testdata/javadoc/types.kt", ModelConfig(withJdk = true)) { doc -> + 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" }!! @@ -28,7 +30,7 @@ class JavadocTest { } @Test fun testObject() { - verifyJavadoc("testdata/javadoc/obj.kt") { doc -> + verifyJavadoc("testdata/javadoc/obj.kt", defaultModelConfig) { doc -> val classDoc = doc.classNamed("foo.O") assertNotNull(classDoc) @@ -41,7 +43,10 @@ class JavadocTest { } @Test fun testException() { - verifyJavadoc("testdata/javadoc/exception.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + 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()) @@ -49,7 +54,10 @@ class JavadocTest { } @Test fun testByteArray() { - verifyJavadoc("testdata/javadoc/bytearr.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + verifyJavadoc( + "testdata/javadoc/bytearr.kt", + ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true) + ) { doc -> val classDoc = doc.classNamed("foo.ByteArray")!! assertNotNull(classDoc.asClassDoc()) @@ -59,7 +67,10 @@ class JavadocTest { } @Test fun testStringArray() { - verifyJavadoc("testdata/javadoc/stringarr.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + verifyJavadoc( + "testdata/javadoc/stringarr.kt", + ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true) + ) { doc -> val classDoc = doc.classNamed("foo.Foo")!! assertNotNull(classDoc.asClassDoc()) @@ -72,7 +83,10 @@ class JavadocTest { } @Test fun testJvmName() { - verifyJavadoc("testdata/javadoc/jvmname.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + verifyJavadoc( + "testdata/javadoc/jvmname.kt", + ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true) + ) { doc -> val classDoc = doc.classNamed("foo.Apple")!! assertNotNull(classDoc.asClassDoc()) @@ -82,7 +96,10 @@ class JavadocTest { } @Test fun testLinkWithParam() { - verifyJavadoc("testdata/javadoc/paramlink.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + 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>() @@ -93,7 +110,10 @@ class JavadocTest { } @Test fun testInternalVisibility() { - verifyJavadoc("testdata/javadoc/internal.kt", ModelConfig(withKotlinRuntime = true, includeNonPublic = false)) { doc -> + 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) @@ -102,7 +122,10 @@ class JavadocTest { } @Test fun testSuppress() { - verifyJavadoc("testdata/javadoc/suppress.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + verifyJavadoc( + "testdata/javadoc/suppress.kt", + ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true) + ) { doc -> assertNull(doc.classNamed("Some")) assertNull(doc.classNamed("SomeAgain")) assertNull(doc.classNamed("Interface")) @@ -113,7 +136,10 @@ class JavadocTest { } @Test fun testTypeAliases() { - verifyJavadoc("testdata/javadoc/typealiases.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + verifyJavadoc( + "testdata/javadoc/typealiases.kt", + ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true) + ) { doc -> assertNull(doc.classNamed("B")) assertNull(doc.classNamed("D")) @@ -128,7 +154,10 @@ class JavadocTest { } @Test fun testKDocKeywordsOnMethod() { - verifyJavadoc("testdata/javadoc/kdocKeywordsOnMethod.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + 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()) @@ -138,7 +167,10 @@ class JavadocTest { @Test fun testBlankLineInsideCodeBlock() { - verifyJavadoc("testdata/javadoc/blankLineInsideCodeBlock.kt", ModelConfig(withKotlinRuntime = true)) { doc -> + 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(""" @@ -155,7 +187,7 @@ class JavadocTest { @Test fun testCompanionMethodReference() { - verifyJavadoc("testdata/javadoc/companionMethodReference.kt") { doc -> + 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()) diff --git a/core/src/test/kotlin/model/BaseClassTest.kt b/core/src/test/kotlin/model/ClassTest.kt index d48ecb48..b8e58a62 100644 --- a/core/src/test/kotlin/model/BaseClassTest.kt +++ b/core/src/test/kotlin/model/ClassTest.kt @@ -4,6 +4,7 @@ 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 @@ -267,3 +268,51 @@ abstract class BaseClassTest(val analysisPlatform: Platform) { } } + +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 index a97c55eb..08aa3572 100644 --- a/core/src/test/kotlin/model/CommentTest.kt +++ b/core/src/test/kotlin/model/CommentTest.kt @@ -4,10 +4,10 @@ import org.junit.Test import org.junit.Assert.* import org.jetbrains.dokka.* -public class CommentTest { - +abstract class BaseCommentTest(val analysisPlatform: Platform) { + val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform) @Test fun codeBlockComment() { - checkSourceExistsAndVerifyModel("testdata/comments/codeBlockComment.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/codeBlockComment.kt", defaultModelConfig) { model -> with(model.members.single().members.first()) { assertEqualsIgnoringSeparators("""[code lang=brainfuck] | @@ -30,7 +30,7 @@ public class CommentTest { } @Test fun emptyDoc() { - checkSourceExistsAndVerifyModel("testdata/comments/emptyDoc.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/emptyDoc.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals(Content.Empty, content) } @@ -38,7 +38,7 @@ public class CommentTest { } @Test fun emptyDocButComment() { - checkSourceExistsAndVerifyModel("testdata/comments/emptyDocButComment.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/emptyDocButComment.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals(Content.Empty, content) } @@ -46,7 +46,7 @@ public class CommentTest { } @Test fun multilineDoc() { - checkSourceExistsAndVerifyModel("testdata/comments/multilineDoc.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/multilineDoc.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("doc1", content.summary.toTestString()) assertEquals("doc2\ndoc3", content.description.toTestString()) @@ -55,7 +55,7 @@ public class CommentTest { } @Test fun multilineDocWithComment() { - checkSourceExistsAndVerifyModel("testdata/comments/multilineDocWithComment.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/multilineDocWithComment.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("doc1", content.summary.toTestString()) assertEquals("doc2\ndoc3", content.description.toTestString()) @@ -64,7 +64,7 @@ public class CommentTest { } @Test fun oneLineDoc() { - checkSourceExistsAndVerifyModel("testdata/comments/oneLineDoc.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/oneLineDoc.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("doc", content.summary.toTestString()) } @@ -72,7 +72,7 @@ public class CommentTest { } @Test fun oneLineDocWithComment() { - checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithComment.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithComment.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("doc", content.summary.toTestString()) } @@ -80,7 +80,7 @@ public class CommentTest { } @Test fun oneLineDocWithEmptyLine() { - checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithEmptyLine.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithEmptyLine.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("doc", content.summary.toTestString()) } @@ -88,7 +88,7 @@ public class CommentTest { } @Test fun emptySection() { - checkSourceExistsAndVerifyModel("testdata/comments/emptySection.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/emptySection.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) assertEquals(1, content.sections.count()) @@ -101,7 +101,7 @@ public class CommentTest { } @Test fun quotes() { - checkSourceExistsAndVerifyModel("testdata/comments/quotes.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/quotes.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("it's \"useful\"", content.summary.toTestString()) } @@ -109,7 +109,7 @@ public class CommentTest { } @Test fun section1() { - checkSourceExistsAndVerifyModel("testdata/comments/section1.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/section1.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) assertEquals(1, content.sections.count()) @@ -122,7 +122,7 @@ public class CommentTest { } @Test fun section2() { - checkSourceExistsAndVerifyModel("testdata/comments/section2.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/section2.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) assertEquals(2, content.sections.count()) @@ -139,7 +139,7 @@ public class CommentTest { } @Test fun multilineSection() { - checkSourceExistsAndVerifyModel("testdata/comments/multilineSection.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/multilineSection.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) assertEquals(1, content.sections.count()) @@ -153,7 +153,7 @@ line two""", toTestString()) } @Test fun directive() { - checkSourceExistsAndVerifyModel("testdata/comments/directive.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/comments/directive.kt", defaultModelConfig) { model -> with(model.members.single().members.first()) { assertEquals("Summary", content.summary.toTestString()) with (content.description) { @@ -184,3 +184,7 @@ line two""", 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/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt index 2704bf65..47685df2 100644 --- a/core/src/test/kotlin/model/FunctionTest.kt +++ b/core/src/test/kotlin/model/FunctionTest.kt @@ -4,6 +4,7 @@ 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 @@ -229,3 +230,25 @@ Documentation""", content.description.toTestString()) } } } + +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/JSClassTest.kt b/core/src/test/kotlin/model/JSClassTest.kt deleted file mode 100644 index e39b95cc..00000000 --- a/core/src/test/kotlin/model/JSClassTest.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.dokka.tests.model - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseClassTest - -class JSClassTest: BaseClassTest(Platform.js) {}
\ No newline at end of file diff --git a/core/src/test/kotlin/model/JSFunctionTest.kt b/core/src/test/kotlin/model/JSFunctionTest.kt deleted file mode 100644 index f6b987a9..00000000 --- a/core/src/test/kotlin/model/JSFunctionTest.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.jetbrains.dokka.tests.model - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseFunctionTest - -class JSFunctionTest: BaseFunctionTest(Platform.js) { - -}
\ No newline at end of file diff --git a/core/src/test/kotlin/model/JSPropertyTest.kt b/core/src/test/kotlin/model/JSPropertyTest.kt deleted file mode 100644 index 0193d899..00000000 --- a/core/src/test/kotlin/model/JSPropertyTest.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.jetbrains.dokka.tests.model - -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BasePropertyTest - -class JSPropertyTest: BasePropertyTest(Platform.js) { - -}
\ No newline at end of file diff --git a/core/src/test/kotlin/model/JVMClassTest.kt b/core/src/test/kotlin/model/JVMClassTest.kt deleted file mode 100644 index 22e23722..00000000 --- a/core/src/test/kotlin/model/JVMClassTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.jetbrains.dokka.tests.model - -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.NodeKind -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseClassTest -import org.jetbrains.dokka.tests.ModelConfig -import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel -import org.jetbrains.dokka.tests.verifyPackageMember -import org.junit.Assert -import org.junit.Test - -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) - } - } - } - } - } - } - -}
\ No newline at end of file diff --git a/core/src/test/kotlin/model/JVMFunctionTest.kt b/core/src/test/kotlin/model/JVMFunctionTest.kt deleted file mode 100644 index a2fb0d2a..00000000 --- a/core/src/test/kotlin/model/JVMFunctionTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -package org.jetbrains.dokka.tests.model - -import com.sun.tools.javac.util.BaseFileManager -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.NodeKind -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BaseFunctionTest -import org.jetbrains.dokka.tests.ModelConfig -import org.jetbrains.dokka.tests.verifyPackageMember -import org.junit.Assert -import org.junit.Test - -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) - } - } - } - -}
\ No newline at end of file diff --git a/core/src/test/kotlin/model/JVMPropertyTest.kt b/core/src/test/kotlin/model/JVMPropertyTest.kt deleted file mode 100644 index 182dedbe..00000000 --- a/core/src/test/kotlin/model/JVMPropertyTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.jetbrains.dokka.tests.model - -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.NodeKind -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.tests.BasePropertyTest -import org.jetbrains.dokka.tests.ModelConfig -import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel -import org.junit.Assert -import org.junit.Test - -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("Volatile", name) - Assert.assertEquals(Content.Empty, content) - Assert.assertEquals(NodeKind.Annotation, kind) - } - } - } - } - -}
\ No newline at end of file diff --git a/core/src/test/kotlin/model/KotlinAsJavaTest.kt b/core/src/test/kotlin/model/KotlinAsJavaTest.kt index 1d95556f..f6f0aa20 100644 --- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt +++ b/core/src/test/kotlin/model/KotlinAsJavaTest.kt @@ -7,8 +7,6 @@ import org.junit.Test import org.junit.Assert.assertEquals class KotlinAsJavaTest { - private val defaultModelConfig = ModelConfig (analysisPlatform = Platform.jvm) - @Test fun function() { verifyModelAsJava("testdata/functions/function.kt") { model -> val pkg = model.members.single() @@ -33,14 +31,13 @@ class KotlinAsJavaTest { } fun verifyModelAsJava(source: String, - withJdk: Boolean = false, - withKotlinRuntime: Boolean = false, + modelConfig: ModelConfig = ModelConfig(), verifier: (DocumentationModule) -> Unit) { checkSourceExistsAndVerifyModel( source, modelConfig = ModelConfig( - withJdk = withJdk, - withKotlinRuntime = withKotlinRuntime, + 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 index d7283bae..9b2f9f0d 100644 --- a/core/src/test/kotlin/model/LinkTest.kt +++ b/core/src/test/kotlin/model/LinkTest.kt @@ -3,12 +3,14 @@ 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 -class LinkTest { +abstract class BaseLinkTest(val analysisPlatform: Platform) { + private val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform) @Test fun linkToSelf() { - checkSourceExistsAndVerifyModel("testdata/links/linkToSelf.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/links/linkToSelf.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) assertEquals(NodeKind.Class, kind) @@ -18,7 +20,7 @@ class LinkTest { } @Test fun linkToMember() { - checkSourceExistsAndVerifyModel("testdata/links/linkToMember.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/links/linkToMember.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) assertEquals(NodeKind.Class, kind) @@ -28,7 +30,7 @@ class LinkTest { } @Test fun linkToConstantWithUnderscores() { - checkSourceExistsAndVerifyModel("testdata/links/linkToConstantWithUnderscores.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/links/linkToConstantWithUnderscores.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) assertEquals(NodeKind.Class, kind) @@ -38,7 +40,7 @@ class LinkTest { } @Test fun linkToQualifiedMember() { - checkSourceExistsAndVerifyModel("testdata/links/linkToQualifiedMember.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/links/linkToQualifiedMember.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) assertEquals(NodeKind.Class, kind) @@ -48,7 +50,7 @@ class LinkTest { } @Test fun linkToParam() { - checkSourceExistsAndVerifyModel("testdata/links/linkToParam.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/links/linkToParam.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) assertEquals(NodeKind.Function, kind) @@ -58,7 +60,7 @@ class LinkTest { } @Test fun linkToPackage() { - checkSourceExistsAndVerifyModel("testdata/links/linkToPackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/links/linkToPackage.kt", defaultModelConfig) { model -> val packageNode = model.members.single() with(packageNode) { assertEquals(this.name, "test.magic") @@ -72,4 +74,8 @@ class LinkTest { } } -}
\ No newline at end of file +} + +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 index bc8a0e0d..80a2fd56 100644 --- a/core/src/test/kotlin/model/PackageTest.kt +++ b/core/src/test/kotlin/model/PackageTest.kt @@ -1,15 +1,14 @@ package org.jetbrains.dokka.tests -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.NodeKind -import org.jetbrains.dokka.PackageOptionsImpl +import org.jetbrains.dokka.* import org.jetbrains.kotlin.config.KotlinSourceRoot import org.junit.Assert.* import org.junit.Test -public class PackageTest { +abstract class BasePackageTest(val analysisPlatform: Platform) { + val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform) @Test fun rootPackage() { - checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt", defaultModelConfig) { model -> with(model.members.single()) { assertEquals(NodeKind.Package, kind) assertEquals("", name) @@ -22,7 +21,7 @@ public class PackageTest { } @Test fun simpleNamePackage() { - checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt", defaultModelConfig) { model -> with(model.members.single()) { assertEquals(NodeKind.Package, kind) assertEquals("simple", name) @@ -35,7 +34,7 @@ public class PackageTest { } @Test fun dottedNamePackage() { - checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt", defaultModelConfig) { model -> with(model.members.single()) { assertEquals(NodeKind.Package, kind) assertEquals("dot.name", name) @@ -53,7 +52,8 @@ public class PackageTest { roots = arrayOf( KotlinSourceRoot("testdata/packages/dottedNamePackage.kt"), KotlinSourceRoot("testdata/packages/simpleNamePackage.kt") - ) + ), + analysisPlatform = analysisPlatform ) ) { model -> assertEquals(2, model.members.count()) @@ -81,7 +81,8 @@ public class PackageTest { roots = arrayOf( KotlinSourceRoot("testdata/packages/simpleNamePackage.kt"), KotlinSourceRoot("testdata/packages/simpleNamePackage2.kt") - ) + ), + analysisPlatform = analysisPlatform ) ) { model -> assertEquals(1, model.members.count()) @@ -98,7 +99,10 @@ public class PackageTest { @Test fun classAtPackageLevel() { verifyModel( - ModelConfig(roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt"))) + ModelConfig( + roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")), + analysisPlatform = analysisPlatform + ) ) { model -> assertEquals(1, model.members.count()) with(model.members.elementAt(0)) { @@ -118,7 +122,8 @@ public class PackageTest { roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")), perPackageOptions = listOf( PackageOptionsImpl(prefix = "simple.name", suppress = true) - ) + ), + analysisPlatform = analysisPlatform ) ) { model -> assertEquals(1, model.members.count()) @@ -133,3 +138,7 @@ public class PackageTest { } } } + +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/BasePropertyTest.kt b/core/src/test/kotlin/model/PropertyTest.kt index c88fe702..a41ab5a3 100644 --- a/core/src/test/kotlin/model/BasePropertyTest.kt +++ b/core/src/test/kotlin/model/PropertyTest.kt @@ -1,6 +1,7 @@ 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 @@ -99,3 +100,30 @@ abstract class BasePropertyTest(val analysisPlatform: Platform) { } } } + +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("Volatile", name) + Assert.assertEquals(Content.Empty, content) + Assert.assertEquals(NodeKind.Annotation, kind) + } + } + } + } + +} + +class CommonPropertyTest: BasePropertyTest(Platform.common) {}
\ No newline at end of file |