diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 4ad7701216f..4681d3fab02 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -104,7 +104,7 @@ import org.jetbrains.jet.plugin.stubs.AbstractStubBuilderTest import org.jetbrains.jet.plugin.codeInsight.AbstractJetInspectionTest import org.jetbrains.jet.plugin.debugger.AbstractKotlinSteppingTest import org.jetbrains.jet.completion.AbstractMultiFileJvmBasicCompletionTest -import org.jetbrains.jet.plugin.refactoring.introduce.introduceVariable.AbstractJetIntroduceVariableTest +import org.jetbrains.jet.plugin.refactoring.introduce.introduceVariable.AbstractJetExtractionTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -563,8 +563,8 @@ fun main(args: Array) { model("completion/basic/multifile", pattern = """^([^\.]+)\.kt$""") } - testClass(javaClass()) { - model("refactoring/introduceVariable", extension = "kt") + testClass(javaClass()) { + model("refactoring/introduceVariable", extension = "kt", testMethod = "doIntroduceVariableTest") } } diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/AbstractJetIntroduceVariableTest.java b/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/AbstractJetExtractionTest.java similarity index 81% rename from idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/AbstractJetIntroduceVariableTest.java rename to idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/AbstractJetExtractionTest.java index 678d13e80c3..68be187088d 100644 --- a/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/AbstractJetIntroduceVariableTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/AbstractJetExtractionTest.java @@ -18,16 +18,22 @@ package org.jetbrains.jet.plugin.refactoring.introduce.introduceVariable; import com.intellij.ide.DataManager; import com.intellij.psi.PsiElement; +import com.intellij.refactoring.RefactoringActionHandler; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lexer.JetTokens; +import org.jetbrains.jet.plugin.refactoring.extractFunction.ExtractKotlinFunctionHandler; import java.io.File; -public abstract class AbstractJetIntroduceVariableTest extends LightCodeInsightFixtureTestCase { - protected void doTest(@NotNull String path) { +public abstract class AbstractJetExtractionTest extends LightCodeInsightFixtureTestCase { + protected void doIntroduceVariableTest(@NotNull String path) { + doTest(path, new KotlinIntroduceVariableHandler()); + } + + protected void doTest(@NotNull String path, @NotNull RefactoringActionHandler handler) { File mainFile = new File(path); myFixture.setTestDataPath(JetTestCaseBuilder.getHomeDirectory() + "/" + mainFile.getParent()); @@ -47,7 +53,7 @@ public abstract class AbstractJetIntroduceVariableTest extends LightCodeInsightF } assert expectedResultText != null; - new KotlinIntroduceVariableHandler().invoke( + handler.invoke( getProject(), myFixture.getEditor(), file, DataManager.getInstance().getDataContext(myFixture.getEditor().getComponent()) ); diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/JetExtractionTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/JetExtractionTestGenerated.java new file mode 100644 index 00000000000..6810254042a --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/JetExtractionTestGenerated.java @@ -0,0 +1,188 @@ +/* + * 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.refactoring.introduce.introduceVariable; + +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.refactoring.introduce.introduceVariable.AbstractJetExtractionTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@InnerTestClasses({JetExtractionTestGenerated.IntroduceVariable.class}) +public class JetExtractionTestGenerated extends AbstractJetExtractionTest { + @TestMetadata("idea/testData/refactoring/introduceVariable") + public static class IntroduceVariable extends AbstractJetExtractionTest { + public void testAllFilesPresentInIntroduceVariable() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/refactoring/introduceVariable"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ArrayAccessExpr.kt") + public void testArrayAccessExpr() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/ArrayAccessExpr.kt"); + } + + @TestMetadata("ClassBody.kt") + public void testClassBody() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/ClassBody.kt"); + } + + @TestMetadata("DoWhileAddBlock.kt") + public void testDoWhileAddBlock() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/DoWhileAddBlock.kt"); + } + + @TestMetadata("DoWhileAddBlockInner.kt") + public void testDoWhileAddBlockInner() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/DoWhileAddBlockInner.kt"); + } + + @TestMetadata("FewOccurrences.kt") + public void testFewOccurrences() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/FewOccurrences.kt"); + } + + @TestMetadata("FunctionAddBlock.kt") + public void testFunctionAddBlock() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/FunctionAddBlock.kt"); + } + + @TestMetadata("FunctionAddBlockInner.kt") + public void testFunctionAddBlockInner() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt"); + } + + @TestMetadata("FunctionLiteral.kt") + public void testFunctionLiteral() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/FunctionLiteral.kt"); + } + + @TestMetadata("FunctionLiteralFromExpected.kt") + public void testFunctionLiteralFromExpected() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/FunctionLiteralFromExpected.kt"); + } + + @TestMetadata("IfCondition.kt") + public void testIfCondition() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/IfCondition.kt"); + } + + @TestMetadata("IfElseAddBlock.kt") + public void testIfElseAddBlock() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/IfElseAddBlock.kt"); + } + + @TestMetadata("IfElseAddBlockInner.kt") + public void testIfElseAddBlockInner() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/IfElseAddBlockInner.kt"); + } + + @TestMetadata("IfThenAddBlock.kt") + public void testIfThenAddBlock() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/IfThenAddBlock.kt"); + } + + @TestMetadata("IfThenAddBlockInner.kt") + public void testIfThenAddBlockInner() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/IfThenAddBlockInner.kt"); + } + + @TestMetadata("It.kt") + public void testIt() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/It.kt"); + } + + @TestMetadata("LoopRange.kt") + public void testLoopRange() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/LoopRange.kt"); + } + + @TestMetadata("ManyInnerOccurences.kt") + public void testManyInnerOccurences() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/ManyInnerOccurences.kt"); + } + + @TestMetadata("ManyOccurrences.kt") + public void testManyOccurrences() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/ManyOccurrences.kt"); + } + + @TestMetadata("ReplaceOccurence.kt") + public void testReplaceOccurence() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/ReplaceOccurence.kt"); + } + + @TestMetadata("Simple.kt") + public void testSimple() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/Simple.kt"); + } + + @TestMetadata("SimpleCreateValue.kt") + public void testSimpleCreateValue() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/SimpleCreateValue.kt"); + } + + @TestMetadata("StringInjection.kt") + public void testStringInjection() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/StringInjection.kt"); + } + + @TestMetadata("WhenAddBlock.kt") + public void testWhenAddBlock() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/WhenAddBlock.kt"); + } + + @TestMetadata("WhenAddBlockInner.kt") + public void testWhenAddBlockInner() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/WhenAddBlockInner.kt"); + } + + @TestMetadata("WhenParts.kt") + public void testWhenParts() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/WhenParts.kt"); + } + + @TestMetadata("WhileAddBlock.kt") + public void testWhileAddBlock() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/WhileAddBlock.kt"); + } + + @TestMetadata("WhileAddBlockInner.kt") + public void testWhileAddBlockInner() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/WhileAddBlockInner.kt"); + } + + @TestMetadata("WhileCondition.kt") + public void testWhileCondition() throws Exception { + doIntroduceVariableTest("idea/testData/refactoring/introduceVariable/WhileCondition.kt"); + } + + } + + public static Test suite() { + TestSuite suite = new TestSuite("JetExtractionTestGenerated"); + suite.addTestSuite(IntroduceVariable.class); + return suite; + } +} diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/JetIntroduceVariableTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/JetIntroduceVariableTestGenerated.java deleted file mode 100644 index d41ea7f5fc9..00000000000 --- a/idea/tests/org/jetbrains/jet/plugin/refactoring/introduce/introduceVariable/JetIntroduceVariableTestGenerated.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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.refactoring.introduce.introduceVariable; - -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.refactoring.introduce.introduceVariable.AbstractJetIntroduceVariableTest; - -/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("idea/testData/refactoring/introduceVariable") -public class JetIntroduceVariableTestGenerated extends AbstractJetIntroduceVariableTest { - public void testAllFilesPresentInIntroduceVariable() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/refactoring/introduceVariable"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("ArrayAccessExpr.kt") - public void testArrayAccessExpr() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/ArrayAccessExpr.kt"); - } - - @TestMetadata("ClassBody.kt") - public void testClassBody() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/ClassBody.kt"); - } - - @TestMetadata("DoWhileAddBlock.kt") - public void testDoWhileAddBlock() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/DoWhileAddBlock.kt"); - } - - @TestMetadata("DoWhileAddBlockInner.kt") - public void testDoWhileAddBlockInner() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/DoWhileAddBlockInner.kt"); - } - - @TestMetadata("FewOccurrences.kt") - public void testFewOccurrences() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/FewOccurrences.kt"); - } - - @TestMetadata("FunctionAddBlock.kt") - public void testFunctionAddBlock() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/FunctionAddBlock.kt"); - } - - @TestMetadata("FunctionAddBlockInner.kt") - public void testFunctionAddBlockInner() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/FunctionAddBlockInner.kt"); - } - - @TestMetadata("FunctionLiteral.kt") - public void testFunctionLiteral() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/FunctionLiteral.kt"); - } - - @TestMetadata("FunctionLiteralFromExpected.kt") - public void testFunctionLiteralFromExpected() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/FunctionLiteralFromExpected.kt"); - } - - @TestMetadata("IfCondition.kt") - public void testIfCondition() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/IfCondition.kt"); - } - - @TestMetadata("IfElseAddBlock.kt") - public void testIfElseAddBlock() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/IfElseAddBlock.kt"); - } - - @TestMetadata("IfElseAddBlockInner.kt") - public void testIfElseAddBlockInner() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/IfElseAddBlockInner.kt"); - } - - @TestMetadata("IfThenAddBlock.kt") - public void testIfThenAddBlock() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/IfThenAddBlock.kt"); - } - - @TestMetadata("IfThenAddBlockInner.kt") - public void testIfThenAddBlockInner() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/IfThenAddBlockInner.kt"); - } - - @TestMetadata("It.kt") - public void testIt() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/It.kt"); - } - - @TestMetadata("LoopRange.kt") - public void testLoopRange() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/LoopRange.kt"); - } - - @TestMetadata("ManyInnerOccurences.kt") - public void testManyInnerOccurences() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/ManyInnerOccurences.kt"); - } - - @TestMetadata("ManyOccurrences.kt") - public void testManyOccurrences() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/ManyOccurrences.kt"); - } - - @TestMetadata("ReplaceOccurence.kt") - public void testReplaceOccurence() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/ReplaceOccurence.kt"); - } - - @TestMetadata("Simple.kt") - public void testSimple() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/Simple.kt"); - } - - @TestMetadata("SimpleCreateValue.kt") - public void testSimpleCreateValue() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/SimpleCreateValue.kt"); - } - - @TestMetadata("StringInjection.kt") - public void testStringInjection() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/StringInjection.kt"); - } - - @TestMetadata("WhenAddBlock.kt") - public void testWhenAddBlock() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/WhenAddBlock.kt"); - } - - @TestMetadata("WhenAddBlockInner.kt") - public void testWhenAddBlockInner() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/WhenAddBlockInner.kt"); - } - - @TestMetadata("WhenParts.kt") - public void testWhenParts() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/WhenParts.kt"); - } - - @TestMetadata("WhileAddBlock.kt") - public void testWhileAddBlock() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/WhileAddBlock.kt"); - } - - @TestMetadata("WhileAddBlockInner.kt") - public void testWhileAddBlockInner() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/WhileAddBlockInner.kt"); - } - - @TestMetadata("WhileCondition.kt") - public void testWhileCondition() throws Exception { - doTest("idea/testData/refactoring/introduceVariable/WhileCondition.kt"); - } - -}