back end test for 'variable as function' call case
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
package invoke
|
||||||
|
|
||||||
|
fun test1(predicate: (Int) -> Int, i: Int) = predicate(i)
|
||||||
|
|
||||||
|
fun test2(predicate: (Int) -> Int, i: Int) = predicate.invoke(i)
|
||||||
|
|
||||||
|
class Method {
|
||||||
|
fun invoke(i: Int) = i
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test3(method: Method, i: Int) = method.invoke(i)
|
||||||
|
|
||||||
|
//todo
|
||||||
|
//fun test4(method: Method, i: Int) = method(i)
|
||||||
|
|
||||||
|
fun box() : String {
|
||||||
|
if (test1({ it }, 1) != 1) return "fail 1"
|
||||||
|
if (test2({ it }, 2) != 2) return "fail 2"
|
||||||
|
if (test3(Method(), 3) != 3) return "fail 3"
|
||||||
|
//if (test4(Method(), 4) != 4) return "fail 4"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -101,4 +101,8 @@ public class FunctionGenTest extends CodegenTestCase {
|
|||||||
public void testLocalFunction () throws InvocationTargetException, IllegalAccessException {
|
public void testLocalFunction () throws InvocationTargetException, IllegalAccessException {
|
||||||
blackBoxFile("functions/localFunction.kt");
|
blackBoxFile("functions/localFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInvoke() {
|
||||||
|
blackBoxFile("functions/invoke.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user