Migrate testdata to new lambda syntax
This commit is contained in:
@@ -8,17 +8,17 @@ fun Int.foo2() : (i : Int) -> Int {
|
||||
|
||||
fun fooT1<T>(t : T) = { t.toString() }
|
||||
|
||||
fun fooT2<T>(t: T) = { (x:T) -> t.toString() + x.toString() }
|
||||
fun fooT2<T>(t: T) = { x:T -> t.toString() + x.toString() }
|
||||
|
||||
fun box() : String {
|
||||
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.(fun 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";
|
||||
if( 1.({Int.() -> this})() != 1) return "test 7 failed";
|
||||
if( {x : Int -> x}(1) != 1) return "test 5 failed";
|
||||
if( 1.(fun Int.(x: Int) = x + this)(1) != 2) return "test 6 failed";
|
||||
if( 1.(fun Int.() = this)() != 1) return "test 7 failed";
|
||||
if( (fooT1<String>("mama"))() != "mama") return "test 8 failed";
|
||||
if( (fooT2<String>("mama"))("papa") != "mamapapa") return "test 9 failed";
|
||||
return "OK"
|
||||
|
||||
@@ -7,22 +7,22 @@ fun check(expected: String, obj: Any?) {
|
||||
|
||||
fun box(): String {
|
||||
check("kotlin.Function0<kotlin.Unit>")
|
||||
{ () : Unit -> }
|
||||
{ -> }
|
||||
check("kotlin.Function0<java.lang.Integer>")
|
||||
{ () : Int -> 42 }
|
||||
check("kotlin.Function1<java.lang.String, java.lang.Long>")
|
||||
{ (s: String) : Long -> 42.toLong() }
|
||||
{ -> 42 }
|
||||
check("kotlin.Function1<java.lang.String, java.lang.Long>",
|
||||
fun (s: String) = 42.toLong())
|
||||
check("kotlin.Function2<java.lang.Integer, java.lang.Integer, kotlin.Unit>")
|
||||
{ (x: Int, y: Int) : Unit -> }
|
||||
{ x: Int, y: Int -> }
|
||||
|
||||
check("kotlin.ExtensionFunction0<java.lang.Integer, kotlin.Unit>")
|
||||
{ Int.() : Unit -> }
|
||||
check("kotlin.ExtensionFunction0<kotlin.Unit, java.lang.Integer>")
|
||||
{ Unit.() : Int -> 42 }
|
||||
check("kotlin.ExtensionFunction1<java.lang.String, java.lang.String, java.lang.Long>")
|
||||
{ String.(s: String) : Long -> 42.toLong() }
|
||||
check("kotlin.ExtensionFunction2<java.lang.Integer, java.lang.Integer, java.lang.Integer, kotlin.Unit>")
|
||||
{ Int.(x: Int, y: Int) : Unit -> }
|
||||
check("kotlin.ExtensionFunction0<java.lang.Integer, kotlin.Unit>",
|
||||
fun Int.() {})
|
||||
check("kotlin.ExtensionFunction0<kotlin.Unit, java.lang.Integer>",
|
||||
fun Unit.(): Int = 42)
|
||||
check("kotlin.ExtensionFunction1<java.lang.String, java.lang.String, java.lang.Long>",
|
||||
fun String.(s: String): Long = 42.toLong())
|
||||
check("kotlin.ExtensionFunction2<java.lang.Integer, java.lang.Integer, java.lang.Integer, kotlin.Unit>",
|
||||
fun Int.(x: Int, y: Int) {})
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@ fun B.test(): String {
|
||||
if (foo()() != "##") return "fail3"
|
||||
if (foo()(42) != "#42") return "fail4"
|
||||
if ((foo())(42) != "#42") return "fail5"
|
||||
if ({() -> A()}()() != "##") return "fail6"
|
||||
if ({() -> A()}()(37) != "#37") return "fail7"
|
||||
if ({ -> A()}()() != "##") return "fail6"
|
||||
if ({ -> A()}()(37) != "#37") return "fail7"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ fun box(): String {
|
||||
if (foo()() != "##") return "fail3"
|
||||
if (foo()(42) != "#42") return "fail4"
|
||||
if ((foo())(42) != "#42") return "fail5"
|
||||
if ({() -> A()}()() != "##") return "fail6"
|
||||
if ({() -> A()}()(37) != "#37") return "fail7"
|
||||
if ({ -> A()}()() != "##") return "fail6"
|
||||
if ({ -> A()}()(37) != "#37") return "fail7"
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
fun Any.with(operation : Any.() -> Any) = operation().toString()
|
||||
|
||||
val f = { (a : Int) :Unit -> }
|
||||
val f = { a : Int -> }
|
||||
|
||||
fun box () : String {
|
||||
return if(20.with {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A() {
|
||||
var x : Int = 0
|
||||
|
||||
var z = { () ->
|
||||
var z = {
|
||||
x++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ fun outer() {
|
||||
fun inner(i: Int) {
|
||||
if (i > 0){
|
||||
{
|
||||
(it: Int) -> inner(0) // <- invocation of literal itself is generated instead
|
||||
it: Int -> inner(0) // <- invocation of literal itself is generated instead
|
||||
}.invoke(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user