Files
kotlin/compiler/testData/codegen/box/strings/multilineStringsWithTemplates.kt
Alexander Udalov a7b88e9485 Make CharSequence.length a function instead of property
And String.length as well.

This is done for JVM interoperability: java.lang.CharSequence is an open class
and has a function 'length()' which should be implemented in subclasses
somehow.

A minor unexpected effect of this is that String.length() is now a compile-time
constant (it wasn't such as a property because properties are not supported in
compile-time constant evaluation)

 #KT-3571 Fixed
2014-11-27 20:38:17 +03:00

32 lines
709 B
Kotlin

fun box() : String {
val s = "abc"
val test1 = """$s"""
if (test1 != "abc") return "Fail 1: $test1"
val test2 = """${s}"""
if (test2 != "abc") return "Fail 2: $test2"
val test3 = """ "$s" """
if (test3 != " \"abc\" ") return "Fail 3: $test3"
val test4 = """ "${s}" """
if (test4 != " \"abc\" ") return "Fail 4: $test4"
val test5 =
"""
${s.length()}
"""
if (test5 != "\n 3\n") return "Fail 5: $test5"
val test6 = """\n"""
if (test6 != "\\n") return "Fail 6: $test6"
val test7 = """\${'$'}foo"""
if (test7 != "\\\$foo") return "Fail 7: $test7"
val test8 = """$ foo"""
if (test8 != "$ foo") return "Fail 8: $test8"
return "OK"
}