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
@@ -26,18 +26,18 @@ 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})
}
}
fun test1(): Int {
val inlineX = Inline(9)
return inlineX.calcExt({(z: Int) -> z}, 25)
return inlineX.calcExt({ z: Int -> z}, 25)
}
fun test2(): Int {
@@ -58,7 +58,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)
}
@@ -6,7 +6,7 @@ class A(val a: Int)
inline fun <T, R> with2(receiver: T, arg1: R, arg2: R, f: T.(R, R) -> R): R = receiver.f(arg1, arg2)
fun multiply(a: Int, b: Int, c: Int): Int = with2(A(a), b, c) { (x, y) -> a*x*y }
fun multiply(a: Int, b: Int, c: Int): Int = with2(A(a), b, c) { x, y -> a*x*y }
fun box(): String {
assertEquals(105, multiply(3, 5, 7))
@@ -11,7 +11,7 @@ inline fun <T> doNothing2(a: T, inline f: (T) -> T): T {
}
fun doNothingNoInline(a: Int): Int {
return doNothing2(a, {(x) -> doNothing1(x)})
return doNothing2(a, { x -> doNothing1(x)})
}
fun box(): String {
@@ -16,7 +16,7 @@ inline fun filteredReduce(a: Array<Int>, inline predicate: (Int) -> Boolean, inl
}
fun sumEven(a: Array<Int>): Int {
return filteredReduce(a, {(x) -> x % 2 == 0}, {(x, y) -> x + y})
return filteredReduce(a, { x -> x % 2 == 0}, { x, y -> x + y})
}
fun box(): String {
@@ -22,7 +22,7 @@ inline fun maxBy(a: Array<Int>, inline keyFun: (Int) -> Int): Int {
fun maxBySquare(a: Array<Int>, r: Result): Result {
var invocationCount = 0
val maxVal = maxBy(a, {(x) -> invocationCount++; x * x;})
val maxVal = maxBy(a, { x -> invocationCount++; x * x;})
r.value = maxVal
r.invocationCount = invocationCount
@@ -5,14 +5,14 @@ inline fun run(func: () -> Int): Int {
}
fun bar(): Int {
var f = { () -> 0 }
var f = { -> 0 }
var get0 = f
f = { () -> 1 }
f = { -> 1 }
var get1 = f
var get2 = get1
f = { () -> 2 }
f = { -> 2 }
get2 = f
return run(get0) + run(get1) + run(get2)
@@ -7,14 +7,14 @@ inline fun run(func: () -> Int): Int {
}
fun bar(p: IntPair): Int {
var f = { () -> p.fst++ }
var f = { -> p.fst++ }
var get0 = f
f = { () -> ++p.snd }
f = { -> ++p.snd }
var get1 = f
var get2 = get1
f = { () -> ++p.fst }
f = { -> ++p.fst }
get2 = f
return run(get0) + run(get1) + run(get2)
@@ -22,23 +22,23 @@ class Inline() {
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)
}
@@ -18,18 +18,18 @@ class Inline() {
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 {
@@ -31,40 +31,40 @@ class InlineDouble(val res : Double) {
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 {
@@ -31,40 +31,40 @@ class Inline(val res : Int) {
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 {
@@ -31,40 +31,40 @@ class InlineString(val res : String) {
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 {