diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 09a8dd55f56..ccccbebfaa6 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -467,6 +467,21 @@ task enum_linkTest(type: LinkKonanTest) { lib = "codegen/enum/linkTest_lib.kt" } +task mangling(type: LinkKonanTest) { + goldValue = + "Int direct [1, 2, 3, 4]\n" + + "out Number direct [9, 10, 11, 12]\n" + + "star direct [5, 6, 7, 8]\n" + + "Int param [1, 2, 3, 4]\n" + + "out Number param [9, 10, 11, 12]\n" + + "star param [5, 6, 7, 8]\n" + + "no constructors {}\n" + + "single constructor some string\n" + + "two constructors 17\n" + source = "mangling/mangling.kt" + lib = "mangling/manglinglib.kt" +} + task innerClass_simple(type: RunKonanTest) { goldValue = "OK\n" source = "codegen/innerClass/simple.kt" diff --git a/backend.native/tests/mangling/mangling.kt b/backend.native/tests/mangling/mangling.kt new file mode 100644 index 00000000000..0da5a5bc04e --- /dev/null +++ b/backend.native/tests/mangling/mangling.kt @@ -0,0 +1,36 @@ +fun test_direct() { + val mutListInt = mutableListOf(1, 2, 3, 4) + val mutListNum = mutableListOf(9, 10, 11, 12) + val mutListAny = mutableListOf(5, 6, 7, 8) + + mangle1(mutListInt) + mangle1(mutListNum) + mangle1(mutListAny) +} + +fun test_param() { + val mutListInt = mutableListOf(1, 2, 3, 4) + val mutListNum = mutableListOf(9, 10, 11, 12) + val mutListAny = mutableListOf(5, 6, 7, 8) + + mangle2(mutListInt) + mangle2(mutListNum) + mangle2(mutListAny) +} + +fun test_multiple_constructors() { + val any = mapOf() + val comparable = "some string" + val number = 17 + + mangle3(any) + mangle3(comparable) + mangle3(number) +} + +fun main(args: Array) { + test_direct() + test_param() + test_multiple_constructors() +} + diff --git a/backend.native/tests/mangling/manglinglib.kt b/backend.native/tests/mangling/manglinglib.kt new file mode 100644 index 00000000000..4c75ddd7b04 --- /dev/null +++ b/backend.native/tests/mangling/manglinglib.kt @@ -0,0 +1,47 @@ +public fun mangle1(l: List) { + println("Int direct $l") +} + +public fun mangle1(l: List) { + println("out Number direct $l") +} + +public fun mangle1(l: List<*>) { + println("star direct $l") +} + +public fun mangle2(l: T) where T: List +{ + println("Int param $l") +} + +public fun mangle2(l: T) where T: List +{ + println("out Number param $l") +} + +public fun mangle2(l: T) where T: List<*> +{ + println("star param $l") +} + +public fun mangle3(l: T) +{ + println("no constructors $l") +} + +public fun mangle3(l: T) + where + T: Comparable +{ + println("single constructor $l") +} + +public fun mangle3(l: T) + where + T: Comparable, + T: Number +{ + println("two constructors $l") +} +