Support indy concatenation

This commit is contained in:
Mikhael Bogdanov
2020-09-29 14:01:34 +02:00
parent 942e1962d9
commit 1938f9459f
13 changed files with 274 additions and 14 deletions
+14
View File
@@ -0,0 +1,14 @@
// KOTLIN_CONFIGURATION_FLAGS: RUNTIME_STRING_CONCAT=enable
// JVM_TARGET: 9
fun box(): String {
val p = 3147483648u
val a = "_"
val b = "_"
val s = a + "1" + "2" + 3 + 4L + b + 5.0 + 6F + '7' + true + false + 3147483647u + p
return if (s != "_1234_5.06.07truefalse31474836473147483648") "fail $s" else "OK"
}
fun main() {
box().let { if (it != "OK") throw AssertionError(it) }
}
@@ -0,0 +1,22 @@
// KOTLIN_CONFIGURATION_FLAGS: RUNTIME_STRING_CONCAT=indy
// JVM_TARGET: 9
fun box(): String {
val z = "0"
val result = z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z //200
return if (result.length != 200)
"fail: ${result.length}" else "OK"
}
fun main() {
box().let { if (it != "OK") throw AssertionError(it) }
}
@@ -0,0 +1,23 @@
// KOTLIN_CONFIGURATION_FLAGS: RUNTIME_STRING_CONCAT=indy
// JVM_TARGET: 9
fun box(): String {
val z = "0"
val result = z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z +
z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + z + //200
z //201
return if (result.length != 201)
"fail: ${result.length}" else "OK"
}
fun main() {
box().let { if (it != "OK") throw AssertionError(it) }
}
@@ -0,0 +1,31 @@
// KOTLIN_CONFIGURATION_FLAGS: RUNTIME_STRING_CONCAT=enable
// JVM_TARGET: 9
inline class Str(val s: String)
inline class NStr(val s: String?)
fun testStr(s: Str?) = "1$s$s"
fun testNStr(ns: NStr?) = "2$ns$ns"
fun box(): String {
val test1 = testStr(Str("0"))
if (test1 != "1Str(s=0)Str(s=0)") return "fail 1: $test1"
val test2 = testStr(null)
if (test2 != "1nullnull") return "fail 2: $test2"
val test3 = testNStr(NStr(null))
if (test3 != "2NStr(s=null)NStr(s=null)") return "fail 3: $test3"
val test4 = testNStr(NStr("0"))
if (test4 != "2NStr(s=0)NStr(s=0)") return "fail 4: $test4"
val test5 = testNStr(null)
if (test5 != "2nullnull") return "fail 5: $test5"
return "OK"
}
fun main() {
box().let { if (it != "OK") throw AssertionError(it) }
}
@@ -0,0 +1,25 @@
// KOTLIN_CONFIGURATION_FLAGS: RUNTIME_STRING_CONCAT=enable
// JVM_TARGET: 9
inline fun test(crossinline s: (String) -> String): String {
var result = "1" + s("2") + "3" + 4 + {
"5" + s("6") + "7"
}()
result += object {
fun run() = "8" + s("9") + "10"
}.run()
return result
}
fun box(): String {
val result = test { it }
if (result != "12345678910") return "fail 1: $result"
val result2 = test { it + "_" }
return if (result2 != "12_3456_789_10") "fail 2: $result2" else "OK"
}
fun main() {
box().let { if (it != "OK") throw AssertionError(it) }
}