Adopt more tests for functions from codegen tests.
Create test for KT-2565.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package foo
|
||||
|
||||
fun Any.foo1() : ()-> String {
|
||||
return { "239" + this }
|
||||
}
|
||||
|
||||
fun Int.foo2() : (i : Int) -> Int {
|
||||
return { x -> x + this }
|
||||
}
|
||||
|
||||
fun fooT1<T>(t : T) = { t.toString() }
|
||||
|
||||
fun fooT2<T>(t: T) = { (x:T) -> t.toString() + x.toString() }
|
||||
|
||||
fun box() : Any? {
|
||||
if( (10.foo1())() != "23910") return "foo1 fail"
|
||||
if( (10.foo2())(1) != 11 ) return "foo2 fail"
|
||||
|
||||
if(1.{Int.() -> this + 1}() != 2) return "test 3 failed";
|
||||
if( {1}() != 1) return "test 4 failed";
|
||||
if( {(x : Int) -> x}(1) != 1) return "test 5 failed";
|
||||
if( 1.{Int.(x : Int) -> x + this}(1) != 2) return "test 6 failed";
|
||||
val tmp = 1.({Int.() -> this})()
|
||||
if(tmp != 1) return "test 7 failed, res: $tmp ${tmp is Int}";
|
||||
if( (fooT1<String>("mama"))() != "mama") return "test 8 failed";
|
||||
if( (fooT2<String>("mama"))("papa") != "mamapapa") return "test 9 failed";
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package foo
|
||||
|
||||
var c = 2
|
||||
|
||||
fun loop(var times : Int) {
|
||||
while(times > 0) {
|
||||
val u : (value : Int) -> Unit = {
|
||||
c++
|
||||
}
|
||||
u(times--)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : Any? {
|
||||
loop(5)
|
||||
return if (c == 7) return "OK" else c
|
||||
}
|
||||
Reference in New Issue
Block a user