Extract Function: Add test data

This commit is contained in:
Alexey Sedunov
2014-04-10 20:09:13 +04:00
parent 4dec0508a6
commit 0d90dcf010
111 changed files with 1596 additions and 13 deletions
@@ -0,0 +1,15 @@
trait Callable<T> {
fun call(): T
}
fun foo(a: Int): Int {
// NEXT_SIBLING:
val o = <selection>object: Callable<Int> {
val b: Int = 1
override fun call(): Int {
return a + b
}
}</selection>
return o.call()
}
@@ -0,0 +1 @@
Cannot extract method since following types are not denotable in the target scope: foo.&lt;no name provided&gt;
@@ -0,0 +1,7 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
val t = <selection>if (a > 0) return a else a + b</selection>
return t
}
@@ -0,0 +1 @@
Selected code fragment has multiple exit points
@@ -0,0 +1,7 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
val t = <selection>if (a > 0) throw Exception("") else a + b</selection>
return t
}
@@ -0,0 +1 @@
Selected code fragment has multiple exit points
@@ -0,0 +1,11 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
<selection>if (a + b > 0) break
println(a - b)
if (a - b > 0) return 0
println(a + b)</selection>
}
return 1
}
@@ -0,0 +1 @@
Selected code fragment has multiple exit points
@@ -0,0 +1,11 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
<selection>if (a + b > 0) break
println(a - b)
if (a - b > 0) continue
println(a + b)</selection>
}
return 1
}
@@ -0,0 +1 @@
Selected code fragment has multiple exit points
@@ -0,0 +1,10 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>if (a > 0) return a
if (a < 0) return b
</selection>
return t
}
@@ -0,0 +1 @@
Selected code fragment has multiple exit points
@@ -0,0 +1,15 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
val t = <selection>if (a > 0) {
b += a
b
}
else {
a
}</selection>
println(b)
return t
}
@@ -0,0 +1 @@
Selected code fragment has output values as well as alternative exit points
@@ -0,0 +1,8 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
<selection>b += a
println(b)
return b</selection>
}
@@ -0,0 +1 @@
Selected code fragment has output values as well as alternative exit points
@@ -0,0 +1,9 @@
// NEXT_SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
<selection>if (n == 10) throw Exception("")
b++</selection>
return b
}
@@ -0,0 +1 @@
Selected code fragment has output values as well as alternative exit points
@@ -0,0 +1,6 @@
// NEXT_SIBLING:
fun foo(t: Int): Int {
<selection>val x = t + 1
if (x > 0) return x</selection>
return 0
}
@@ -0,0 +1 @@
Following declarations won't be available outside of extracted function body: x