aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 19:49:25 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 19:49:25 +0400
commite4a6e2d908b285a3a92a65d99322f810fb5ff37d (patch)
tree2b15d5015e6cf9de0835ef558ba9490e8a91ff8d /test/src
parentea6da1423c3711a44952e4fc87967ac3a9e9da3e (diff)
downloaddokka-e4a6e2d908b285a3a92a65d99322f810fb5ff37d.tar.gz
dokka-e4a6e2d908b285a3a92a65d99322f810fb5ff37d.tar.bz2
dokka-e4a6e2d908b285a3a92a65d99322f810fb5ff37d.zip
Use more structural approach to testing using with(node) { ... }
Diffstat (limited to 'test/src')
-rw-r--r--test/src/ClassTest.kt74
-rw-r--r--test/src/FunctionTest.kt34
-rw-r--r--test/src/PackageTest.kt45
3 files changed, 93 insertions, 60 deletions
diff --git a/test/src/ClassTest.kt b/test/src/ClassTest.kt
index be9a29b1..348e74d4 100644
--- a/test/src/ClassTest.kt
+++ b/test/src/ClassTest.kt
@@ -7,39 +7,67 @@ import com.jetbrains.dokka.*
public class ClassTest {
Test fun emptyClass() {
verifyModel("test/data/classes/emptyClass.kt") { model ->
- val item = model.nodes.single().members.single()
- assertEquals(DocumentationNodeKind.Class, item.kind)
- assertEquals("Klass", item.name)
- assertEquals("", item.doc)
- assertTrue(item.details.none())
- assertEquals("<init>", item.members.single().name)
- assertTrue(item.links.none())
+ with(model.nodes.single().members.single()) {
+ assertEquals(DocumentationNodeKind.Class, kind)
+ assertEquals("Klass", name)
+ assertEquals("", doc)
+ assertTrue(details.none())
+ assertEquals("<init>", members.single().name)
+ assertTrue(links.none())
+ }
}
}
Test fun classWithConstructor() {
verifyModel("test/data/classes/classWithConstructor.kt") { model ->
- val item = model.nodes.single().members.single()
- assertEquals(DocumentationNodeKind.Class, item.kind)
- assertEquals("Klass", item.name)
- assertEquals("", item.doc)
- assertTrue(item.details.none())
- assertEquals("<init>", item.members.single().name)
- assertTrue(item.links.none())
+ 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("<init>", name)
+ assertEquals("", doc)
+ assertEquals(1, details.count())
+ with(details.elementAt(0)) {
+ assertEquals("name", name)
+ assertEquals("", doc)
+ }
+ assertTrue(members.none())
+ assertTrue(links.none())
+ }
+ }
}
}
Test fun classWithFunction() {
verifyModel("test/data/classes/classWithFunction.kt") { model ->
- val item = model.nodes.single().members.single()
- assertEquals(DocumentationNodeKind.Class, item.kind)
- assertEquals("Klass", item.name)
- assertEquals("", item.doc)
- assertTrue(item.details.none())
- assertEquals(2, item.members.count())
- assertEquals("<init>", item.members.elementAt(0).name)
- assertEquals("fn", item.members.elementAt(1).name)
- assertTrue(item.links.none())
+ 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("<init>", name)
+ assertEquals("", doc)
+ assertTrue(details.none())
+ assertTrue(members.none())
+ assertTrue(links.none())
+ }
+ with(members.elementAt(1)) {
+ assertEquals("fn", name)
+ assertEquals("", doc)
+ assertTrue(details.none())
+ assertTrue(members.none())
+ assertTrue(links.none())
+ }
+ }
}
}
} \ No newline at end of file
diff --git a/test/src/FunctionTest.kt b/test/src/FunctionTest.kt
index e8afe97b..2c0955d1 100644
--- a/test/src/FunctionTest.kt
+++ b/test/src/FunctionTest.kt
@@ -8,30 +8,32 @@ import com.jetbrains.dokka.*
public class FunctionTest {
Test fun function() {
verifyModel("test/data/functions/function.kt") { model ->
- val item = model.nodes.single().members.single()
- assertEquals(DocumentationNodeKind.Function, item.kind)
- assertEquals("fn", item.name)
- assertEquals("Function fn", item.doc)
- assertTrue(item.details.none())
- assertTrue(item.members.none())
- assertTrue(item.links.none())
+ with(model.nodes.single().members.single()) {
+ assertEquals(DocumentationNodeKind.Function, kind)
+ assertEquals("fn", name)
+ assertEquals("Function fn", doc)
+ assertTrue(details.none())
+ assertTrue(members.none())
+ assertTrue(links.none())
+ }
}
}
Test fun functionWithParams() {
verifyModel("test/data/functions/functionWithParams.kt") { model ->
- val item = model.nodes.single().members.single()
- assertEquals(DocumentationNodeKind.Function, item.kind)
- assertEquals("function", item.name)
- assertEquals("""Multiline
+ with(model.nodes.single().members.single()) {
+ assertEquals(DocumentationNodeKind.Function, kind)
+ assertEquals("function", name)
+ assertEquals("""Multiline
Function
Documentation"""
- , item.doc)
- assertEquals("x", item.details.single().name)
- assertEquals(DocumentationNodeKind.Parameter, item.details.single().kind)
+ , doc)
+ assertEquals("x", details.single().name)
+ assertEquals(DocumentationNodeKind.Parameter, details.single().kind)
- assertTrue(item.members.none())
- assertTrue(item.links.none())
+ assertTrue(members.none())
+ assertTrue(links.none())
+ }
}
}
} \ No newline at end of file
diff --git a/test/src/PackageTest.kt b/test/src/PackageTest.kt
index 46e25c9f..6ab40ba6 100644
--- a/test/src/PackageTest.kt
+++ b/test/src/PackageTest.kt
@@ -7,37 +7,40 @@ import com.jetbrains.dokka.*
public class PackageTest {
Test fun rootPackage() {
verifyModel("test/data/packages/rootPackage.kt") { model ->
- val item = model.nodes.single()
- assertEquals(DocumentationNodeKind.Package, item.kind)
- assertEquals("", item.name)
- assertEquals("", item.doc)
- assertTrue(item.details.none())
- assertTrue(item.members.none())
- assertTrue(item.links.none())
+ 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 ->
- val item = model.nodes.single()
- assertEquals(DocumentationNodeKind.Package, item.kind)
- assertEquals("simple", item.name)
- assertEquals("", item.doc)
- assertTrue(item.details.none())
- assertTrue(item.members.none())
- assertTrue(item.links.none())
+ 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 ->
- val item = model.nodes.single()
- assertEquals(DocumentationNodeKind.Package, item.kind)
- assertEquals("dot.name", item.name)
- assertEquals("", item.doc)
- assertTrue(item.details.none())
- assertTrue(item.members.none())
- assertTrue(item.links.none())
+ 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