@@ -17,6 +17,24 @@ import kotlin.test.assertTrue
17
17
@Suppress(" Detekt.UnusedPrivateClass" )
18
18
open class KClassExtensionsTest {
19
19
20
+ interface SomeInterface {
21
+ val someField: String?
22
+
23
+ fun someFunction (): String?
24
+ }
25
+
26
+ abstract class SomeAbstractClass : SomeInterface {
27
+ override val someField: String = " Hello"
28
+
29
+ override fun someFunction (): String? = " Goodbye"
30
+
31
+ abstract val justAnotherField: String?
32
+ }
33
+
34
+ class SomeConcreteClass : SomeAbstractClass () {
35
+ override val justAnotherField: String? = " Default value"
36
+ }
37
+
20
38
@Suppress(" Detekt.FunctionOnlyReturningConstant" , " Detekt.UnusedPrivateMember" )
21
39
private class MyTestClass (
22
40
val publicProperty : String = " public" ,
@@ -90,6 +108,12 @@ open class KClassExtensionsTest {
90
108
assertEquals(listOf (" publicProperty" ), properties.map { it.name })
91
109
}
92
110
111
+ @Test
112
+ fun `test getting valid properties from abstract classes` () {
113
+ val concreteProperties = SomeConcreteClass ::class .getValidProperties(noopHooks)
114
+ assertEquals(listOf (" justAnotherField" , " someField" ), concreteProperties.map { it.name })
115
+ }
116
+
93
117
@Test
94
118
fun `test getting valid functions with no hooks` () {
95
119
val properties = MyTestClass ::class .getValidFunctions(noopHooks)
@@ -102,6 +126,12 @@ open class KClassExtensionsTest {
102
126
assertEquals(listOf (" publicFunction" ), properties.map { it.name })
103
127
}
104
128
129
+ @Test
130
+ fun `test getting functions from abstract classes` () {
131
+ val properties = SomeConcreteClass ::class .getValidFunctions(noopHooks)
132
+ assertEquals(listOf (" someFunction" ), properties.map { it.name })
133
+ }
134
+
105
135
@Test
106
136
fun `test getting valid superclass with no hooks` () {
107
137
val superclasses = InterfaceSuperclass ::class .getValidSuperclasses(noopHooks)
0 commit comments