Add more tests from the latest snapshot
This commit is contained in:
committed by
Pavel Punegov
parent
d71af3da10
commit
4d8fddef6e
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user