Migrate testdata to new lambda syntax

This commit is contained in:
Stanislav Erokhin
2015-04-03 13:40:07 +03:00
parent b703f59e04
commit 3de0dff575
134 changed files with 263 additions and 277 deletions
@@ -2,7 +2,7 @@
fun box(): String {
fun rec(n : Int) {
val x = { (m : Int) ->
val x = { m : Int ->
if (n > 0) rec(n - 1)
}
@@ -1,5 +1,5 @@
fun box() : String {
return apply( "OK", {(arg: String) -> arg } )
return apply( "OK", {arg: String -> arg } )
}
fun apply(arg : String, f : (p:String) -> String) : String {
@@ -1,5 +1,5 @@
fun box() : String {
return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail"
return if (apply( 5, {arg: Int -> arg + 13 } ) == 18) "OK" else "fail"
}
fun apply(arg : Int, f : (p:Int) -> Int) : Int {
@@ -1,6 +1,6 @@
class Point(val x:Int, val y:Int) {
fun mul() : (scalar:Int)->Point {
return { (scalar:Int):Point -> Point(x * scalar, y * scalar) }
return { scalar:Int -> Point(x * scalar, y * scalar) }
}
}
@@ -1,7 +1,7 @@
class Point(val x : Int, val y : Int)
fun box() : String {
val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point ->
val answer = apply(Point(3, 5), { scalar : Int ->
Point(x * scalar, y * scalar)
})
@@ -1,13 +1,13 @@
fun box(): String {
val a = 1
val explicitlyReturned = run1 @f{(): String ->
val explicitlyReturned = run1 @f{
if (a > 0)
return@f "OK"
else "Fail 1"
}
if (explicitlyReturned != "OK") return explicitlyReturned
val implicitlyReturned = run1 @f{(): String ->
val implicitlyReturned = run1 @f{
if (a < 0)
return@f "Fail 2"
else "OK"
@@ -1,13 +1,13 @@
fun box(): String {
val a = 1
val explicitlyReturned = run1 {(): String ->
val explicitlyReturned = run1 {
if (a > 0)
return@run1 "OK"
else "Fail 1"
}
if (explicitlyReturned != "OK") return explicitlyReturned
val implicitlyReturned = run1 {(): String ->
val implicitlyReturned = run1 {
if (a < 0)
return@run1 "Fail 2"
else "OK"
@@ -5,7 +5,7 @@ fun main(args: Array<String>?) {
//do not compile
System.out?.println(fff<Unit>(Unit)) //do not compile
System.out?.println(id<Unit>(y)) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(arrayOfNulls<Int>(0) as Array<Int>,{(e : Int) : Unit -> }))) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(arrayOfNulls<Int>(0) as Array<Int>,{ e : Int -> }))) //do not compile
}
class A<T>()
@@ -34,8 +34,8 @@ fun box() : String {
a[0] = 0
a[1] = 1
a[2] = 2
foreach(a, { (el : Int) : Unit -> System.out?.println(el) })
almostFilter(a, { (el : Int) : Int -> el })
foreach(a, { el : Int -> System.out?.println(el) })
almostFilter(a, { el : Int -> el })
main(null)
return "OK"
}
@@ -1,7 +1,7 @@
//KT-1061 Can't call function defined as a val
object X {
val doit = { (i: Int) -> i }
val doit = { i: Int -> i }
}
fun box() : String = if (X.doit(3) == 3) "OK" else "fail"
@@ -6,7 +6,7 @@ class Foo<T>(val filter: (T) -> Boolean) {
}
}
fun foo() = Foo({ (i: Int) -> i < 5 }).bar(2)
fun foo() = Foo({ i: Int -> i < 5 }).bar(2)
fun box() : String {
if (!foo()) return "fail"
@@ -1,6 +1,6 @@
fun box() : String {
val y = 12
val op = { (x:Int) -> (x + y).toString() }
val op = { x:Int -> (x + y).toString() }
val op2 : Int.(Int) -> String = { op(this + it) }
@@ -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)
}
}
@@ -1,6 +1,6 @@
val Int.getter: Int
get() {
val extFun = { Int.() ->
val extFun: Int.() -> Int = {
this@getter
}
return this@getter.extFun()
@@ -10,7 +10,7 @@ val Int.getter: Int
var Int.setter: Int
get() = 1
set(i: Int) {
val extFun = { Int.() ->
val extFun: Int.() -> Int = {
this@setter
}
this@setter.extFun()
@@ -10,13 +10,13 @@ fun assertGenericSuper(expected: String, function: Any?) {
val unitFun = { }
val intFun = { 42 }
val stringParamFun = { (x: String) : Unit -> }
val listFun = { (l: List<String>) : List<String> -> l }
val mutableListFun = { (l: MutableList<Double>) : MutableList<Int> -> null!! }
val funWithIn = { (x: Comparable<String>) : Unit -> }
val stringParamFun = { x: String -> }
val listFun = { l: List<String> -> l }
val mutableListFun = fun (l: MutableList<Double>): MutableList<Int> = null!!
val funWithIn = fun (x: Comparable<String>) {}
val extensionFun = { Any.() : Unit -> }
val extensionWithArgFun = { Long.(x: Any) : Date -> Date() }
val extensionFun = fun Any.() {}
val extensionWithArgFun = fun Long.(x: Any): Date = Date()
fun box(): String {
assertGenericSuper("kotlin.Function0<kotlin.Unit>", unitFun)
@@ -1,4 +1,4 @@
fun box(): String {
val sum = {Int.(other: Int) -> this + other }
val sum = fun Int.(other: Int) = this + other
return if (1 sum 2 == 3) "OK" else "Fail"
}
@@ -19,7 +19,7 @@ fun test2() {
}
fun Int.foo(a: Int) = this * a
val boo = {Int.(a: Int): Int -> this + a}
val boo = fun Int.(a: Int): Int = this + a
fun box(): String {
test1()
@@ -4,7 +4,7 @@ fun box(): String {
val list = ArrayList(Arrays.asList(3, 2, 4, 8, 1, 5))
val expected = ArrayList(Arrays.asList(8, 5, 4, 3, 2, 1))
val f = { (a: Int, b: Int) -> b - a }
val f = { a: Int, b: Int -> b - a }
JavaClass.sortIntList(list, f)
return if (list == expected) "OK" else list.toString()
}
@@ -1,7 +1,7 @@
fun testAll(): String {
val inlineX = InlineAll()
return inlineX.inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
return inlineX.inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5},
1, 12.0, 13.0, "14", 15)
}
@@ -19,7 +19,7 @@ fun testAllWithCapturedVal(): String {
val c8 = 27.toShort()
val c9 = 28.toFloat()
return inlineX.inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
return inlineX.inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
}
@@ -37,7 +37,7 @@ fun testAllWithCapturedVar(): String {
var c8 = 27.toShort()
val c9 = 28.toFloat()
return inlineX.inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
return inlineX.inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
}
@@ -55,7 +55,7 @@ fun testAllWithCapturedValAndVar(): String {
var c8 = 27.toShort()
val c9 = 28.toFloat()
return inlineX.inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
return inlineX.inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
}
@@ -1,7 +1,7 @@
fun testAll(): String {
return inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
"" + a1 + a2 + a3 + a4 + a5},
1, 12.0, 13.0, "14", 15)
return inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5},
1, 12.0, 13.0, "14", 15)
}
fun testAllWithCapturedVal(): String {
@@ -15,9 +15,9 @@ fun testAllWithCapturedVal(): String {
val c8 = 27.toShort()
val c9 = 28.toFloat()
return inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
return inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
}
fun testAllWithCapturedVar(): String {
@@ -31,9 +31,9 @@ fun testAllWithCapturedVar(): String {
var c8 = 27.toShort()
val c9 = 28.toFloat()
return inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
return inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
}
fun testAllWithCapturedValAndVar(): String {
@@ -47,9 +47,9 @@ fun testAllWithCapturedValAndVar(): String {
var c8 = 27.toShort()
val c9 = 28.toFloat()
return inline({(a1: Int, a2: Double, a3: Double, a4: String, a5: Long) ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
return inline({ a1: Int, a2: Double, a3: Double, a4: String, a5: Long ->
"" + a1 + a2 + a3 + a4 + a5 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9},
1, 12.0, 13.0, "14", 15)
}
@@ -1,6 +1,6 @@
fun test1(): Int {
val inlineX = Inline()
return inlineX.foo({(z: Int) -> "" + z}, 25, {String.() -> this.length()})
return inlineX.foo({ z: Int -> "" + z}, 25, fun String.(): Int = this.length())
}
fun box(): String {
@@ -8,10 +8,10 @@ fun testExtensionInClass() : String {
res = with(Z(1)) { "1".run() }
if (res != "1null") return "failed in class 2: $res"
res = with(Z(2)) { "3".run("OK", {(a, b) -> a + b + value }, 1) }
res = with(Z(2)) { "3".run("OK", { a, b -> a + b + value }, 1) }
if (res != "OK123") return "failed in class 3: $res"
res = with(Z(3)) { "4".run(lambda = {(a, b) -> a + b + value }) }
res = with(Z(3)) { "4".run(lambda = { a, b -> a + b + value }) }
if (res != "034") return "failed in class 4: $res"
return "OK"
@@ -25,10 +25,10 @@ fun box(): String {
res = "1".run()
if (res != "1null") return "failed 2: $res"
res = "3".run("OK", {(a, b) -> a + b}, 1)
res = "3".run("OK", { a, b -> a + b}, 1)
if (res != "OK13") return "failed 3: $res"
res = "4".run(lambda = {(a, b) -> a + b})
res = "4".run(lambda = { a, b -> a + b})
if (res != "04") return "failed 4: $res"
return testExtensionInClass()
@@ -5,9 +5,9 @@ fun box(): String {
if (Z().run("OK") != "OK0") return "fail 2"
if (Z().run("OK", {(a, b) -> a + b }, 1) != "OK1") return "fail 3"
if (Z().run("OK", { a, b -> a + b }, 1) != "OK1") return "fail 3"
if (Z().run(lambda = {(a: String, b: Int) -> a + b }) != "0") return "fail 4"
if (Z().run(lambda = { a: String, b: Int -> a + b }) != "0") return "fail 4"
return "OK"
}
@@ -1,5 +1,5 @@
fun test1(): Int {
return calc( {(l : Int) -> 2*l}, {(l : Int) -> 4*l})
return calc( { l: Int -> 2*l}, { l: Int -> 4*l})
}
@@ -1,6 +1,6 @@
fun test1(): Int {
val inlineX = Inline()
var p = {(l : Int) -> l};
var p = { l : Int -> l};
return inlineX.calc(p, 25)
}
@@ -2,7 +2,6 @@ import test.*
fun test1(b: Boolean): String {
val localResult = doCall ((@local {
() : String ->
if (b) {
return@local "local"
} else {
@@ -2,7 +2,6 @@ import test.*
fun test1(b: Boolean): String {
val localResult = doCall @local {
() : String ->
if (b) {
return@local "local"
} else {
@@ -2,7 +2,6 @@ import test.*
fun test1(b: Boolean): String {
val localResult = doCall @local {
() : String ->
if (b) {
return@local "local"
} else {
@@ -16,10 +16,8 @@ class Global(val value: String)
fun test1(intKind: Kind, extKind: Kind): Global {
var externalResult = doCall @ext {
() : External ->
val internalResult = doCall @int {
() : Internal ->
if (intKind == Kind.GLOBAL) {
return@test1 Global("internal -> global")
} else if (intKind == EXTERNAL) {
@@ -2,7 +2,6 @@ import test.*
fun test1(b: Boolean): String {
val localResult = noInlineCall @local {
() : Int ->
if (b) {
return@local 1
} else {
@@ -23,11 +23,9 @@ fun test1(intKind: Kind, extKind: Kind, holder: Holder): Global {
holder.value = ""
try {
var externalResult = doCall @ext {
(): External ->
try {
val internalResult = doCall @int {
(): Internal ->
try {
if (intKind == Kind.GLOBAL) {
return@test1 Global("internal -> global")
@@ -23,11 +23,9 @@ fun test1(intKind: Kind, extKind: Kind, holder: Holder): Global {
holder.value = ""
try {
var externalResult = doCall (@ext {
(): External ->
try {
val internalResult = doCall (@int {
(): Internal ->
try {
if (intKind == Kind.GLOBAL) {
return@test1 Global("internal -> global")
@@ -18,7 +18,6 @@ fun test1(h: Holder): String {
fun test2(h: Holder): String {
val localResult = doCall (@lambda {
(): String ->
h.value += "OK_LOCAL"
return@lambda "OK_LOCAL"
}, {
@@ -22,7 +22,6 @@ fun test1(h: Holder): String {
fun test2(h: Holder): String {
val localResult = doCall (
@lambda {
(): String ->
h.value += "OK_NONLOCAL"
return@lambda "OK_NONLOCAL"
}, {
@@ -47,14 +46,12 @@ fun test3(h: Holder): String {
}
fun test4(h: Holder): String {
val localResult = doCall (
val localResult = doCall<String> (
{
():String ->
h.value += "OK_NONLOCAL"
return "OK_NONLOCAL"
},
@l2 {
():String ->
h.value += ", OK_FINALLY"
return@l2 "OK_FINALLY"
})
@@ -1,11 +1,11 @@
fun test1(): Int {
val inlineX = Inline(9)
return inlineX.calcExt({(z: Int) -> z}, 25)
return inlineX.calcExt({ z: Int -> z}, 25)
}
fun test2(): Int {
val inlineX = Inline(9)
return inlineX.calcExt2({Int.() -> this}, 25)
return inlineX.calcExt2(fun Int.(): Int = this, 25)
}
fun test3(): Int {
@@ -21,7 +21,7 @@ fun test4(): Double {
fun test5(): Double {
val inlineX = Inline(9)
with(inlineX) {
11.0.calcDouble{(a: Int, b: Double) -> a + b}
11.0.calcDouble{ a: Int, b: Double -> a + b}
}
return inlineX.doWorkWithDouble(11.0)
}
@@ -19,11 +19,11 @@ class Inline(val res: Int) {
}
fun doWork(l : InlineX) : Int {
return l.calcInt({(a: Int, b: Int) -> a + b})
return l.calcInt({ a: Int, b: Int -> a + b})
}
fun doWorkWithDouble(s : Double) : Double {
return s.calcDouble({(a: Int, b: Double) -> a + b})
return s.calcDouble({ a: Int, b: Double -> a + b})
}
}
@@ -1,23 +1,23 @@
fun test1(): Int {
val inlineX = Inline()
return inlineX.foo1Int({(z: Int) -> z}, 25)
return inlineX.foo1Int({ z: Int -> z}, 25)
}
fun test2(): Double {
val inlineX = Inline()
return inlineX.foo1Double(25.0, {(z: Double) -> z})
return inlineX.foo1Double(25.0, { z: Double -> z})
}
fun test3(): Double {
val inlineX = Inline()
return inlineX.foo2Param(15.0, {(z1: Int, z2: Double) -> z1 + z2}, 10)
return inlineX.foo2Param(15.0, { z1: Int, z2: Double -> z1 + z2}, 10)
}
fun test3WithCaptured(): Double {
val inlineX = Inline()
var c = 11.0;
return inlineX.foo2Param(15.0, {(z1: Int, z2: Double) -> z1 + z2 + c}, 10)
return inlineX.foo2Param(15.0, { z1: Int, z2: Double -> z1 + z2 + c}, 10)
}
@@ -1,17 +1,17 @@
fun test1(): Double {
val inlineX = Inline()
return inlineX.foo1({(z: Int) -> z}, 25, {(z: Double) -> z}, 11.5)
return inlineX.foo1({ z: Int -> z}, 25, { z: Double -> z}, 11.5)
}
fun test1WithCaptured(): Double {
val inlineX = Inline()
var d = 0.0;
return inlineX.foo1({(z: Int) -> d = 1.0; z}, 25, {(z: Double) -> z + d}, 11.5)
return inlineX.foo1({ z: Int -> d = 1.0; z}, 25, { z: Double -> z + d}, 11.5)
}
fun test2(): Double {
val inlineX = Inline()
return inlineX.foo2({(z: Int, p: Int) -> z + p}, 25, {(x: Double, y: Int, z: Int) -> z + x + y}, 11.5, 2)
return inlineX.foo2({ z: Int, p: Int -> z + p}, 25, { x: Double, y: Int, z: Int -> z + x + y}, 11.5, 2)
}
fun box(): String {
@@ -1,39 +1,39 @@
fun test0Param(): Double {
val inlineX = InlineDouble(10.0)
return inlineX.foo({() -> 1.0})
return inlineX.foo({ -> 1.0})
}
fun test1Param(): Double {
val inlineX = InlineDouble(10.0)
return inlineX.foo11({(z: Double) -> z})
return inlineX.foo11({ z: Double -> z})
}
fun test1ParamCaptured(): Double {
val s = 100.0
val inlineX = InlineDouble(10.0)
return inlineX.foo11({(z: Double) -> s})
return inlineX.foo11({ z: Double -> s})
}
fun test1ParamMissed() : Double {
val inlineX = InlineDouble(10.0)
return inlineX.foo11({(z: Double) -> 111.0})
return inlineX.foo11({ z: Double -> 111.0})
}
fun test1ParamFromCallContext() : Double {
val inlineX = InlineDouble(1000.0)
return inlineX.fooRes({(z: Double) -> z})
return inlineX.fooRes({ z: Double -> z})
}
fun test2Params() : Double {
val inlineX = InlineDouble(1000.0)
return inlineX.fooRes2({(y: Double, z: Double) -> 2.0 * y + 3.0 * z})
return inlineX.fooRes2({ y: Double, z: Double -> 2.0 * y + 3.0 * z})
}
fun test2ParamsWithCaptured() : Double {
val inlineX = InlineDouble(1000.0)
val s = 9.0
var t = 1.0
return inlineX.fooRes2({(y: Double, z: Double) -> 2.0 * s + t})
return inlineX.fooRes2({ y: Double, z: Double -> 2.0 * s + t})
}
fun box(): String {
@@ -1,39 +1,39 @@
fun test0Param(): Int {
val inlineX = Inline(10)
return inlineX.foo({() -> 1})
return inlineX.foo({ -> 1})
}
fun test1Param(): Int {
val inlineX = Inline(10)
return inlineX.foo11({(z: Int) -> z})
return inlineX.foo11({ z: Int -> z})
}
fun test1ParamCaptured(): Int {
val s = 100
val inlineX = Inline(10)
return inlineX.foo11({(z: Int) -> s})
return inlineX.foo11({ z: Int -> s})
}
fun test1ParamMissed() : Int {
val inlineX = Inline(10)
return inlineX.foo11({(z: Int) -> 111})
return inlineX.foo11({ z: Int -> 111})
}
fun test1ParamFromCallContext() : Int {
val inlineX = Inline(1000)
return inlineX.fooRes({(z: Int) -> z})
return inlineX.fooRes({ z: Int -> z})
}
fun test2Params() : Int {
val inlineX = Inline(1000)
return inlineX.fooRes2({(y: Int, z: Int) -> 2 * y + 3 * z})
return inlineX.fooRes2({ y: Int, z: Int -> 2 * y + 3 * z})
}
fun test2ParamsWithCaptured() : Int {
val inlineX = Inline(1000)
val s = 9
var t = 1
return inlineX.fooRes2({(y: Int, z: Int) -> 2 * s + t})
return inlineX.fooRes2({ y: Int, z: Int -> 2 * s + t})
}
fun box(): String {
@@ -1,39 +1,39 @@
fun test0Param(): String {
val inlineX = InlineString("10")
return inlineX.foo({() -> "1"})
return inlineX.foo({ -> "1"})
}
fun test1Param(): String {
val inlineX = InlineString("10")
return inlineX.foo11({(z: String) -> z})
return inlineX.foo11({ z: String -> z})
}
fun test1ParamCaptured(): String {
val s = "100"
val inlineX = InlineString("10")
return inlineX.foo11({(z: String) -> s})
return inlineX.foo11({ z: String -> s})
}
fun test1ParamMissed() : String {
val inlineX = InlineString("10")
return inlineX.foo11({(z: String) -> "111"})
return inlineX.foo11({ z: String -> "111"})
}
fun test1ParamFromCallContext() : String {
val inlineX = InlineString("1000")
return inlineX.fooRes({(z: String) -> z})
return inlineX.fooRes({ z: String -> z})
}
fun test2Params() : String {
val inlineX = InlineString("1000")
return inlineX.fooRes2({(y: String, z: String) -> y + "0" + z})
return inlineX.fooRes2({ y: String, z: String -> y + "0" + z})
}
fun test2ParamsWithCaptured() : String {
val inlineX = InlineString("1000")
val s = "9"
var t = "1"
return inlineX.fooRes2({(y: String, z: String) -> s + t})
return inlineX.fooRes2({ y: String, z: String -> s + t})
}
fun box(): String {
@@ -1,5 +1,5 @@
package test
inline fun doSmth(vararg a: String) : String {
return a.foldRight("", {(a, b) -> a + b})
return a.foldRight("", { a, b -> a + b})
}
@@ -1,13 +1,13 @@
fun test1(): String {
val inlineX = My()
var d = "";
inlineX.doWork({(z: String) -> d = z; z})
inlineX.doWork({ z: String -> d = z; z})
return d
}
fun test2(): Int {
val inlineX = My()
return inlineX.perform({(z: My) -> 11})
return inlineX.perform({ z: My -> 11})
}
fun box(): String {
@@ -17,7 +17,7 @@ fun test11(): Int {
throw RuntimeException("2")
}
},
{(ex, thizz) ->
{ ex, thizz ->
if (ex.getMessage() == "2") {
thizz.value
} else {
@@ -48,7 +48,7 @@ fun test22(): Int {
111
}
},
{(ex, thizz) ->
{ ex, thizz ->
-11111
})
@@ -80,7 +80,7 @@ fun test33(): Int {
throw RuntimeException("-2")
}
},
{(ex, thizz) ->
{ ex, thizz ->
if (ex.getMessage() == "-2") {
throw RuntimeException("-3")
} else {
@@ -48,7 +48,7 @@ fun test3(): Int {
result = it.value;
throw RuntimeException("-1")
},
{ (e, z)->
{ e, z ->
++result
throw RuntimeException("-2")
},
@@ -1,10 +1,10 @@
fun Array<String>.test1(): Array<String> {
val func = {(i:Int) -> this}
val func = { i:Int -> this}
return func(1)
}
fun Array<String>.test1Nested(): Array<String> {
val func = {(i:Int) -> { this }()}
val func = { i: Int -> { this }()}
return func(1)
}
@@ -71,7 +71,7 @@ fun Array<String>.test4Nested() : Array<String> {
}
fun Array<DoubleArray>.test1(): Array<DoubleArray> {
val func = {(i:Int) -> this}
val func = { i: Int -> this}
return func(1)
}
@@ -16,6 +16,6 @@ fun box(): String {
list.add("Moscow")
list.add("Munich")
val m: ArrayList<String> = list.findAll<String>({(name: String) -> name.startsWith("M")})
val m: ArrayList<String> = list.findAll<String>({ name: String -> name.startsWith("M")})
return if (m.size() == 2) "OK" else "fail"
}
@@ -1,5 +1,5 @@
fun test() {
1.{Int.() -> 2}()
1.(fun Int.() = 2)()
}
// 1 invoke \(I\)I