Add tests for unfolding to 'when'
This commit is contained in:
+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
|
||||
}
|
||||
+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
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test(n: Int): String {
|
||||
var res: String
|
||||
|
||||
<caret>res = when(n) {
|
||||
1 -> "one"
|
||||
else -> "two"
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test(n: Int): String {
|
||||
var res: String
|
||||
|
||||
<caret>when(n) {
|
||||
1 -> res = "one"
|
||||
else -> 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
|
||||
}
|
||||
+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
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun test(n: Int): String {
|
||||
if (3 > 2) {
|
||||
<caret>return when (n) {
|
||||
1 -> "one"
|
||||
else -> "two"
|
||||
}
|
||||
} else {
|
||||
println("***")
|
||||
return "???"
|
||||
}
|
||||
}
|
||||
+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 "???"
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun test(n: Int): String {
|
||||
<caret>return when (n) {
|
||||
1 -> "one"
|
||||
else -> "two"
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun test(n: Int): String {
|
||||
<caret>when (n) {
|
||||
1 -> return "one"
|
||||
else -> return "two"
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun test(n: Int): String {
|
||||
<caret>return when(n) {
|
||||
1 -> {
|
||||
println("***")
|
||||
"one"
|
||||
}
|
||||
else -> {
|
||||
println("***")
|
||||
"two"
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun test(n: Int): String {
|
||||
<caret>when(n) {
|
||||
1 -> {
|
||||
println("***")
|
||||
return "one"
|
||||
}
|
||||
else -> {
|
||||
println("***")
|
||||
return "two"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -59,7 +59,7 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
||||
}
|
||||
|
||||
public void doTestUnfoldReturnToWhen(@NotNull String path) throws Exception {
|
||||
doTest(path, new UnfoldAssignmentToIfIntention());
|
||||
doTest(path, new UnfoldReturnToWhenIntention());
|
||||
}
|
||||
|
||||
public void doTestRemoveUnnecessaryParentheses(@NotNull String path) throws Exception {
|
||||
|
||||
+49
-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 */
|
||||
@SuppressWarnings("all")
|
||||
@InnerTestClasses({CodeTransformationsTestGenerated.IfToAssignment.class, CodeTransformationsTestGenerated.IfToReturn.class, CodeTransformationsTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationsTestGenerated.WhenToAssignment.class, CodeTransformationsTestGenerated.WhenToReturn.class, CodeTransformationsTestGenerated.AssignmentToIf.class, CodeTransformationsTestGenerated.ReturnToIf.class})
|
||||
@InnerTestClasses({CodeTransformationsTestGenerated.IfToAssignment.class, CodeTransformationsTestGenerated.IfToReturn.class, CodeTransformationsTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationsTestGenerated.WhenToAssignment.class, CodeTransformationsTestGenerated.WhenToReturn.class, CodeTransformationsTestGenerated.AssignmentToIf.class, CodeTransformationsTestGenerated.AssignmentToWhen.class, CodeTransformationsTestGenerated.ReturnToIf.class, CodeTransformationsTestGenerated.ReturnToWhen.class})
|
||||
public class CodeTransformationsTestGenerated extends AbstractCodeTransformationTest {
|
||||
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/folding/ifToAssignment")
|
||||
public static class IfToAssignment extends AbstractCodeTransformationTest {
|
||||
@@ -230,6 +230,29 @@ public class CodeTransformationsTestGenerated extends AbstractCodeTransformation
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToWhen")
|
||||
public static class AssignmentToWhen extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInAssignmentToWhen() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToWhen"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("innerWhenTransformed.kt")
|
||||
public void testInnerWhenTransformed() throws Exception {
|
||||
doTestUnfoldAssignmentToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToWhen/innerWhenTransformed.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleWhen.kt")
|
||||
public void testSimpleWhen() throws Exception {
|
||||
doTestUnfoldAssignmentToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToWhen/simpleWhen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleWhenWithBlocks.kt")
|
||||
public void testSimpleWhenWithBlocks() throws Exception {
|
||||
doTestUnfoldAssignmentToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/assignmentToWhen/simpleWhenWithBlocks.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToIf")
|
||||
public static class ReturnToIf extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInReturnToIf() throws Exception {
|
||||
@@ -253,6 +276,29 @@ public class CodeTransformationsTestGenerated extends AbstractCodeTransformation
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToWhen")
|
||||
public static class ReturnToWhen extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInReturnToWhen() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToWhen"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("innerWhenTransformed.kt")
|
||||
public void testInnerWhenTransformed() throws Exception {
|
||||
doTestUnfoldReturnToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToWhen/innerWhenTransformed.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleWhen.kt")
|
||||
public void testSimpleWhen() throws Exception {
|
||||
doTestUnfoldReturnToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToWhen/simpleWhen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleWhenWithBlocks.kt")
|
||||
public void testSimpleWhenWithBlocks() throws Exception {
|
||||
doTestUnfoldReturnToWhen("idea/testData/codeInsight/codeTransformations/branched/unfolding/returnToWhen/simpleWhenWithBlocks.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("CodeTransformationsTestGenerated");
|
||||
suite.addTestSuite(IfToAssignment.class);
|
||||
@@ -261,7 +307,9 @@ public class CodeTransformationsTestGenerated extends AbstractCodeTransformation
|
||||
suite.addTestSuite(WhenToAssignment.class);
|
||||
suite.addTestSuite(WhenToReturn.class);
|
||||
suite.addTestSuite(AssignmentToIf.class);
|
||||
suite.addTestSuite(AssignmentToWhen.class);
|
||||
suite.addTestSuite(ReturnToIf.class);
|
||||
suite.addTestSuite(ReturnToWhen.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user