aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-10-15 18:11:17 +0200
committerKamil Doległo <kamilok1965@interia.pl>2020-10-15 18:11:17 +0200
commitc5a31b47ef182e4de3ec58d5ce5624e65fe11015 (patch)
tree9df60d122c56ea2ea2d918584f47051ef533622e /plugins/base/src/test
parent7f948864077388e10ba3608b0d5e1d9a4ea0f4d9 (diff)
downloaddokka-c5a31b47ef182e4de3ec58d5ce5624e65fe11015.tar.gz
dokka-c5a31b47ef182e4de3ec58d5ce5624e65fe11015.tar.bz2
dokka-c5a31b47ef182e4de3ec58d5ce5624e65fe11015.zip
Fix class cast exception when creating the ancestry tree
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt62
1 files changed, 47 insertions, 15 deletions
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index bb7bac2d..b6787126 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -460,32 +460,40 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
}
}
- @Test fun genericAnnotationClass() {
+ @Test
+ fun genericAnnotationClass() {
inlineModelTest(
"""annotation class Foo<A,B,C,D:Number>() {}"""
) {
- with((this / "classes" / "Foo").cast<DAnnotation>()){
- generics.map { it.name to it.bounds.first().name } equals listOf("A" to "Any", "B" to "Any", "C" to "Any", "D" to "Number")
+ with((this / "classes" / "Foo").cast<DAnnotation>()) {
+ generics.map { it.name to it.bounds.first().name } equals listOf(
+ "A" to "Any",
+ "B" to "Any",
+ "C" to "Any",
+ "D" to "Number"
+ )
}
}
}
- @Test fun nestedGenericClasses(){
+ @Test
+ fun nestedGenericClasses() {
inlineModelTest(
"""
|class Outer<OUTER> {
| inner class Inner<INNER, T : OUTER> { }
|}
""".trimMargin()
- ){
- with((this / "classes" / "Outer").cast<DClass>()){
+ ) {
+ with((this / "classes" / "Outer").cast<DClass>()) {
val inner = classlikes.single().cast<DClass>()
inner.generics.map { it.name to it.bounds.first().name } equals listOf("INNER" to "Any", "T" to "OUTER")
}
}
}
- @Test fun allImplementedInterfaces() {
+ @Test
+ fun allImplementedInterfaces() {
inlineModelTest(
"""
| interface Highest { }
@@ -494,14 +502,16 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
| interface LowerImplInterface: Lower { }
| class Tested : HighestImpl(), LowerImplInterface { }
""".trimIndent()
- ){
- with((this / "classes" / "Tested").cast<DClass>()){
- extra[ImplementedInterfaces]?.interfaces?.entries?.single()?.value?.map { it.dri.sureClassNames }?.sorted() equals listOf("Highest", "Lower", "LowerImplInterface").sorted()
+ ) {
+ with((this / "classes" / "Tested").cast<DClass>()) {
+ extra[ImplementedInterfaces]?.interfaces?.entries?.single()?.value?.map { it.dri.sureClassNames }
+ ?.sorted() equals listOf("Highest", "Lower", "LowerImplInterface").sorted()
}
}
}
- @Test fun multipleClassInheritance() {
+ @Test
+ fun multipleClassInheritance() {
inlineModelTest(
"""
| open class A { }
@@ -515,7 +525,8 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
}
}
- @Test fun multipleClassInheritanceWithInterface(){
+ @Test
+ fun multipleClassInheritanceWithInterface() {
inlineModelTest(
"""
| open class A { }
@@ -524,10 +535,31 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
| interface Y : X { }
| class Tested : B(), Y { }
""".trimIndent()
- ){
+ ) {
with((this / "classes" / "Tested").cast<DClass>()) {
- supertypes.entries.single().value.map { it.typeConstructor.dri.sureClassNames to it.kind }.sortedBy { it.first } equals listOf("B" to KotlinClassKindTypes.CLASS, "Y" to KotlinClassKindTypes.INTERFACE)
+ supertypes.entries.single().value.map { it.typeConstructor.dri.sureClassNames to it.kind }
+ .sortedBy { it.first } equals listOf(
+ "B" to KotlinClassKindTypes.CLASS,
+ "Y" to KotlinClassKindTypes.INTERFACE
+ )
+ }
+ }
+ }
+
+ @Test
+ fun doublyTypealiasedException() {
+ inlineModelTest(
+ """
+ | typealias B = RuntimeException
+ | typealias A = B
+ """.trimMargin()
+ ) {
+ with((this / "classes" / "A").cast<DTypeAlias>()) {
+ extra[ExceptionInSupertypes].assertNotNull("Typealias A should have ExceptionInSupertypes in its extra field")
+ }
+ with((this / "classes" / "B").cast<DTypeAlias>()) {
+ extra[ExceptionInSupertypes].assertNotNull("Typealias B should have ExceptionInSupertypes in its extra field")
}
}
}
-} \ No newline at end of file
+}