aboutsummaryrefslogtreecommitdiff
path: root/test/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/model')
-rw-r--r--test/src/model/ClassTest.kt275
-rw-r--r--test/src/model/CommentTest.kt153
-rw-r--r--test/src/model/FunctionTest.kt227
-rw-r--r--test/src/model/JavaTest.kt197
-rw-r--r--test/src/model/KotlinAsJavaTest.kt40
-rw-r--r--test/src/model/LinkTest.kt48
-rw-r--r--test/src/model/PackageTest.kt86
-rw-r--r--test/src/model/PropertyTest.kt103
8 files changed, 0 insertions, 1129 deletions
diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt
deleted file mode 100644
index ce4b4683..00000000
--- a/test/src/model/ClassTest.kt
+++ /dev/null
@@ -1,275 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationReference
-import org.junit.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-public class ClassTest {
- @Test fun emptyClass() {
- verifyModel("test/data/classes/emptyClass.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("Klass", name)
- assertEquals(Content.Empty, content)
- assertEquals("<init>", members.single().name)
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun emptyObject() {
- verifyModel("test/data/classes/emptyObject.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Object, kind)
- assertEquals("Obj", name)
- assertEquals(Content.Empty, content)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun classWithConstructor() {
- verifyModel("test/data/classes/classWithConstructor.kt") { model ->
- with (model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("Klass", name)
- assertEquals(Content.Empty, content)
- assertTrue(links.none())
-
- assertEquals(1, members.count())
- with(members.elementAt(0)) {
- assertEquals("<init>", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Constructor, kind)
- assertEquals(2, details.count())
- assertEquals("public", details.elementAt(0).name)
- with(details.elementAt(1)) {
- assertEquals("name", name)
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", details.single().name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
- }
-
- @Test fun classWithFunction() {
- verifyModel("test/data/classes/classWithFunction.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("Klass", name)
- assertEquals(Content.Empty, content)
- assertTrue(links.none())
-
- assertEquals(2, members.count())
- with(members.elementAt(0)) {
- assertEquals("<init>", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Constructor, kind)
- assertEquals(1, details.count())
- assertEquals("public", details.elementAt(0).name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- with(members.elementAt(1)) {
- assertEquals("fn", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("Unit", detail(DocumentationNode.Kind.Type).name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
- }
-
- @Test fun classWithProperty() {
- verifyModel("test/data/classes/classWithProperty.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("Klass", name)
- assertEquals(Content.Empty, content)
- assertTrue(links.none())
-
- assertEquals(2, members.count())
- with(members.elementAt(0)) {
- assertEquals("<init>", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Constructor, kind)
- assertEquals(1, details.count())
- assertEquals("public", details.elementAt(0).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(members.elementAt(1)) {
- assertEquals("name", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Property, kind)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
- }
-
- @Test fun classWithCompanionObject() {
- verifyModel("test/data/classes/classWithCompanionObject.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("Klass", name)
- assertEquals(Content.Empty, content)
- assertTrue(links.none())
-
- assertEquals(3, members.count())
- with(members.elementAt(0)) {
- assertEquals("<init>", name)
- assertEquals(Content.Empty, content)
- }
- with(members.elementAt(1)) {
- assertEquals("x", name)
- assertEquals(DocumentationNode.Kind.CompanionObjectProperty, kind)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(members.elementAt(2)) {
- assertEquals("foo", name)
- assertEquals(DocumentationNode.Kind.CompanionObjectFunction, kind)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
- }
-
- @Test fun annotatedClass() {
- verifyPackageMember("test/data/classes/annotatedClass.kt", withKotlinRuntime = true) { cls ->
- assertEquals(1, cls.annotations.count())
- with(cls.annotations[0]) {
- assertEquals("Strictfp", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- }
- }
- }
-
- @Test fun dataClass() {
- verifyPackageMember("test/data/classes/dataClass.kt") { cls ->
- val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
- assertTrue("data" in modifiers)
- }
- }
-
- @Test fun sealedClass() {
- verifyPackageMember("test/data/classes/sealedClass.kt") { cls ->
- val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
- assertEquals(1, modifiers.count { it == "sealed" })
- }
- }
-
- @Test fun annotatedClassWithAnnotationParameters() {
- verifyModel("test/data/classes/annotatedClassWithAnnotationParameters.kt") { model ->
- with(model.members.single().members.single()) {
- with(deprecation!!) {
- assertEquals("Deprecated", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
- assertEquals("\"should no longer be used\"", name)
- }
- }
- }
- }
- }
- }
-
- @Test fun javaAnnotationClass() {
- verifyModel("test/data/classes/javaAnnotationClass.kt", withJdk = true) { model ->
- with(model.members.single().members.single()) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("Retention", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
- assertEquals("RetentionPolicy.SOURCE", name)
- }
- }
- }
- }
- }
- }
-
- @Test fun notOpenClass() {
- verifyModel("test/data/classes/notOpenClass.kt") { model ->
- with(model.members.single().members.first { it.name == "D"}.members.first { it.name == "f" }) {
- val modifiers = details(DocumentationNode.Kind.Modifier)
- assertEquals(2, modifiers.size)
- assertEquals("final", modifiers[1].name)
-
- val overrideReferences = references(DocumentationReference.Kind.Override)
- assertEquals(1, overrideReferences.size)
- }
- }
- }
-
- @Test fun indirectOverride() {
- verifyModel("test/data/classes/indirectOverride.kt") { model ->
- with(model.members.single().members.first { it.name == "E"}.members.first { it.name == "foo" }) {
- val modifiers = details(DocumentationNode.Kind.Modifier)
- assertEquals(2, modifiers.size)
- assertEquals("final", modifiers[1].name)
-
- val overrideReferences = references(DocumentationReference.Kind.Override)
- assertEquals(1, overrideReferences.size)
- }
- }
- }
-
- @Test fun innerClass() {
- verifyPackageMember("test/data/classes/innerClass.kt") { cls ->
- val innerClass = cls.members.single { it.name == "D" }
- val modifiers = innerClass.details(DocumentationNode.Kind.Modifier)
- assertEquals(3, modifiers.size)
- assertEquals("inner", modifiers[2].name)
- }
- }
-
- @Test fun companionObjectExtension() {
- verifyModel("test/data/classes/companionObjectExtension.kt") { model ->
- val pkg = model.members.single()
- val cls = pkg.members.single { it.name == "Foo" }
- val extensions = cls.extensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectProperty }
- assertEquals(1, extensions.size)
- }
- }
-
- @Test fun secondaryConstructor() {
- verifyPackageMember("test/data/classes/secondaryConstructor.kt") { cls ->
- val constructors = cls.members(DocumentationNode.Kind.Constructor)
- assertEquals(2, constructors.size)
- with (constructors.first { it.details(DocumentationNode.Kind.Parameter).size == 1}) {
- assertEquals("<init>", name)
- assertEquals("This is a secondary constructor.", summary.toTestString())
- }
- }
- }
-}
diff --git a/test/src/model/CommentTest.kt b/test/src/model/CommentTest.kt
deleted file mode 100644
index c4d867fb..00000000
--- a/test/src/model/CommentTest.kt
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.junit.Test
-import kotlin.test.*
-import org.jetbrains.dokka.*
-
-public class CommentTest {
- @Test fun emptyDoc() {
- verifyModel("test/data/comments/emptyDoc.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(Content.Empty, content)
- }
- }
- }
-
- @Test fun emptyDocButComment() {
- verifyModel("test/data/comments/emptyDocButComment.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals(Content.Empty, content)
- }
- }
- }
-
- @Test fun multilineDoc() {
- verifyModel("test/data/comments/multilineDoc.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc1", content.summary.toTestString())
- assertEquals("doc2\ndoc3", content.description.toTestString())
- }
- }
- }
-
- @Test fun multilineDocWithComment() {
- verifyModel("test/data/comments/multilineDocWithComment.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc1", content.summary.toTestString())
- assertEquals("doc2\ndoc3", content.description.toTestString())
- }
- }
- }
-
- @Test fun oneLineDoc() {
- verifyModel("test/data/comments/oneLineDoc.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc", content.summary.toTestString())
- }
- }
- }
-
- @Test fun oneLineDocWithComment() {
- verifyModel("test/data/comments/oneLineDocWithComment.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc", content.summary.toTestString())
- }
- }
- }
-
- @Test fun oneLineDocWithEmptyLine() {
- verifyModel("test/data/comments/oneLineDocWithEmptyLine.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("doc", content.summary.toTestString())
- }
- }
- }
-
- @Test fun emptySection() {
- verifyModel("test/data/comments/emptySection.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Summary", content.summary.toTestString())
- assertEquals(1, content.sections.count())
- with (content.findSectionByTag("one")!!) {
- assertEquals("One", tag)
- assertEquals("", toTestString())
- }
- }
- }
- }
-
- @Test fun section1() {
- verifyModel("test/data/comments/section1.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Summary", content.summary.toTestString())
- assertEquals(1, content.sections.count())
- with (content.findSectionByTag("one")!!) {
- assertEquals("One", tag)
- assertEquals("section one", toTestString())
- }
- }
- }
- }
-
- @Test fun section2() {
- verifyModel("test/data/comments/section2.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Summary", content.summary.toTestString())
- assertEquals(2, content.sections.count())
- with (content.findSectionByTag("one")!!) {
- assertEquals("One", tag)
- assertEquals("section one", toTestString())
- }
- with (content.findSectionByTag("two")!!) {
- assertEquals("Two", tag)
- assertEquals("section two", toTestString())
- }
- }
- }
- }
-
- @Test fun multilineSection() {
- verifyModel("test/data/comments/multilineSection.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Summary", content.summary.toTestString())
- assertEquals(1, content.sections.count())
- with (content.findSectionByTag("one")!!) {
- assertEquals("One", tag)
- assertEquals("""line one
-line two""", toTestString())
- }
- }
- }
- }
-
- @Test fun directive() {
- verifyModel("test/data/comments/directive.kt") { model ->
- with(model.members.single().members.first()) {
- assertEquals("Summary", content.summary.toTestString())
- with (content.description) {
- assertEqualsIgnoringSeparators("""[code]
-if (true) {
- println(property)
-}
-[/code]
-[code]
-if (true) {
- println(property)
-}
-[/code]
-[code]
-if (true) {
- println(property)
-}
-[/code]
-[code]
-if (true) {
- println(property)
-}
-[/code]
-""", toTestString())
- }
- }
- }
- }
-}
diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt
deleted file mode 100644
index 8d1cf609..00000000
--- a/test/src/model/FunctionTest.kt
+++ /dev/null
@@ -1,227 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
-import org.junit.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-public class FunctionTest {
- @Test fun function() {
- verifyModel("test/data/functions/function.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("fn", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("Function fn", content.summary.toTestString())
- assertEquals("Unit", detail(DocumentationNode.Kind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun functionWithReceiver() {
- verifyModel("test/data/functions/functionWithReceiver.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("kotlin.String", name)
- assertEquals(DocumentationNode.Kind.ExternalClass, kind)
- assertEquals(2, members.count())
- with(members[0]) {
- assertEquals("fn", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("Function with receiver", content.summary.toTestString())
- assertEquals("public", details.elementAt(0).name)
- assertEquals("final", details.elementAt(1).name)
- with(details.elementAt(2)) {
- assertEquals("<this>", name)
- assertEquals(DocumentationNode.Kind.Receiver, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", details.single().name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(3).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(members[1]) {
- assertEquals("fn", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- }
- }
- }
- }
-
- @Test fun genericFunction() {
- verifyModel("test/data/functions/genericFunction.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("generic", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("generic function", content.summary.toTestString())
-
- assertEquals("private", details.elementAt(0).name)
- assertEquals("final", details.elementAt(1).name)
- with(details.elementAt(2)) {
- assertEquals("T", name)
- assertEquals(DocumentationNode.Kind.TypeParameter, kind)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(3).name)
-
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
- @Test fun genericFunctionWithConstraints() {
- verifyModel("test/data/functions/genericFunctionWithConstraints.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("generic", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("generic function", content.summary.toTestString())
-
- assertEquals("public", details.elementAt(0).name)
- assertEquals("final", details.elementAt(1).name)
- with(details.elementAt(2)) {
- assertEquals("T", name)
- assertEquals(DocumentationNode.Kind.TypeParameter, kind)
- assertEquals(Content.Empty, content)
- with(details.single()) {
- assertEquals("R", name)
- assertEquals(DocumentationNode.Kind.UpperBound, kind)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(details.elementAt(3)) {
- assertEquals("R", name)
- assertEquals(DocumentationNode.Kind.TypeParameter, kind)
- assertEquals(Content.Empty, content)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(4).name)
-
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun functionWithParams() {
- verifyModel("test/data/functions/functionWithParams.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("function", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("Multiline", content.summary.toTestString())
- assertEquals("""Function
-Documentation""", content.description.toTestString())
-
- assertEquals("public", details.elementAt(0).name)
- assertEquals("final", details.elementAt(1).name)
- with(details.elementAt(2)) {
- assertEquals("x", name)
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals("parameter", content.summary.toTestString())
- assertEquals("Int", details.single().name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- assertEquals("Unit", details.elementAt(3).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun annotatedFunction() {
- verifyPackageMember("test/data/functions/annotatedFunction.kt", withKotlinRuntime = true) { func ->
- assertEquals(1, func.annotations.count())
- with(func.annotations[0]) {
- assertEquals("Strictfp", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- }
- }
- }
-
- @Test fun functionWithNotDocumentedAnnotation() {
- verifyPackageMember("test/data/functions/functionWithNotDocumentedAnnotation.kt") { func ->
- assertEquals(0, func.annotations.count())
- }
- }
-
- @Test fun inlineFunction() {
- verifyPackageMember("test/data/functions/inlineFunction.kt") { func ->
- val modifiers = func.details(DocumentationNode.Kind.Modifier).map { it.name }
- assertTrue("inline" in modifiers)
- }
- }
-
- @Test fun functionWithAnnotatedParam() {
- verifyModel("test/data/functions/functionWithAnnotatedParam.kt") { model ->
- with(model.members.single().members.single { it.name == "function"} ) {
- with(details.elementAt(2)) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("Fancy", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- }
- }
- }
- }
- }
-
- @Test fun functionWithNoinlineParam() {
- verifyPackageMember("test/data/functions/functionWithNoinlineParam.kt") { func ->
- with(func.details.elementAt(2)) {
- val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name }
- assertTrue("noinline" in modifiers)
- }
- }
- }
-
- @Test fun annotatedFunctionWithAnnotationParameters() {
- verifyModel("test/data/functions/annotatedFunctionWithAnnotationParameters.kt") { model ->
- with(model.members.single().members.single { it.name == "f"}) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("Fancy", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
- assertEquals("1", name)
- }
- }
- }
- }
- }
- }
-
- @Test fun functionWithDefaultParameter() {
- verifyModel("test/data/functions/functionWithDefaultParameter.kt") { model ->
- with(model.members.single().members.single()) {
- with(details.elementAt(2)) {
- val value = details(DocumentationNode.Kind.Value)
- assertEquals(1, value.count())
- with(value[0]) {
- assertEquals("\"\"", name)
- }
- }
- }
- }
- }
-}
diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt
deleted file mode 100644
index 0633a5cc..00000000
--- a/test/src/model/JavaTest.kt
+++ /dev/null
@@ -1,197 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationReference
-import org.junit.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertFalse
-import kotlin.test.assertTrue
-
-public class JavaTest {
- @Test fun function() {
- verifyJavaPackageMember("test/data/java/member.java") { cls ->
- assertEquals("Test", cls.name)
- assertEquals(DocumentationNode.Kind.Class, cls.kind)
- with(cls.members(DocumentationNode.Kind.Function).single()) {
- assertEquals("fn", name)
- assertEquals("Summary for Function", content.summary.toTestString().trimEnd())
- assertEquals(3, content.sections.size)
- with(content.sections[0]) {
- assertEquals("Parameters", tag)
- assertEquals("name", subjectName)
- assertEquals("is String parameter ", toTestString())
- }
- with(content.sections[1]) {
- assertEquals("Parameters", tag)
- assertEquals("value", subjectName)
- assertEquals("is int parameter ", toTestString())
- }
- with(content.sections[2]) {
- assertEquals("Author", tag)
- assertEquals("yole", toTestString())
- }
- assertEquals("Unit", detail(DocumentationNode.Kind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- with(details.first { it.name == "name" }) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- }
- with(details.first { it.name == "value" }) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals("Int", detail(DocumentationNode.Kind.Type).name)
- }
- }
- }
- }
-
- @Test fun memberWithModifiers() {
- verifyJavaPackageMember("test/data/java/memberWithModifiers.java") { cls ->
- val modifiers = cls.details(DocumentationNode.Kind.Modifier).map { it.name }
- assertTrue("abstract" in modifiers)
- with(cls.members.single { it.name == "fn" }) {
- assertEquals("protected", details[0].name)
- }
- with(cls.members.single { it.name == "openFn" }) {
- assertEquals("open", details[1].name)
- }
- }
- }
-
- @Test fun superClass() {
- verifyJavaPackageMember("test/data/java/superClass.java") { cls ->
- val superTypes = cls.details(DocumentationNode.Kind.Supertype)
- assertEquals(2, superTypes.size)
- assertEquals("Exception", superTypes[0].name)
- assertEquals("Cloneable", superTypes[1].name)
- }
- }
-
- @Test fun arrayType() {
- verifyJavaPackageMember("test/data/java/arrayType.java") { cls ->
- with(cls.members(DocumentationNode.Kind.Function).single()) {
- val type = detail(DocumentationNode.Kind.Type)
- assertEquals("Array", type.name)
- assertEquals("String", type.detail(DocumentationNode.Kind.Type).name)
- with(details(DocumentationNode.Kind.Parameter).single()) {
- val parameterType = detail(DocumentationNode.Kind.Type)
- assertEquals("IntArray", parameterType.name)
- }
- }
- }
- }
-
- @Test fun typeParameter() {
- verifyJavaPackageMember("test/data/java/typeParameter.java") { cls ->
- val typeParameters = cls.details(DocumentationNode.Kind.TypeParameter)
- with(typeParameters.single()) {
- assertEquals("T", name)
- with(detail(DocumentationNode.Kind.UpperBound)) {
- assertEquals("Comparable", name)
- assertEquals("T", detail(DocumentationNode.Kind.Type).name)
- }
- }
- with(cls.members(DocumentationNode.Kind.Function).single()) {
- val methodTypeParameters = details(DocumentationNode.Kind.TypeParameter)
- with(methodTypeParameters.single()) {
- assertEquals("E", name)
- }
- }
- }
- }
-
- @Test fun constructors() {
- verifyJavaPackageMember("test/data/java/constructors.java") { cls ->
- val constructors = cls.members(DocumentationNode.Kind.Constructor)
- assertEquals(2, constructors.size)
- with(constructors[0]) {
- assertEquals("<init>", name)
- }
- }
- }
-
- @Test fun innerClass() {
- verifyJavaPackageMember("test/data/java/innerClass.java") { cls ->
- val innerClass = cls.members(DocumentationNode.Kind.Class).single()
- assertEquals("D", innerClass.name)
- }
- }
-
- @Test fun varargs() {
- verifyJavaPackageMember("test/data/java/varargs.java") { cls ->
- val fn = cls.members(DocumentationNode.Kind.Function).single()
- val param = fn.detail(DocumentationNode.Kind.Parameter)
- assertEquals("vararg", param.details(DocumentationNode.Kind.Modifier).first().name)
- val psiType = param.detail(DocumentationNode.Kind.Type)
- assertEquals("String", psiType.name)
- assertTrue(psiType.details(DocumentationNode.Kind.Type).isEmpty())
- }
- }
-
- @Test fun fields() {
- verifyJavaPackageMember("test/data/java/field.java") { cls ->
- val i = cls.members(DocumentationNode.Kind.Property).single { it.name == "i" }
- assertEquals("Int", i.detail(DocumentationNode.Kind.Type).name)
- assertTrue("var" in i.details(DocumentationNode.Kind.Modifier).map { it.name })
-
- val s = cls.members(DocumentationNode.Kind.Property).single { it.name == "s" }
- assertEquals("String", s.detail(DocumentationNode.Kind.Type).name)
- assertFalse("var" in s.details(DocumentationNode.Kind.Modifier).map { it.name })
- assertTrue("static" in s.details(DocumentationNode.Kind.Modifier).map { it.name })
- }
- }
-
- @Test fun staticMethod() {
- verifyJavaPackageMember("test/data/java/staticMethod.java") { cls ->
- val m = cls.members(DocumentationNode.Kind.Function).single { it.name == "foo" }
- assertTrue("static" in m.details(DocumentationNode.Kind.Modifier).map { it.name })
- }
- }
-
- @Test fun annotatedAnnotation() {
- verifyJavaPackageMember("test/data/java/annotatedAnnotation.java") { cls ->
- assertEquals(1, cls.annotations.size)
- with(cls.annotations[0]) {
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Parameter, kind)
- assertEquals(1, details.count())
- with(details[0]) {
- assertEquals(DocumentationNode.Kind.Value, kind)
- assertEquals("[AnnotationTarget.FIELD, AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]", name)
- }
- }
- }
- }
- }
-
- @Test fun deprecation() {
- verifyJavaPackageMember("test/data/java/deprecation.java") { cls ->
- val fn = cls.members(DocumentationNode.Kind.Function).single()
- assertEquals("This should no longer be used", fn.deprecation!!.content.toTestString())
- }
- }
-
- @Test fun javaLangObject() {
- verifyJavaPackageMember("test/data/java/javaLangObject.java") { cls ->
- val fn = cls.members(DocumentationNode.Kind.Function).single()
- assertEquals("Any", fn.detail(DocumentationNode.Kind.Type).name)
- }
- }
-
- @Test fun enumValues() {
- verifyJavaPackageMember("test/data/java/enumValues.java") { cls ->
- val superTypes = cls.details(DocumentationNode.Kind.Supertype)
- assertEquals(0, superTypes.size)
- assertEquals(1, cls.members(DocumentationNode.Kind.EnumItem).size)
- }
- }
-
- @Test fun inheritorLinks() {
- verifyJavaPackageMember("test/data/java/inheritorLinks.java") { cls ->
- val fooClass = cls.members.single { it.name == "Foo" }
- val inheritors = fooClass.references(DocumentationReference.Kind.Inheritor)
- assertEquals(1, inheritors.size)
- }
- }
-}
diff --git a/test/src/model/KotlinAsJavaTest.kt b/test/src/model/KotlinAsJavaTest.kt
deleted file mode 100644
index 18a1cfef..00000000
--- a/test/src/model/KotlinAsJavaTest.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.DocumentationModule
-import org.jetbrains.dokka.DocumentationNode
-import org.junit.Test
-import kotlin.test.assertEquals
-
-class KotlinAsJavaTest {
- @Test fun function() {
- verifyModelAsJava("test/data/functions/function.kt") { model ->
- val pkg = model.members.single()
-
- val facadeClass = pkg.members.single { it.name == "FunctionKt" }
- assertEquals(DocumentationNode.Kind.Class, facadeClass.kind)
-
- val fn = facadeClass.members.single()
- assertEquals("fn", fn.name)
- assertEquals(DocumentationNode.Kind.Function, fn.kind)
- }
- }
-
- @Test fun propertyWithComment() {
- verifyModelAsJava("test/data/comments/oneLineDoc.kt") { model ->
- val facadeClass = model.members.single().members.single { it.name == "OneLineDocKt" }
- val getter = facadeClass.members.single { it.name == "getProperty" }
- assertEquals(DocumentationNode.Kind.Function, getter.kind)
- assertEquals("doc", getter.content.summary.toTestString())
- }
- }
-}
-
-fun verifyModelAsJava(source: String,
- withJdk: Boolean = false,
- withKotlinRuntime: Boolean = false,
- verifier: (DocumentationModule) -> Unit) {
- verifyModel(source,
- withJdk = withJdk, withKotlinRuntime = withKotlinRuntime,
- format = "html-as-java",
- verifier = verifier)
-}
diff --git a/test/src/model/LinkTest.kt b/test/src/model/LinkTest.kt
deleted file mode 100644
index a8004367..00000000
--- a/test/src/model/LinkTest.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.junit.Test
-import kotlin.test.*
-import org.jetbrains.dokka.*
-
-public class LinkTest {
- @Test fun linkToSelf() {
- verifyModel("test/data/links/linkToSelf.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("This is link to [Foo -> Class:Foo]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToMember() {
- verifyModel("test/data/links/linkToMember.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("This is link to [member -> Function:member]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToQualifiedMember() {
- verifyModel("test/data/links/linkToQualifiedMember.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Class, kind)
- assertEquals("This is link to [Foo.member -> Function:member]", content.summary.toTestString())
- }
- }
- }
-
- @Test fun linkToParam() {
- verifyModel("test/data/links/linkToParam.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("Foo", name)
- assertEquals(DocumentationNode.Kind.Function, kind)
- assertEquals("This is link to [param -> Parameter:param]", content.summary.toTestString())
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/test/src/model/PackageTest.kt b/test/src/model/PackageTest.kt
deleted file mode 100644
index 52324f1d..00000000
--- a/test/src/model/PackageTest.kt
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.kotlin.config.KotlinSourceRoot
-import org.junit.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-public class PackageTest {
- @Test fun rootPackage() {
- verifyModel("test/data/packages/rootPackage.kt") { model ->
- with(model.members.single()) {
- assertEquals(DocumentationNode.Kind.Package, kind)
- assertEquals("", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun simpleNamePackage() {
- verifyModel("test/data/packages/simpleNamePackage.kt") { model ->
- with(model.members.single()) {
- assertEquals(DocumentationNode.Kind.Package, kind)
- assertEquals("simple", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun dottedNamePackage() {
- verifyModel("test/data/packages/dottedNamePackage.kt") { model ->
- with(model.members.single()) {
- assertEquals(DocumentationNode.Kind.Package, kind)
- assertEquals("dot.name", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun multipleFiles() {
- verifyModel(KotlinSourceRoot("test/data/packages/dottedNamePackage.kt"),
- KotlinSourceRoot("test/data/packages/simpleNamePackage.kt")) { model ->
- assertEquals(2, model.members.count())
- with(model.members.single { it.name == "simple" }) {
- assertEquals(DocumentationNode.Kind.Package, kind)
- assertEquals("simple", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- with(model.members.single { it.name == "dot.name" }) {
- assertEquals(DocumentationNode.Kind.Package, kind)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun multipleFilesSamePackage() {
- verifyModel(KotlinSourceRoot("test/data/packages/simpleNamePackage.kt"),
- KotlinSourceRoot("test/data/packages/simpleNamePackage2.kt")) { model ->
- assertEquals(1, model.members.count())
- with(model.members.elementAt(0)) {
- assertEquals(DocumentationNode.Kind.Package, kind)
- assertEquals("simple", name)
- assertEquals(Content.Empty, content)
- assertTrue(details.none())
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-} \ No newline at end of file
diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt
deleted file mode 100644
index 093772b4..00000000
--- a/test/src/model/PropertyTest.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationReference
-import org.junit.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-public class PropertyTest {
- @Test fun valueProperty() {
- verifyModel("test/data/properties/valueProperty.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun variableProperty() {
- verifyModel("test/data/properties/variableProperty.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- assertTrue(members.none())
- assertTrue(links.none())
- }
- }
- }
-
- @Test fun valuePropertyWithGetter() {
- verifyModel("test/data/properties/valuePropertyWithGetter.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
-
- @Test fun variablePropertyWithAccessors() {
- verifyModel("test/data/properties/variablePropertyWithAccessors.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("property", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
- assertEquals(Content.Empty, content)
- assertEquals("String", detail(DocumentationNode.Kind.Type).name)
- val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name }
- assertTrue("final" in modifiers)
- assertTrue("public" in modifiers)
- assertTrue("var" in modifiers)
- assertTrue(links.none())
- assertTrue(members.none())
- }
- }
- }
-
- @Test fun annotatedProperty() {
- verifyModel("test/data/properties/annotatedProperty.kt", withKotlinRuntime = true) { model ->
- with(model.members.single().members.single()) {
- assertEquals(1, annotations.count())
- with(annotations[0]) {
- assertEquals("Volatile", name)
- assertEquals(Content.Empty, content)
- assertEquals(DocumentationNode.Kind.Annotation, kind)
- }
- }
- }
- }
-
- @Test fun propertyWithReceiver() {
- verifyModel("test/data/properties/propertyWithReceiver.kt") { model ->
- with(model.members.single().members.single()) {
- assertEquals("kotlin.String", name)
- assertEquals(DocumentationNode.Kind.ExternalClass, kind)
- with(members.single()) {
- assertEquals("foobar", name)
- assertEquals(DocumentationNode.Kind.Property, kind)
- }
- }
- }
- }
-
- @Test fun propertyOverride() {
- verifyModel("test/data/properties/propertyOverride.kt") { model ->
- with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) {
- assertEquals("xyzzy", name)
- val override = references(DocumentationReference.Kind.Override).single().to
- assertEquals("xyzzy", override.name)
- assertEquals("Foo", override.owner!!.name)
- }
- }
- }
-}