back end test for 'variable as function' call case

This commit is contained in:
Svetlana Isakova
2012-04-30 15:43:13 +04:00
parent 09c065b371
commit 9c0eb285e2
2 changed files with 26 additions and 0 deletions
@@ -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 {
blackBoxFile("functions/localFunction.kt");
}
public void testInvoke() {
blackBoxFile("functions/invoke.kt");
}
}