[Commonizer] HierarchicalClassAndTypeAliasCommonizationTest: Add function parameter tests

This commit is contained in:
sebastian.sellmair
2021-06-24 09:46:32 +02:00
committed by Space
parent 4bcae0cc6f
commit eaa0eb2851

View File

@@ -309,6 +309,62 @@ class HierarchicalClassAndTypeAliasCommonizationTest : AbstractInlineSourcesComm
)
}
fun `test parameters`() {
val result = commonize {
outputTarget("(a, b)")
simpleSingleSourceTarget(
"a", """
class X
fun useX(x: X) = Unit
""".trimIndent()
)
simpleSingleSourceTarget(
"b", """
class B
typealias X = B
fun useX(x: X) = Unit
""".trimIndent()
)
}
result.assertCommonized(
"(a, b)", """
expect class X expect constructor()
expect fun useX(x: X)
""".trimIndent()
)
}
fun `test parameters with non-commonized TA expanding to a commonized type`() {
val result = commonize {
outputTarget("(a, b)")
simpleSingleSourceTarget(
"a", """
class X
fun useX(x: X) = Unit
""".trimIndent()
)
simpleSingleSourceTarget(
"b", """
class X
typealias B = X
fun useX(x: B) = Unit
""".trimIndent()
)
}
result.assertCommonized(
"(a, b)", """
expect class X expect constructor()
expect fun useX(x: X)
""".trimIndent()
)
}
fun `test parameterized types`() {
val result = commonize {
outputTarget("(a, b)", "(c, d)", "(a, b, c, d)")