From 4d8fddef6ec3c25dc3f2950f118917713eaa1a36 Mon Sep 17 00:00:00 2001 From: Pavel Punegov <32519625+PavelPunegov@users.noreply.github.com> Date: Wed, 15 Nov 2017 16:03:07 +0300 Subject: [PATCH] Add more tests from the latest snapshot --- .../codegen/box/optimizations/kt20844.kt | 9 +++++++ .../boxInline/optimizations/kt20844.kt | 27 +++++++++++++++++++ gradle.properties | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 backend.native/tests/external/codegen/box/optimizations/kt20844.kt create mode 100644 backend.native/tests/external/codegen/boxInline/optimizations/kt20844.kt diff --git a/backend.native/tests/external/codegen/box/optimizations/kt20844.kt b/backend.native/tests/external/codegen/box/optimizations/kt20844.kt new file mode 100644 index 00000000000..6c359e3c88b --- /dev/null +++ b/backend.native/tests/external/codegen/box/optimizations/kt20844.kt @@ -0,0 +1,9 @@ +//WITH_RUNTIME + +fun foo(x: String, ys: List) = + x + ys.fold("", { a, b -> a + b }) + +var flag = true + +fun box(): String = + foo("O", if (flag) listOf("k").map { it.toUpperCase() } else listOf()) \ No newline at end of file diff --git a/backend.native/tests/external/codegen/boxInline/optimizations/kt20844.kt b/backend.native/tests/external/codegen/boxInline/optimizations/kt20844.kt new file mode 100644 index 00000000000..7775771039c --- /dev/null +++ b/backend.native/tests/external/codegen/boxInline/optimizations/kt20844.kt @@ -0,0 +1,27 @@ +// FILE: 1.kt +//WITH_RUNTIME +package test + +data class Address( + val createdTimeMs: Long = 0, + val firstName: String = "", + val lastName: String = "" +) + +inline fun String.switchIfEmpty(provider: () -> String): String { + return if (isEmpty()) provider() else this +} + +// FILE: 2.kt + +import test.* + +fun box(): String { + val address = Address() + val result = address.copy( + firstName = address.firstName.switchIfEmpty { "O" }, + lastName = address.lastName.switchIfEmpty { "K" } + ) + + return result.firstName + result.lastName +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3546e58c17f..e188dffc6cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ llvmVersion = 3.9.0 remoteRoot=konan_tests #kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-SNAPSHOT # Download artifacts of https://teamcity.jetbrains.com/viewType.html?buildTypeId=Kotlin_120_Compiler -testDataVersion=1213932:id +testDataVersion=1226829:id kotlinCompilerRepo=https://dl.bintray.com/jetbrains/kotlin-native-dependencies #kotlinCompilerRepo=http://oss.sonatype.org/content/repositories/snapshots #kotlinCompilerRepo=http://dl.bintray.com/kotlin/kotlin-dev