From 6afd7af76563f373e971256f8c9a7dcf42183fd4 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 11 Jul 2014 20:53:46 +0400 Subject: Migrate tests to org.jetbrains.dokka --- test/src/model/ClassTest.kt | 123 +++++++++++++++++++++++++++++++++++++++++ test/src/model/FunctionTest.kt | 43 ++++++++++++++ test/src/model/PackageTest.kt | 46 +++++++++++++++ test/src/model/PropertyTest.kt | 90 ++++++++++++++++++++++++++++++ 4 files changed, 302 insertions(+) create mode 100644 test/src/model/ClassTest.kt create mode 100644 test/src/model/FunctionTest.kt create mode 100644 test/src/model/PackageTest.kt create mode 100644 test/src/model/PropertyTest.kt (limited to 'test/src/model') diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt new file mode 100644 index 00000000..708a1798 --- /dev/null +++ b/test/src/model/ClassTest.kt @@ -0,0 +1,123 @@ +package org.jetbrains.dokka.tests + +import org.junit.Test +import kotlin.test.* +import org.jetbrains.dokka.* + +public class ClassTest { + Test fun emptyClass() { + verifyModel("test/data/classes/emptyClass.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals(DocumentationNodeKind.Class, kind) + assertEquals("Klass", name) + assertEquals("", doc) + assertTrue(details.none()) + assertEquals("", members.single().name) + assertTrue(links.none()) + } + } + } + + Test fun emptyObject() { + verifyModel("test/data/classes/emptyObject.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals(DocumentationNodeKind.Object, kind) + assertEquals("Obj", name) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + + Test fun classWithConstructor() { + verifyModel("test/data/classes/classWithConstructor.kt") { model -> + with (model.nodes.single().members.single()) { + assertEquals(DocumentationNodeKind.Class, kind) + assertEquals("Klass", name) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + + assertEquals(1, members.count()) + with(members.elementAt(0)) { + assertEquals("", name) + assertEquals("", doc) + assertEquals(DocumentationNodeKind.Constructor, kind) + assertEquals(1, details.count()) + with(details.elementAt(0)) { + assertEquals("name", name) + assertEquals(DocumentationNodeKind.Parameter, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + assertTrue(members.none()) + } + assertTrue(links.none()) + assertTrue(members.none()) + } + } + } + } + + Test fun classWithFunction() { + verifyModel("test/data/classes/classWithFunction.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals(DocumentationNodeKind.Class, kind) + assertEquals("Klass", name) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + + assertEquals(2, members.count()) + with(members.elementAt(0)) { + assertEquals("", name) + assertEquals("", doc) + assertEquals(DocumentationNodeKind.Constructor, kind) + assertTrue(details.none()) + assertTrue(links.none()) + assertTrue(members.none()) + } + with(members.elementAt(1)) { + assertEquals("fn", name) + assertEquals("", doc) + assertEquals(DocumentationNodeKind.Function, kind) + assertTrue(details.none()) + assertTrue(links.none()) + assertTrue(members.none()) + } + } + } + } + + Test fun classWithProperty() { + verifyModel("test/data/classes/classWithProperty.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals(DocumentationNodeKind.Class, kind) + assertEquals("Klass", name) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + + assertEquals(2, members.count()) + with(members.elementAt(0)) { + assertEquals("", name) + assertEquals("", doc) + assertEquals(DocumentationNodeKind.Constructor, kind) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + with(members.elementAt(1)) { + assertEquals("name", name) + assertEquals("", doc) + assertEquals(DocumentationNodeKind.Property, kind) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + } +} \ No newline at end of file diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt new file mode 100644 index 00000000..90b937de --- /dev/null +++ b/test/src/model/FunctionTest.kt @@ -0,0 +1,43 @@ +package org.jetbrains.dokka.tests + +import org.junit.Test +import kotlin.test.* +import org.jetbrains.dokka.* + +public class FunctionTest { + Test fun function() { + verifyModel("test/data/functions/function.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals("fn", name) + assertEquals(DocumentationNodeKind.Function, kind) + assertEquals("Function fn", doc) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + + Test fun functionWithParams() { + verifyModel("test/data/functions/functionWithParams.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals("function", name) + assertEquals(DocumentationNodeKind.Function, kind) + assertEquals("""Multiline +Function +Documentation""" + , doc) + with(details.single()) { + assertEquals("x", name) + assertEquals(DocumentationNodeKind.Parameter, kind) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } +} \ No newline at end of file diff --git a/test/src/model/PackageTest.kt b/test/src/model/PackageTest.kt new file mode 100644 index 00000000..7b376012 --- /dev/null +++ b/test/src/model/PackageTest.kt @@ -0,0 +1,46 @@ +package org.jetbrains.dokka.tests + +import org.junit.Test +import kotlin.test.* +import org.jetbrains.dokka.* + +public class PackageTest { + Test fun rootPackage() { + verifyModel("test/data/packages/rootPackage.kt") { model -> + with(model.nodes.single()) { + assertEquals(DocumentationNodeKind.Package, kind) + assertEquals("", name) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + + Test fun simpleNamePackage() { + verifyModel("test/data/packages/simpleNamePackage.kt") { model -> + with(model.nodes.single()) { + assertEquals(DocumentationNodeKind.Package, kind) + assertEquals("simple", name) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + + Test fun dottedNamePackage() { + verifyModel("test/data/packages/dottedNamePackage.kt") { model -> + with(model.nodes.single()) { + assertEquals(DocumentationNodeKind.Package, kind) + assertEquals("dot.name", name) + assertEquals("", doc) + 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 new file mode 100644 index 00000000..1d30f2ce --- /dev/null +++ b/test/src/model/PropertyTest.kt @@ -0,0 +1,90 @@ +package org.jetbrains.dokka.tests + +import org.junit.Test +import kotlin.test.* +import org.jetbrains.dokka.* + +public class PropertyTest { + Test fun valueProperty() { + verifyModel("test/data/properties/valueProperty.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals("property", name) + assertEquals(DocumentationNodeKind.Property, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + + Test fun variableProperty() { + verifyModel("test/data/properties/variableProperty.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals("property", name) + assertEquals(DocumentationNodeKind.Property, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } + + Test fun valuePropertyWithGetter() { + verifyModel("test/data/properties/valuePropertyWithGetter.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals("property", name) + assertEquals(DocumentationNodeKind.Property, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + with(members.single()) { + assertEquals("", name) + assertEquals(DocumentationNodeKind.Function, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + assertTrue(members.none()) + } + } + } + } + + Test fun variablePropertyWithAccessors() { + verifyModel("test/data/properties/variablePropertyWithAccessors.kt") { model -> + with(model.nodes.single().members.single()) { + assertEquals("property", name) + assertEquals(DocumentationNodeKind.Property, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + + assertEquals(2, members.count()) + with(members.elementAt(0)) { + assertEquals("", name) + assertEquals(DocumentationNodeKind.Function, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + assertTrue(members.none()) + } + with(members.elementAt(1)) { + assertEquals("", name) + assertEquals(DocumentationNodeKind.Function, kind) + assertEquals("", doc) + with(details.single()) { + assertEquals("value", name) + assertEquals(DocumentationNodeKind.Parameter, kind) + assertEquals("", doc) + assertTrue(details.none()) + assertTrue(links.none()) + assertTrue(members.none()) + } + assertTrue(links.none()) + assertTrue(members.none()) + } + } + } + } +} -- cgit