Generate out of block modification tests

This commit is contained in:
Nikolay Krasko
2013-10-23 21:20:15 +04:00
parent 2975198b4c
commit fa0c3e52c5
4 changed files with 120 additions and 61 deletions
@@ -24,7 +24,7 @@ public final class JetModifiableBlockHelper {
}
/**
* Tested in OutOfBlockModificationTest
* Tested in OutOfBlockModificationTestGenerated
*/
public static boolean shouldChangeModificationCount(PsiElement place) {
JetDeclaration declaration = PsiTreeUtil.getParentOfType(place, JetDeclaration.class, true);
@@ -45,6 +45,7 @@ import org.jetbrains.jet.lang.resolve.lazy.AbstractLazyResolveNamespaceComparing
import org.jetbrains.jet.lang.resolve.lazy.AbstractLazyResolveTest;
import org.jetbrains.jet.modules.xml.AbstractModuleXmlParserTest;
import org.jetbrains.jet.parsing.AbstractJetParsingTest;
import org.jetbrains.jet.plugin.codeInsight.AbstractOutOfBlockModificationTest;
import org.jetbrains.jet.plugin.codeInsight.moveUpDown.AbstractCodeMoverTest;
import org.jetbrains.jet.plugin.codeInsight.surroundWith.AbstractSurroundWithTest;
import org.jetbrains.jet.plugin.codeInsight.unwrap.AbstractUnwrapRemoveTest;
@@ -511,6 +512,13 @@ public class GenerateTests {
AbstractDiagnosticMessageTest.class,
testModel("idea/testData/diagnosticMessage")
);
generateTest(
"idea/tests/",
"OutOfBlockModificationTestGenerated",
AbstractOutOfBlockModificationTest.class,
testModel("idea/testData/codeInsight/outOfBlock")
);
}
private static SimpleTestClassModel testModel(@NotNull String rootPath) {
@@ -21,72 +21,15 @@ import com.intellij.psi.impl.JavaCodeBlockModificationListener;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.jet.plugin.PluginTestCaseBase;
public class OutOfBlockModificationTest extends LightCodeInsightFixtureTestCase {
public void testFunInFun() {
doTest();
}
public void testFunNoBody() {
doTest();
}
public void testInAntonymsObjectDeclaration() {
doTest();
}
public void testInClass() {
doTest();
}
public void testInClassPropertyAccessor() {
doTest();
}
public void testInFunctionLiteral() {
doTest();
}
public void testInFunInFunWithBody() {
doTest();
}
public void testInFunInMultiDeclaration() {
doTest();
}
public void testInFunWithInference() {
doTest();
}
public void testInGlobalPropertyWithGetter() {
doTest();
}
public void testInMethod() {
doTest();
}
public void testInPropertyAccessorWithInference() {
doTest();
}
public void testInPropertyWithFunctionLiteral() {
doTest();
}
public void testInPropertyWithInference() {
doTest();
}
public abstract class AbstractOutOfBlockModificationTest extends LightCodeInsightFixtureTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.setTestDataPath(PluginTestCaseBase.getTestDataPathBase() + "/codeInsight/outOfBlock");
}
protected void doTest() {
myFixture.configureByFile(getTestName(false) + ".kt");
protected void doTest(String path) {
myFixture.configureByFile(path);
String text = myFixture.getDocument(myFixture.getFile()).getText();
boolean expectedOutOfBlock = false;
@@ -0,0 +1,108 @@
/*
* Copyright 2010-2013 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.codeInsight;
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.codeInsight.AbstractOutOfBlockModificationTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/codeInsight/outOfBlock")
public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModificationTest {
public void testAllFilesPresentInOutOfBlock() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/codeInsight/outOfBlock"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("FunInFun.kt")
public void testFunInFun() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/FunInFun.kt");
}
@TestMetadata("FunNoBody.kt")
public void testFunNoBody() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/FunNoBody.kt");
}
@TestMetadata("InAntonymsObjectDeclaration.kt")
public void testInAntonymsObjectDeclaration() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InAntonymsObjectDeclaration.kt");
}
@TestMetadata("InClass.kt")
public void testInClass() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InClass.kt");
}
@TestMetadata("InClassPropertyAccessor.kt")
public void testInClassPropertyAccessor() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt");
}
@TestMetadata("InFunInFunWithBody.kt")
public void testInFunInFunWithBody() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InFunInFunWithBody.kt");
}
@TestMetadata("InFunInMultiDeclaration.kt")
public void testInFunInMultiDeclaration() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InFunInMultiDeclaration.kt");
}
@TestMetadata("InFunWithInference.kt")
public void testInFunWithInference() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InFunWithInference.kt");
}
@TestMetadata("InFunctionLiteral.kt")
public void testInFunctionLiteral() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InFunctionLiteral.kt");
}
@TestMetadata("InGlobalPropertyWithGetter.kt")
public void testInGlobalPropertyWithGetter() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InGlobalPropertyWithGetter.kt");
}
@TestMetadata("InMethod.kt")
public void testInMethod() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InMethod.kt");
}
@TestMetadata("InPropertyAccessorWithInference.kt")
public void testInPropertyAccessorWithInference() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InPropertyAccessorWithInference.kt");
}
@TestMetadata("InPropertyWithFunctionLiteral.kt")
public void testInPropertyWithFunctionLiteral() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt");
}
@TestMetadata("InPropertyWithInference.kt")
public void testInPropertyWithInference() throws Exception {
doTest("idea/testData/codeInsight/outOfBlock/InPropertyWithInference.kt");
}
}