aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-07-02 13:21:00 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-13 14:47:37 +0200
commitb67f44943bc80dedd70c4a9e120b9c6aec78ca72 (patch)
tree349a417b0ed67e1220b4d7c3c82800a7d3a956bd /plugins/base/src/test/kotlin
parentf042de920724f6e2ae4ccbcb21baed6b490290ab (diff)
downloaddokka-b67f44943bc80dedd70c4a9e120b9c6aec78ca72.tar.gz
dokka-b67f44943bc80dedd70c4a9e120b9c6aec78ca72.tar.bz2
dokka-b67f44943bc80dedd70c4a9e120b9c6aec78ca72.zip
Draft for showing only first level of inheritance
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt36
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt134
2 files changed, 47 insertions, 123 deletions
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index 979ea89b..5dc8812e 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -221,7 +221,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "f").cast<DFunction>()) {
modifier.values.forEach { it equals Open }
}
- D.supertypes.flatMap { it.component2() }.firstOrNull() equals C.dri
+ D.supertypes.flatMap { it.component2() }.firstOrNull()?.dri equals C.dri
}
}
}
@@ -258,8 +258,8 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
modifier.values.forEach { it equals Final }
}
- D.supers.single() equals C.dri
- E.supers.firstOrNull() equals D.dri
+ D.supers.single().dri equals C.dri
+ E.supers.single().dri equals D.dri
}
}
@@ -500,4 +500,34 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
}
}
}
+
+ @Test fun multipleClassInheritance() {
+ inlineModelTest(
+ """
+ | open class A { }
+ | open class B: A() { }
+ | class Tested : B() { }
+ """.trimIndent()
+ ) {
+ with((this / "classes" / "Tested").cast<DClass>()) {
+ supertypes.entries.single().value.map { it.dri.sureClassNames }.single() equals "B"
+ }
+ }
+ }
+
+ @Test fun multipleClassInheritanceWithInterface(){
+ inlineModelTest(
+ """
+ | open class A { }
+ | open class B: A() { }
+ | interface X { }
+ | interface Y : X { }
+ | class Tested : B(), Y { }
+ """.trimIndent()
+ ){
+ with((this / "classes" / "Tested").cast<DClass>()) {
+ supertypes.entries.single().value.map { it.dri.sureClassNames to it.kind }.sortedBy { it.first } equals listOf("B" to KotlinClassKindTypes.CLASS, "Y" to KotlinClassKindTypes.INTERFACE)
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index 4cad784b..1f042304 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -54,38 +54,19 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- //@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())
- // }
- // 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 multipleClassInheritanceWithInterface() {
+ inlineModelTest(
+ """
+ |interface Highest { }
+ |interface Lower extends Highest { }
+ |class Extendable { }
+ |class Tested extends Extendable implements Lower { }
+ """){
+ with((this / "java" / "Tested").cast<DClass>()) {
+ supertypes.entries.single().value.map { it.dri.sureClassNames to it.kind }.sortedBy { it.first } equals listOf("Extendable" to JavaClassKindTypes.CLASS, "Lower" to JavaClassKindTypes.INTERFACE)
+ }
+ }
+ }
@Test // todo
fun memberWithModifiers() {
@@ -107,19 +88,6 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- // @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() {
inlineModelTest(
@@ -130,7 +98,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with((this / "java" / "Foo").cast<DClass>()) {
val sups = listOf("Exception", "Cloneable")
assertTrue(
- sups.all { s -> supertypes.values.flatten().any { it.classNames == s } })
+ sups.all { s -> supertypes.values.flatten().any { it.dri.classNames == s } })
"Foo must extend ${sups.joinToString(", ")}"
}
}
@@ -178,25 +146,6 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- // @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() {
inlineModelTest(
@@ -290,19 +239,6 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- // @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() {
inlineModelTest(
@@ -321,25 +257,6 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- // @Test fun staticMethod() { todo
- // 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() {
inlineModelTest(
@@ -367,13 +284,6 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- // @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() {
inlineModelTest(
@@ -389,13 +299,6 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
- // @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() {
inlineModelTest(
@@ -440,13 +343,4 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
}
}
}
-
- // todo
- // @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)
- // }
- // }
}