Extracted test for "Join Lines" from CodeTransformationsTest.

This commit is contained in:
Evgeny Gerashchenko
2014-07-07 16:10:49 +04:00
parent ea20073d4b
commit b1003fc034
33 changed files with 157 additions and 91 deletions
@@ -116,6 +116,7 @@ import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterTest
import org.jetbrains.jet.jps.build.AbstractIncrementalJpsTest
import org.jetbrains.jet.asJava.AbstractKotlinLightClassTest
import org.jetbrains.jet.lang.resolve.java.AbstractJavaTypeSubstitutorTest
import org.jetbrains.jet.plugin.intentions.declarations.AbstractJoinLinesTest
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
@@ -385,6 +386,10 @@ fun main(args: Array<String>) {
model("codeInsight/surroundWith/functionLiteral", testMethod = "doTestWithFunctionLiteralSurrounder")
}
testClass(javaClass<AbstractJoinLinesTest>()) {
model("joinLines", testMethod = "doTest")
}
testClass(javaClass<AbstractCodeTransformationTest>()) {
model("intentions/branched/doubleBangToIfThen", testMethod = "doTestDoubleBangToIfThen")
model("intentions/branched/ifThenToDoubleBang", testMethod = "doTestIfThenToDoubleBang")
@@ -410,7 +415,6 @@ fun main(args: Array<String>) {
model("intentions/branched/when/introduceSubject", testMethod = "doTestIntroduceWhenSubject")
model("intentions/branched/when/eliminateSubject", testMethod = "doTestEliminateWhenSubject")
model("intentions/declarations/split", testMethod = "doTestSplitProperty")
model("intentions/declarations/join", testMethod = "doTestJoinProperty")
model("intentions/declarations/convertMemberToExtension", testMethod = "doTestConvertMemberToExtension")
model("intentions/reconstructedType", testMethod = "doTestReconstructType")
model("intentions/removeUnnecessaryParentheses", testMethod = "doTestRemoveUnnecessaryParentheses")
@@ -143,10 +143,6 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
doTestIntention(path, new SplitPropertyDeclarationIntention());
}
public void doTestJoinProperty(@NotNull String path) throws Exception {
doTestAction(path, new JoinLinesHandler(null));
}
public void doTestRemoveUnnecessaryParentheses(@NotNull String path) throws Exception {
doTestIntention(path, new RemoveUnnecessaryParenthesesIntention());
}
@@ -348,12 +344,6 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
}
}
private void doTestAction(@NotNull String path, @NotNull EditorActionHandler actionHandler) throws Exception {
configureByFile(path);
actionHandler.execute(getEditor(), getCurrentEditorDataContext());
checkResultByFile(path + ".after");
}
@NotNull
@Override
protected String getTestDataPath() {
@@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@InnerTestClasses({CodeTransformationTestGenerated.DoubleBangToIfThen.class, CodeTransformationTestGenerated.IfThenToDoubleBang.class, CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.ConvertToStringTemplateIntention.class, CodeTransformationTestGenerated.ConvertToConcatenatedStringIntention.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class, CodeTransformationTestGenerated.ReplaceWithOperatorAssign.class, CodeTransformationTestGenerated.ReplaceWithTraditionalAssignment.class, CodeTransformationTestGenerated.SimplifyBooleanWithConstants.class, CodeTransformationTestGenerated.InsertExplicitTypeArguments.class, CodeTransformationTestGenerated.RemoveExplicitTypeArguments.class, CodeTransformationTestGenerated.ConvertAssertToIf.class, CodeTransformationTestGenerated.ConvertIfToAssert.class, CodeTransformationTestGenerated.MakeTypeExplicitInLambda.class, CodeTransformationTestGenerated.MakeTypeImplicitInLambda.class, CodeTransformationTestGenerated.InvertIfCondition.class, CodeTransformationTestGenerated.OperatorToFunction.class, CodeTransformationTestGenerated.ConvertToForEachLoop.class, CodeTransformationTestGenerated.ConvertToForEachFunctionCall.class})
@InnerTestClasses({CodeTransformationTestGenerated.DoubleBangToIfThen.class, CodeTransformationTestGenerated.IfThenToDoubleBang.class, CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.ConvertToStringTemplateIntention.class, CodeTransformationTestGenerated.ConvertToConcatenatedStringIntention.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class, CodeTransformationTestGenerated.ReplaceWithOperatorAssign.class, CodeTransformationTestGenerated.ReplaceWithTraditionalAssignment.class, CodeTransformationTestGenerated.SimplifyBooleanWithConstants.class, CodeTransformationTestGenerated.InsertExplicitTypeArguments.class, CodeTransformationTestGenerated.RemoveExplicitTypeArguments.class, CodeTransformationTestGenerated.ConvertAssertToIf.class, CodeTransformationTestGenerated.ConvertIfToAssert.class, CodeTransformationTestGenerated.MakeTypeExplicitInLambda.class, CodeTransformationTestGenerated.MakeTypeImplicitInLambda.class, CodeTransformationTestGenerated.InvertIfCondition.class, CodeTransformationTestGenerated.OperatorToFunction.class, CodeTransformationTestGenerated.ConvertToForEachLoop.class, CodeTransformationTestGenerated.ConvertToForEachFunctionCall.class})
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
@TestMetadata("idea/testData/intentions/branched/doubleBangToIfThen")
public static class DoubleBangToIfThen extends AbstractCodeTransformationTest {
@@ -1601,84 +1601,6 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
}
@TestMetadata("idea/testData/intentions/declarations/join")
public static class Join extends AbstractCodeTransformationTest {
public void testAllFilesPresentInJoin() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/declarations/join"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("longInit.kt")
public void testLongInit() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/longInit.kt");
}
@TestMetadata("longInit2.kt")
public void testLongInit2() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/longInit2.kt");
}
@TestMetadata("simpleInit.kt")
public void testSimpleInit() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInit.kt");
}
@TestMetadata("simpleInit2.kt")
public void testSimpleInit2() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInit2.kt");
}
@TestMetadata("simpleInitWithBackticks.kt")
public void testSimpleInitWithBackticks() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithBackticks.kt");
}
@TestMetadata("simpleInitWithBackticks2.kt")
public void testSimpleInitWithBackticks2() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithBackticks2.kt");
}
@TestMetadata("simpleInitWithBackticks3.kt")
public void testSimpleInitWithBackticks3() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithBackticks3.kt");
}
@TestMetadata("simpleInitWithComments.kt")
public void testSimpleInitWithComments() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithComments.kt");
}
@TestMetadata("simpleInitWithComments2.kt")
public void testSimpleInitWithComments2() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithComments2.kt");
}
@TestMetadata("simpleInitWithSemicolons.kt")
public void testSimpleInitWithSemicolons() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithSemicolons.kt");
}
@TestMetadata("simpleInitWithSemicolons2.kt")
public void testSimpleInitWithSemicolons2() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithSemicolons2.kt");
}
@TestMetadata("simpleInitWithSemicolons3.kt")
public void testSimpleInitWithSemicolons3() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithSemicolons3.kt");
}
@TestMetadata("simpleInitWithType.kt")
public void testSimpleInitWithType() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithType.kt");
}
@TestMetadata("simpleInitWithType2.kt")
public void testSimpleInitWithType2() throws Exception {
doTestJoinProperty("idea/testData/intentions/declarations/join/simpleInitWithType2.kt");
}
}
@TestMetadata("idea/testData/intentions/declarations/convertMemberToExtension")
public static class ConvertMemberToExtension extends AbstractCodeTransformationTest {
@TestMetadata("abstract.kt")
@@ -4819,7 +4741,6 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
suite.addTestSuite(IntroduceSubject.class);
suite.addTestSuite(EliminateSubject.class);
suite.addTestSuite(Split.class);
suite.addTestSuite(Join.class);
suite.addTestSuite(ConvertMemberToExtension.class);
suite.addTestSuite(ReconstructedType.class);
suite.addTestSuite(RemoveUnnecessaryParentheses.class);
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.plugin.intentions.declarations;
import com.intellij.codeInsight.editorActions.JoinLinesHandler;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.apache.commons.lang.SystemUtils;
import org.jetbrains.annotations.NotNull;
public abstract class AbstractJoinLinesTest extends LightCodeInsightTestCase {
public void doTest(@NotNull String path) throws Exception {
configureByFile(path);
new JoinLinesHandler(null).execute(getEditor(), getCurrentEditorDataContext());
checkResultByFile(path + ".after");
}
@NotNull
@Override
protected String getTestDataPath() {
return "";
}
protected static Sdk getFullJavaJDK() {
return JavaSdk.getInstance().createJdk("JDK", SystemUtils.getJavaHome().getAbsolutePath());
}
}
@@ -0,0 +1,109 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.plugin.intentions.declarations;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.plugin.intentions.declarations.AbstractJoinLinesTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/joinLines")
public class JoinLinesTestGenerated extends AbstractJoinLinesTest {
public void testAllFilesPresentInJoinLines() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/joinLines"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("longInit.kt")
public void testLongInit() throws Exception {
doTest("idea/testData/joinLines/longInit.kt");
}
@TestMetadata("longInit2.kt")
public void testLongInit2() throws Exception {
doTest("idea/testData/joinLines/longInit2.kt");
}
@TestMetadata("simpleInit.kt")
public void testSimpleInit() throws Exception {
doTest("idea/testData/joinLines/simpleInit.kt");
}
@TestMetadata("simpleInit2.kt")
public void testSimpleInit2() throws Exception {
doTest("idea/testData/joinLines/simpleInit2.kt");
}
@TestMetadata("simpleInitWithBackticks.kt")
public void testSimpleInitWithBackticks() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithBackticks.kt");
}
@TestMetadata("simpleInitWithBackticks2.kt")
public void testSimpleInitWithBackticks2() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithBackticks2.kt");
}
@TestMetadata("simpleInitWithBackticks3.kt")
public void testSimpleInitWithBackticks3() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithBackticks3.kt");
}
@TestMetadata("simpleInitWithComments.kt")
public void testSimpleInitWithComments() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithComments.kt");
}
@TestMetadata("simpleInitWithComments2.kt")
public void testSimpleInitWithComments2() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithComments2.kt");
}
@TestMetadata("simpleInitWithSemicolons.kt")
public void testSimpleInitWithSemicolons() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithSemicolons.kt");
}
@TestMetadata("simpleInitWithSemicolons2.kt")
public void testSimpleInitWithSemicolons2() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithSemicolons2.kt");
}
@TestMetadata("simpleInitWithSemicolons3.kt")
public void testSimpleInitWithSemicolons3() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithSemicolons3.kt");
}
@TestMetadata("simpleInitWithType.kt")
public void testSimpleInitWithType() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithType.kt");
}
@TestMetadata("simpleInitWithType2.kt")
public void testSimpleInitWithType2() throws Exception {
doTest("idea/testData/joinLines/simpleInitWithType2.kt");
}
}