extract dfa-related completion tests to separate test cases

This commit is contained in:
peter
2013-09-26 21:34:47 +02:00
parent 420b4d4542
commit 2db1cd4250
7 changed files with 142 additions and 80 deletions
@@ -1,6 +1,5 @@
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupEvent;
import com.intellij.codeInsight.lookup.LookupManager;
@@ -35,6 +34,17 @@ public abstract class LightFixtureCompletionTestCase extends LightCodeInsightFix
complete();
}
protected void configureByTestName() {
configureByFile("/" + getTestName(false) + ".java");
}
protected void doAntiTest() {
configureByTestName();
checkResultByFile(getTestName(false) + ".java");
assertEmpty(myItems);
assertNull(getLookup());
}
protected void complete() {
myItems = myFixture.completeBasic();
}
@@ -0,0 +1,48 @@
/*
* Copyright 2000-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 com.intellij.codeInsight.completion
import com.intellij.JavaTestUtil;
/**
* @author peter
*/
class NormalCompletionDfaTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal/";
}
void testCastInstanceofedQualifier() { doTest(); }
void testCastInstanceofedQualifierInForeach() { doTest(); }
void testCastComplexInstanceofedQualifier() { doTest(); }
void _testCastIncompleteInstanceofedQualifier() { doTest(); }
void testCastTooComplexInstanceofedQualifier() { doAntiTest() }
void testDontCastInstanceofedQualifier() { doTest(); }
void testQualifierCastingWithUnknownAssignments() { doTest(); }
void testQualifierCastingBeforeLt() { doTest(); }
void testCastQualifierForPrivateFieldReference() { doTest(); }
void testOrAssignmentDfa() { doTest(); }
void testFieldWithCastingCaret() { doTest(); }
private void doTest() throws Exception {
configureByTestName()
checkResultByFile(getTestName(false) + "_after.java")
}
}
@@ -627,8 +627,6 @@ public class ListUtils {
doTest();
}
public void testFieldWithCastingCaret() throws Throwable { doTest(); }
public void testInnerEnumConstant() throws Throwable { doTest('\n'); }
public void testMethodReturnType() throws Throwable {
@@ -798,7 +796,7 @@ public class ListUtils {
}
private def configure() {
configureByFile(getTestName(false) + ".java")
configureByTestName()
}
public void testFinalInForLoop() throws Throwable {
@@ -868,13 +866,6 @@ public class ListUtils {
checkResult();
}
private void doAntiTest() throws Exception {
configure()
checkResultByFile(getTestName(false) + ".java");
assertEmpty(myItems);
assertNull(getLookup());
}
public void testSecondAnonymousClassParameter() throws Throwable { doTest('\n'); }
public void testSpaceAfterReturn() throws Throwable {
@@ -892,20 +883,8 @@ public class ListUtils {
assertStringItems "fooa", "foob"
}
public void testCastInstanceofedQualifier() throws Throwable { doTest(); }
public void testCastInstanceofedQualifierInForeach() throws Throwable { doTest(); }
public void testCastComplexInstanceofedQualifier() throws Throwable { doTest(); }
public void _testCastIncompleteInstanceofedQualifier() throws Throwable { doTest(); }
public void testCastTooComplexInstanceofedQualifier() throws Throwable { doAntiTest(); }
public void testDontCastInstanceofedQualifier() throws Throwable { doTest(); }
public void testQualifierCastingWithUnknownAssignments() throws Throwable { doTest(); }
public void testQualifierCastingBeforeLt() throws Throwable { doTest(); }
public void testCastQualifierForPrivateFieldReference() throws Throwable { doTest(); }
public void testNoReturnInTernary() throws Throwable { doTest(); }
public void testOrAssignmentDfa() throws Throwable { doTest(); }
public void testWildcardsInLookup() throws Exception {
configure()
assertNotNull(getLookup());
@@ -141,12 +141,6 @@ public class SecondSmartTypeCompletionTest extends LightFixtureCompletionTestCas
public void testNoUnqualifiedCastsInQualifiedContext() throws Throwable { doAntiTest(); }
private void doAntiTest() throws Exception {
configure();
assertEmpty(myItems);
checkResultByFile(getTestName(false) + ".java");
}
public void testCastInstanceofedQualifier() throws Throwable { doTest(); }
public void testNoLeftRecursion() throws Throwable {
@@ -0,0 +1,78 @@
/*
* Copyright 2000-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 com.intellij.codeInsight.completion
import com.intellij.JavaTestUtil
/**
* @author peter
*/
class SmartTypeCompletionDfaTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/smartType/";
}
@Override
protected void complete() {
myItems = myFixture.complete(CompletionType.SMART);
}
private void doTest() {
configureByTestName();
checkResultByTestName();
}
private void checkResultByTestName() {
checkResultByFile("/" + getTestName(false) + "-out.java");
}
void testCastGenericQualifier() { doTest() }
void testDontAutoCastWhenAlreadyCasted() {
configureByTestName();
myFixture.assertPreferredCompletionItems(0, "s", "toString");
myFixture.type('\n')
checkResultByTestName();
}
void testAutoCastWhenAlreadyCasted() {
configureByTestName();
myFixture.type('\n')
checkResultByTestName();
}
void testSuggestCastedValueAfterCast() { doTest(); }
void testSuggestInstanceofedValue() { doTest() }
void testSuggestInstanceofedValueInTernary() { doTest() }
void testSuggestInstanceofedValueInComplexIf() { doTest(); }
void testSuggestInstanceofedValueInElseNegated() { doTest(); }
void testSuggestInstanceofedValueAfterReturn() { doTest(); }
void testNoInstanceofedValueWhenBasicSuits() { doTest(); }
void testNoInstanceofedValueInElse() { doAntiTest(); }
void testNoInstanceofedValueInThenNegated() { doAntiTest(); }
void testNoInstanceofedValueInElseWithComplexIf() { doAntiTest(); }
void testInstanceofedInsideAnonymous() { doTest(); }
}
@@ -626,8 +626,6 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
public void testDefaultAnnoParam() throws Throwable { doTest(); }
public void testCastGenericQualifier() throws Throwable { doTest(); }
public void testNewWithTypeParameterErasure() throws Throwable { doTest(); }
public void testEverythingDoubles() throws Throwable {
@@ -694,34 +692,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
doTest();
}
public void testSuggestInstanceofedValue() throws Throwable {
doTest();
}
public void testSuggestInstanceofedValueInTernary() throws Throwable {
doTest();
}
public void testSuggestInstanceofedValueInComplexIf() throws Throwable { doTest('\n'); }
public void testSuggestInstanceofedValueInElseNegated() throws Throwable { doTest('\n'); }
public void testSuggestInstanceofedValueAfterReturn() throws Throwable { doTest('\n'); }
public void testNoInstanceofedValueWhenBasicSuits() throws Throwable { doTest(); }
public void testSuggestCastedValueAfterCast() throws Throwable { doTest('\n'); }
public void testNoInstanceofedValueInElse() throws Throwable { doAntiTest(); }
public void testNoInstanceofedValueInThenNegated() throws Throwable { doAntiTest(); }
public void testNoInstanceofedValueInElseWithComplexIf() throws Throwable { doAntiTest(); }
public void testReplaceWholeReferenceChain() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
public void testInstanceofedInsideAnonymous() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
public void testDoubleTrueInOverloadedMethodCall() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
public void testMethodColon() throws Exception { doFirstItemTest(':'); }
@@ -737,15 +709,6 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
public void testCastToArray() throws Throwable { doTest(); }
public void testDontAutoCastWhenAlreadyCasted() throws Throwable {
configureByTestName();
myFixture.assertPreferredCompletionItems(0, "s", "toString");
select();
checkResultByTestName();
}
public void testAutoCastWhenAlreadyCasted() throws Throwable { doTest('\n'); }
public void testCommaDoublePenetration() throws Throwable {
doFirstItemTest(',');
}
@@ -803,12 +766,6 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
checkResultByTestName();
}
private void doAntiTest() throws Exception {
configureByTestName();
assertEmpty(myItems);
checkResultByFile("/" + getTestName(false) + ".java");
}
public void testAfterNewWithGenerics() throws Exception {
doActionTest();
}
@@ -946,10 +903,6 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
public void testConstructorArgsSmartEnter() throws Exception { doTest(Lookup.COMPLETE_STATEMENT_SELECT_CHAR); }
private void configureByTestName() {
configureByFile("/" + getTestName(false) + ".java");
}
public void testIDEADEV13148() throws Exception {
configureByFile("/IDEADEV13148.java");
assertStringItems("false", "true"); //todo don't suggest boolean literals in synchronized
@@ -15,8 +15,8 @@
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.completion.NormalCompletionTest;
import com.intellij.codeInsight.completion.SmartTypeCompletionTest;
import com.intellij.codeInsight.completion.NormalCompletionDfaTest;
import com.intellij.codeInsight.completion.SmartTypeCompletionDfaTest;
import com.intellij.codeInsight.slice.SliceBackwardTest;
import com.intellij.codeInsight.slice.SliceTreeTest;
import junit.framework.Test;
@@ -29,8 +29,8 @@ public class DataFlowInspectionTestSuite {
suite.addTestSuite(DataFlowInspectionAncientTest.class);
suite.addTestSuite(SliceTreeTest.class);
suite.addTestSuite(SliceBackwardTest.class);
suite.addTestSuite(SmartTypeCompletionTest.class);
suite.addTestSuite(NormalCompletionTest.class);
suite.addTestSuite(SmartTypeCompletionDfaTest.class);
suite.addTestSuite(NormalCompletionDfaTest.class);
return suite;
}
}