Extract Function: Add test data
This commit is contained in:
+15
@@ -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()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Cannot extract method since following types are not denotable in the target scope: foo.<no name provided>
|
||||
+7
@@ -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
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has multiple exit points
|
||||
+7
@@ -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
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has multiple exit points
|
||||
+11
@@ -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
|
||||
}
|
||||
+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
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has multiple exit points
|
||||
+10
@@ -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
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has multiple exit points
|
||||
+15
@@ -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
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has output values as well as alternative exit points
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(a: Int): Int {
|
||||
var b: Int = 1
|
||||
|
||||
<selection>b += a
|
||||
println(b)
|
||||
return b</selection>
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has output values as well as alternative exit points
|
||||
+9
@@ -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
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Selected code fragment has output values as well as alternative exit points
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// NEXT_SIBLING:
|
||||
fun foo(t: Int): Int {
|
||||
<selection>val x = t + 1
|
||||
if (x > 0) return x</selection>
|
||||
return 0
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Following declarations won't be available outside of extracted function body: x
|
||||
Reference in New Issue
Block a user