Using invokeFunction() instead of invokeFunctionWithNoParams() when generating when() conditions

This commit is contained in:
Andrey Breslav
2012-08-23 13:44:28 +04:00
parent 0dcdaccad1
commit 9ca49b50b8
5 changed files with 66 additions and 18 deletions
@@ -9,3 +9,21 @@ fun isDigit(a: Int) : String {
else -> "something"
}
}
fun assertDigit(i: Int, expected: String): String {
val result = isDigit(i)
return if (result == expected) "" else "fail: isDigit($i) = \"$result\""
}
fun box(): String {
val result =
assertDigit(239, "array list") +
assertDigit(0, "digit") +
assertDigit(9, "digit") +
assertDigit(5, "digit") +
assertDigit(19, "something") +
assertDigit(190, "not small")
if (result == "") return "OK"
return result
}
@@ -0,0 +1,13 @@
var x = 0
fun inc(): Int {
x++
return 0
}
fun box(): String {
val al = java.util.ArrayList<Int>()
when (inc()) {
in al -> return "fail 1"
else -> {}
}
return if (x == 1) "OK" else "fail 2"
}