Introduce Parameter: Implement "Introduce lambda parameter"

This commit is contained in:
Alexey Sedunov
2015-04-21 20:55:06 +03:00
parent 2cc39995bb
commit 298dfa545f
31 changed files with 747 additions and 208 deletions
@@ -0,0 +1,12 @@
// WITH_DEFAULT_VALUE: false
// TARGET:
class Foo(val a: Int) {
fun foo(n: Int): Int {
val t = a + n + 1
return <selection>a - n</selection> - t
}
}
fun test() {
Foo(1).foo(2)
}
@@ -0,0 +1,12 @@
// WITH_DEFAULT_VALUE: false
// TARGET:
class Foo(val a: Int, val i: Foo.(Int) -> Int) {
fun foo(n: Int): Int {
val t = a + n + 1
return i(n) - t
}
}
fun test() {
Foo(1) { n -> a - n }.foo(2)
}
@@ -0,0 +1,11 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: String): Int {
val t = a + 1 + 2
return <selection>a
.plus(1)
.plus(2)</selection> - t
}
fun test() {
foo(1, "2")
}
@@ -0,0 +1,13 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: String, i: (Int) -> Int): Int {
val t = i(a)
return i(a) - t
}
fun test() {
foo(1, "2") { a ->
a
.plus(1)
.plus(2)
}
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: String): Int {
val t = (a + 1) * 2
return <selection>a + 1</selection> - t
}
fun test() {
foo(1, "2")
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: String, i: (Int) -> Int): Int {
val t = i(a) * 2
return i(a) - t
}
fun test() {
foo(1, "2") { a -> a + 1 }
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: () -> String): Int {
val t = (a + 1) * 2
return <selection>a + 1</selection> - t
}
fun test() {
foo(1) { "2" }
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: () -> String, i: (Int) -> Int): Int {
val t = i(a) * 2
return i(a) - t
}
fun test() {
foo(1, { "2" }) { a -> a + 1 }
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: String): Int {
val t = (a + 1) * 2
return <selection>1 + 2</selection> - t
}
fun test() {
foo(1, "2")
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, s: String, i: () -> Int): Int {
val t = (a + 1) * 2
return i() - t
}
fun test() {
foo(1, "2") { 1 + 2 }
}
@@ -0,0 +1,8 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int) {
<selection>throw Exception("Error: $a")</selection>
}
fun test() {
foo(1)
}
@@ -0,0 +1,8 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, __dummyTestFun__: (Int) -> Unit) {
__dummyTestFun__(a)
}
fun test() {
foo(1) { a -> throw Exception("Error: $a") }
}
@@ -0,0 +1,12 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int) {
}
fun bar(a: Int) {
<selection>foo(a + 1)</selection>
}
fun test() {
bar(1)
}
@@ -0,0 +1,12 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int) {
}
fun bar(a: Int, __dummyTestFun__: (Int) -> Unit) {
__dummyTestFun__(a)
}
fun test() {
bar(1) { a -> foo(a + 1) }
}
@@ -0,0 +1,8 @@
fun foo(a: Int, s: String): Int {
val t = (a + 1) * 2
return <selection>a + 1</selection> - t
}
fun test() {
foo(1, "2")
}
@@ -0,0 +1,8 @@
fun foo(a: Int, s: String, i: (Int) -> Int = { a -> a + 1 }): Int {
val t = i(a) * 2
return i(a) - t
}
fun test() {
foo(1, "2")
}