@@ -17,6 +17,24 @@ import kotlin.test.assertTrue
1717@Suppress(" Detekt.UnusedPrivateClass" )
1818open class KClassExtensionsTest {
1919
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+
2038 @Suppress(" Detekt.FunctionOnlyReturningConstant" , " Detekt.UnusedPrivateMember" )
2139 private class MyTestClass (
2240 val publicProperty : String = " public" ,
@@ -90,6 +108,12 @@ open class KClassExtensionsTest {
90108 assertEquals(listOf (" publicProperty" ), properties.map { it.name })
91109 }
92110
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+
93117 @Test
94118 fun `test getting valid functions with no hooks` () {
95119 val properties = MyTestClass ::class .getValidFunctions(noopHooks)
@@ -102,6 +126,12 @@ open class KClassExtensionsTest {
102126 assertEquals(listOf (" publicFunction" ), properties.map { it.name })
103127 }
104128
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+
105135 @Test
106136 fun `test getting valid superclass with no hooks` () {
107137 val superclasses = InterfaceSuperclass ::class .getValidSuperclasses(noopHooks)
0 commit comments