Tests for code transformation: if statement with assignments <-> assignment with if expression

This commit is contained in:
Alexey Sedunov
2013-04-04 15:52:03 +04:00
parent 9f828b8f41
commit af8c3792f6
18 changed files with 428 additions and 0 deletions
@@ -0,0 +1,21 @@
fun test(n: Int): String {
var res: String
if (n == 1) {
<caret>res = if (3 > 2) {
println("***")
"one"
} else {
println("***")
"???"
}
} else if (n == 2) {
println("***")
res = "two"
} else {
println("***")
res = "too many"
}
return res
}
@@ -0,0 +1,21 @@
fun test(n: Int): String {
var res: String
if (n == 1) {
<caret>if (3 > 2) {
println("***")
res = "one"
} else {
println("***")
res = "???"
}
} else if (n == 2) {
println("***")
res = "two"
} else {
println("***")
res = "too many"
}
return res
}
@@ -0,0 +1,21 @@
fun test(n: Int): String {
var res: String
<caret>res = if (n == 1) {
if (3 > 2) {
println("***")
"one"
} else {
println("***")
"???"
}
} else if (n == 2) {
println("***")
"two"
} else {
println("***")
"too many"
}
return res
}
@@ -0,0 +1,21 @@
fun test(n: Int): String {
var res: String
<caret>if (n == 1) {
if (3 > 2) {
println("***")
res = "one"
} else {
println("***")
res = "???"
}
} else if (n == 2) {
println("***")
res = "two"
} else {
println("***")
res = "too many"
}
return res
}
@@ -0,0 +1,13 @@
fun test(n: Int): String {
var res: String
<caret>res = if (n == 1) {
println("***")
"one"
} else {
println("***")
"two"
}
return res
}
@@ -0,0 +1,13 @@
fun test(n: Int): String {
var res: String
<caret>if (n == 1) {
println("***")
res = "one"
} else {
println("***")
res = "two"
}
return res
}
@@ -0,0 +1,12 @@
// IS_APPLICABLE: false
fun test(n: Int): String {
var res: String
<caret>if (n == 1) {
"one"
} else {
"two"
}
return res
}