Browse Source

Make it crash

add_interface_default_testcase
Oleksandr Karpovich 1 year ago
parent
commit
1be3b8c46e
  1. 6
      compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/lib/src/commonMain/kotlin/Dependencies.kt
  2. 10
      compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonMain/kotlin/ComposableContentImpl.kt
  3. 32
      compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CompsableInterfaceTests.kt

6
compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/lib/src/commonMain/kotlin/Dependencies.kt

@ -12,8 +12,10 @@ interface ComposableContent {
interface DefaultComposableContent {
@Composable
fun ComposableContent() {
TextLeafNode("DefaultComposableContent")
fun ComposableContent(
any: String = "any"
) {
TextLeafNode("DefaultComposableContent - $any")
}
}

10
compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonMain/kotlin/ComposableContentImpl.kt

@ -43,4 +43,12 @@ class CollectionOfComposablesImpl : CollectionOfComposable {
}
class DefaultComposableContentImpl : DefaultComposableContent
class DefaultComposableContentImpl : DefaultComposableContent
class DefaultComposableContentOverrideImpl : DefaultComposableContent {
@Composable
override fun ComposableContent(any: String) {
super.ComposableContent("$any-overriden")
}
}

32
compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CompsableInterfaceTests.kt

@ -4,6 +4,7 @@ import com.example.common.TextLeafNode
import com.example.common.composeText
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
@ -89,7 +90,36 @@ class CompsableInterfaceTests {
}
assertEquals(
"root:{DefaultComposableContent}",
"root:{DefaultComposableContent - any}",
root.dump()
)
}
@Test
fun testDefaultComposableContentOverrideImpl() = runTest {
val instance = DefaultComposableContentOverrideImpl()
val root = composeText {
instance.ComposableContent("any")
}
assertEquals(
"root:{DefaultComposableContent - any-overriden}",
root.dump()
)
}
@Test
@Ignore // TODO: fails on jvm too: Parameter specified as non-null is null: method DefaultComposableContentOverrideImpl.ComposableContent, parameter any
fun testDefaultComposableContentOverrideImpl2() = runTest {
val instance = DefaultComposableContentOverrideImpl()
val root = composeText {
instance.ComposableContent()
}
assertEquals(
"root:{DefaultComposableContent - any-overriden}",
root.dump()
)
}

Loading…
Cancel
Save