diff options
| author | Simon Ogorodnik <sem-oro@yandex.ru> | 2016-11-28 18:31:56 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-28 18:31:56 +0300 |
| commit | e9cf2d779c03e278ddfd5adb0d1c743961d8d07a (patch) | |
| tree | 9fc3ad76cfe1a3b939258fdc005cdd554fbd2562 /core/src/test/kotlin/model | |
| parent | 17a9a1774ec10690a031ae7afba5f5cfc59a9f24 (diff) | |
| parent | 575caeb1cb2a97750f8cc220d3100fc240312671 (diff) | |
| download | dokka-e9cf2d779c03e278ddfd5adb0d1c743961d8d07a.tar.gz dokka-e9cf2d779c03e278ddfd5adb0d1c743961d8d07a.tar.bz2 dokka-e9cf2d779c03e278ddfd5adb0d1c743961d8d07a.zip | |
Merge pull request #114 from Kotlin/0.9.10/typealias
Type alias support
Diffstat (limited to 'core/src/test/kotlin/model')
| -rw-r--r-- | core/src/test/kotlin/model/TypeAliasTest.kt | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/core/src/test/kotlin/model/TypeAliasTest.kt b/core/src/test/kotlin/model/TypeAliasTest.kt new file mode 100644 index 00000000..812fd9dc --- /dev/null +++ b/core/src/test/kotlin/model/TypeAliasTest.kt @@ -0,0 +1,123 @@ +package org.jetbrains.dokka.tests + +import junit.framework.TestCase.assertEquals +import org.jetbrains.dokka.Content +import org.jetbrains.dokka.NodeKind +import org.junit.Test + +class TypeAliasTest { + @Test + fun testSimple() { + verifyModel("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() { + verifyModel("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() { + verifyModel("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() { + verifyModel("testdata/typealias/documented.kt") { + val pkg = it.members.single() + with(pkg.member(NodeKind.TypeAlias)) { + assertEquals("Just typealias", content.summary.toTestString()) + } + } + } + + @Test + fun testDeprecated() { + verifyModel("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() { + verifyModel("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() { + verifyModel("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() { + verifyModel("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) + } + } + } +}
\ No newline at end of file |
