aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/model
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/kotlin/model')
-rw-r--r--core/src/test/kotlin/model/ClassTest.kt322
-rw-r--r--core/src/test/kotlin/model/CommentTest.kt195
-rw-r--r--core/src/test/kotlin/model/FunctionTest.kt284
-rw-r--r--core/src/test/kotlin/model/JavaTest.kt213
-rw-r--r--core/src/test/kotlin/model/KotlinAsJavaTest.kt68
-rw-r--r--core/src/test/kotlin/model/LinkTest.kt94
-rw-r--r--core/src/test/kotlin/model/PackageTest.kt139
-rw-r--r--core/src/test/kotlin/model/PropertyTest.kt131
-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.kt134
11 files changed, 0 insertions, 1690 deletions
diff --git a/core/src/test/kotlin/model/ClassTest.kt b/core/src/test/kotlin/model/ClassTest.kt
deleted file mode 100644
index b479e59e..00000000
--- a/core/src/test/kotlin/model/ClassTest.kt
+++ /dev/null
@@ -1,322 +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.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.toTestString
-import org.jetbrains.dokka.testApi.verifyPackageMember
-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 b94e9d0c..00000000
--- a/core/src/test/kotlin/model/CommentTest.kt
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.assertEqualsIgnoringSeparators
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.toTestString
-import org.junit.Assert.assertEquals
-import org.junit.Test
-
-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/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt
deleted file mode 100644
index 9900446a..00000000
--- a/core/src/test/kotlin/model/FunctionTest.kt
+++ /dev/null
@@ -1,284 +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.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.toTestString
-import org.jetbrains.dokka.testApi.verifyPackageMember
-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 018ab089..00000000
--- a/core/src/test/kotlin/model/JavaTest.kt
+++ /dev/null
@@ -1,213 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.RefKind
-import org.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.toTestString
-import org.jetbrains.dokka.testApi.verifyJavaPackageMember
-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 80ff95bd..00000000
--- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt
+++ /dev/null
@@ -1,68 +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.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.toTestString
-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()
- assertEquals("fn", fn.name)
- assertEquals(NodeKind.Function, fn.kind)
- }
- }
-
- @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 08e27db8..00000000
--- a/core/src/test/kotlin/model/LinkTest.kt
+++ /dev/null
@@ -1,94 +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.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.toTestString
-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 0afbbb5d..00000000
--- a/core/src/test/kotlin/model/PackageTest.kt
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.verifyModel
-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(
- org.jetbrains.dokka.testApi.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 bce3c585..00000000
--- a/core/src/test/kotlin/model/PropertyTest.kt
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-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 2d587856..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.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.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 8f7766f6..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.testApi.ModelConfig
-import org.jetbrains.dokka.testApi.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 6c9b90a8..00000000
--- a/core/src/test/kotlin/model/TypeAliasTest.kt
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import junit.framework.TestCase.assertEquals
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.testApi.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.testApi.toTestString
-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