backend/tests: Add blackbox tests from Kotlin JVM
Added tests from testData/codegen/box directory. There are blackbox tests in other directories and they are to be added.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
var result = "fail"
|
||||
|
||||
private operator fun X.get(name: String) = name + "K"
|
||||
private operator fun X.set(name: String, v: String) {
|
||||
result = v
|
||||
}
|
||||
|
||||
class X {
|
||||
fun test() : String {
|
||||
if (this["O"] != "OK") return "fail 1: ${this["O"]}"
|
||||
|
||||
this["O"] += "K"
|
||||
if (result != "OKK") return "fail 2: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return X().test()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class MyString(var content : String)
|
||||
|
||||
object Greeter {
|
||||
fun sayHello(name : String): String {
|
||||
var result = MyString(name)
|
||||
result += "K"
|
||||
return result.content
|
||||
}
|
||||
}
|
||||
|
||||
private operator fun MyString.plus(suffix: String) : MyString = MyString("${this.content}$suffix")
|
||||
|
||||
fun box(): String {
|
||||
return Greeter.sayHello("O")
|
||||
}
|
||||
Reference in New Issue
Block a user