Using invokeFunction() instead of invokeFunctionWithNoParams() when generating when() conditions
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user