Add tests for folding/unfolding operations
This commit is contained in:
@@ -306,8 +306,7 @@ public class GenerateTests {
|
|||||||
"CodeTransformationsTestGenerated",
|
"CodeTransformationsTestGenerated",
|
||||||
AbstractCodeTransformationTest.class,
|
AbstractCodeTransformationTest.class,
|
||||||
testModel("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression", "doTestIfStatementWithAssignmentsToExpression"),
|
testModel("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression", "doTestIfStatementWithAssignmentsToExpression"),
|
||||||
testModel("idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement", "doTestAssignmentWithIfExpressionToStatement"),
|
testModel("idea/testData/codeInsight/codeTransformations/assignmentWithIfExpressionToStatement", "doTestAssignmentWithIfExpressionToStatement")
|
||||||
testModel("idea/testData/codeInsight/codeTransformations/removeUnnecessaryParentheses", "doTestRemoveUnnecessaryParentheses")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
generateTest(
|
generateTest(
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
if (3 > 2) {
|
||||||
|
<caret>when(n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
res = "one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
res = "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
res = "???"
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
if (3 > 2) {
|
||||||
|
<caret>res = when(n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
"two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
res = "???"
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>if (n == 1) res = "one" else res = "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>res = if (n == 1) "one" else "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = "!"
|
||||||
|
|
||||||
|
<caret>if (n == 1) res += "one" else res += "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = "!"
|
||||||
|
|
||||||
|
<caret>res += if (n == 1) "one" else "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = ""
|
||||||
|
|
||||||
|
<caret>if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
res = "one"
|
||||||
|
} else {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
println("***")
|
||||||
|
res = "two"
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(s: String): Int {
|
||||||
|
var n: Int = 1;
|
||||||
|
|
||||||
|
<caret>if (s.equals("add")) {
|
||||||
|
n += 1
|
||||||
|
} else {
|
||||||
|
n -= 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return n
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = ""
|
||||||
|
var res2: String = ""
|
||||||
|
|
||||||
|
<caret>if (n == 1) {
|
||||||
|
res = "one"
|
||||||
|
} else {
|
||||||
|
res2 = "two"
|
||||||
|
}
|
||||||
|
|
||||||
|
return res + res2
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>when(n) {
|
||||||
|
1 -> res = "one"
|
||||||
|
else -> res = "two"
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>res = when(n) {
|
||||||
|
1 -> "one"
|
||||||
|
else -> "two"
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>when (n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
res = "one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
res = "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>res = when (n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
"two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = ""
|
||||||
|
|
||||||
|
<caret>when (n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
res = "one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
res = "two"
|
||||||
|
println("***")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = ""
|
||||||
|
var res2: String = ""
|
||||||
|
|
||||||
|
<caret>when (n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
res = "one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
res2 = "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res + res2
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>when (n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
res = "one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
res = "two"
|
||||||
|
println("***")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1) return "one"
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1) "one" else "two"
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
return "one"
|
||||||
|
}
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
} else "two"
|
||||||
|
}
|
||||||
+6
-10
@@ -1,21 +1,17 @@
|
|||||||
fun test(n: Int): String {
|
fun test(n: Int): String {
|
||||||
var res: String
|
if (n == 1) {
|
||||||
|
<caret>if (3 > 2) {
|
||||||
<caret>if (n == 1) {
|
|
||||||
if (3 > 2) {
|
|
||||||
println("***")
|
println("***")
|
||||||
res = "one"
|
return "one"
|
||||||
} else {
|
} else {
|
||||||
println("***")
|
println("***")
|
||||||
res = "???"
|
return "???"
|
||||||
}
|
}
|
||||||
} else if (n == 2) {
|
} else if (n == 2) {
|
||||||
println("***")
|
println("***")
|
||||||
res = "two"
|
return "two"
|
||||||
} else {
|
} else {
|
||||||
println("***")
|
println("***")
|
||||||
res = "too many"
|
return "too many"
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
+6
-10
@@ -1,21 +1,17 @@
|
|||||||
fun test(n: Int): String {
|
fun test(n: Int): String {
|
||||||
var res: String
|
if (n == 1) {
|
||||||
|
<caret>return if (3 > 2) {
|
||||||
<caret>if (n == 1) {
|
|
||||||
if (3 > 2) {
|
|
||||||
println("***")
|
println("***")
|
||||||
res = "one"
|
"one"
|
||||||
} else {
|
} else {
|
||||||
println("***")
|
println("***")
|
||||||
res = "???"
|
"???"
|
||||||
}
|
}
|
||||||
} else if (n == 2) {
|
} else if (n == 2) {
|
||||||
println("***")
|
println("***")
|
||||||
res = "two"
|
return "two"
|
||||||
} else {
|
} else {
|
||||||
println("***")
|
println("***")
|
||||||
res = "too many"
|
return "too many"
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
if (3 > 2) {
|
||||||
|
<caret>when (n) {
|
||||||
|
1 -> return "one"
|
||||||
|
else -> return "two"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "???"
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
if (3 > 2) {
|
||||||
|
<caret>return when (n) {
|
||||||
|
1 -> "one"
|
||||||
|
else -> "two"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "???"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1)
|
||||||
|
return "one"
|
||||||
|
else
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1)
|
||||||
|
"one"
|
||||||
|
else
|
||||||
|
"two"
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
return "one"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
"two"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>when (n) {
|
||||||
|
1 -> return "one"
|
||||||
|
else -> return "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return when (n) {
|
||||||
|
1 -> "one"
|
||||||
|
else -> "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>when(n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
return "one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return when(n) {
|
||||||
|
1 -> {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
println("***")
|
||||||
|
"two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -1,15 +1,15 @@
|
|||||||
fun test(n: Int): String {
|
fun test(n: Int): String {
|
||||||
var res: String
|
var res: String
|
||||||
|
|
||||||
<caret>res = if (n == 1) {
|
<caret>if (n == 1) {
|
||||||
if (3 > 2) {
|
res = if (3 > 2) {
|
||||||
println("***")
|
println("***")
|
||||||
"one"
|
"one"
|
||||||
} else {
|
} else {
|
||||||
println("***")
|
println("***")
|
||||||
"???"
|
"???"
|
||||||
}
|
}
|
||||||
} else if (n == 2) {
|
} else res = if (n == 2) {
|
||||||
println("***")
|
println("***")
|
||||||
"two"
|
"two"
|
||||||
} else {
|
} else {
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>res = if (n == 1) "one" else "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String
|
||||||
|
|
||||||
|
<caret>if (n == 1) res = "one" else res = "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = "!"
|
||||||
|
|
||||||
|
<caret>res += if (n == 1) "one" else "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
var res: String = "!"
|
||||||
|
|
||||||
|
<caret>if (n == 1) res += "one" else res += "two"
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1) "one" else "two"
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1) return "one" else return "two"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
} else "two"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
return "one"
|
||||||
|
} else return "two"
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
if (n == 1) {
|
||||||
|
<caret>return if (3 > 2) {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
"???"
|
||||||
|
}
|
||||||
|
} else if (n == 2) {
|
||||||
|
println("***")
|
||||||
|
return "two"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "too many"
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
if (n == 1) {
|
||||||
|
<caret>if (3 > 2) {
|
||||||
|
println("***")
|
||||||
|
return "one"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "???"
|
||||||
|
}
|
||||||
|
} else if (n == 2) {
|
||||||
|
println("***")
|
||||||
|
return "two"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "too many"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1)
|
||||||
|
"one"
|
||||||
|
else
|
||||||
|
"two"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1)
|
||||||
|
return "one"
|
||||||
|
else
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>return if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
"one"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
"two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fun test(n: Int): String {
|
||||||
|
<caret>if (n == 1) {
|
||||||
|
println("***")
|
||||||
|
return "one"
|
||||||
|
} else {
|
||||||
|
println("***")
|
||||||
|
return "two"
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.codeInsight.codeTransformations.AbstractCodeTran
|
|||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@InnerTestClasses({CodeTransformationsTestGenerated.IfStatementWithAssignmentsToExpression.class, CodeTransformationsTestGenerated.AssignmentWithIfExpressionToStatement.class, CodeTransformationsTestGenerated.RemoveUnnecessaryParentheses.class})
|
@InnerTestClasses({CodeTransformationsTestGenerated.IfStatementWithAssignmentsToExpression.class, CodeTransformationsTestGenerated.AssignmentWithIfExpressionToStatement.class})
|
||||||
public class CodeTransformationsTestGenerated extends AbstractCodeTransformationTest {
|
public class CodeTransformationsTestGenerated extends AbstractCodeTransformationTest {
|
||||||
@TestMetadata("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression")
|
@TestMetadata("idea/testData/codeInsight/codeTransformations/ifStatementWithAssignmentsToExpression")
|
||||||
public static class IfStatementWithAssignmentsToExpression extends AbstractCodeTransformationTest {
|
public static class IfStatementWithAssignmentsToExpression extends AbstractCodeTransformationTest {
|
||||||
|
|||||||
Reference in New Issue
Block a user