From 38c7337b191ca40c6f91e2ee109288461888f5fa Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Thu, 16 Sep 2021 15:04:29 +0200 Subject: [PATCH] [Commonizer] Add tests to ParameterizedTypesCommonizationTest ^KT-48288 --- .../ParameterizedTypesCommonizationTest.kt | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt index 9c6f11d345c..d96bfdada07 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt @@ -287,4 +287,81 @@ class ParameterizedTypesCommonizationTest : AbstractInlineSourcesCommonizationTe """.trimIndent() ) } + + fun `test parameterized function - 0`() { + val result = commonize { + outputTarget("(a, b)") + simpleSingleSourceTarget( + "a", """ + typealias X = Map + fun x(x: X) + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + fun x(x: Map) + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect fun x(x: Map) + """.trimIndent() + ) + } + + fun `test parameterized function - 1`() { + val result = commonize { + outputTarget("(a, b)") + + simpleSingleSourceTarget( + "a", """ + typealias X = Map + fun > x(x: X) + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + fun > x(x: Map) + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect fun > x(x: Map) + """.trimIndent() + ) + } + + fun `test parameterized function - 2`() { + val result = commonize { + outputTarget("(a, b)") + + simpleSingleSourceTarget( + "a", """ + typealias X = Map + fun > x(x: X) + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + typealias X = Map + typealias Y = X + fun > x(x: Y) + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect typealias X = Map + expect fun > x(x: X) + """.trimIndent() + ) + } }