JS test: added inline tests

This commit is contained in:
Alexey Tsvetkov
2014-09-29 16:00:18 +04:00
committed by Zalim Bashorov
parent 987708680f
commit 3f2d4b31be
112 changed files with 4442 additions and 0 deletions
@@ -0,0 +1,21 @@
package foo
// CHECK_CALLED_IN_SCOPE: scope=multiplyBy2 function=multiplyBy2$f
// CHECK_NOT_CALLED_IN_SCOPE: scope=multiplyBy2 function=multiplyBy2$f_0
// CHECK_NOT_CALLED_IN_SCOPE: scope=multiplyBy2 function=run
inline fun runLambdaInLambda<T>(noinline inner: (T) -> T, outer: ((T) -> T, T) -> T, arg: T): T {
return outer(inner, arg)
}
fun multiplyBy2(x: Int): Int {
return runLambdaInLambda({ it * 2 }, { f, x -> f(x) }, x)
}
fun box(): String {
assertEquals(0, multiplyBy2(0))
assertEquals(4, multiplyBy2(2))
assertEquals(8, multiplyBy2(4))
return "OK"
}