migrate NormalCompletionTest to use jdk 9, add test for IDEA-88939

This commit is contained in:
peter
2017-12-01 18:36:16 +01:00
parent d33401b6ac
commit 20cee42f50
8 changed files with 130 additions and 152 deletions

View File

@@ -1,3 +1,3 @@
public class Main {
StringBuf<caret>
StringBuf<caret>x
}

View File

@@ -0,0 +1,5 @@
class Foo {
{
BigDec<caret>x
}
}

View File

@@ -1,79 +0,0 @@
/*
* Copyright 2000-2017 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.java.codeInsight.completion
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.annotations.NotNull
class Normal17CompletionTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal/"
}
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
return JAVA_1_7
}
void testOnlyExceptionsInMultiCatch1() { doTest() }
void testOnlyExceptionsInMultiCatch2() { doTest() }
void testOnlyResourcesInResourceList1() { doTest() }
void testOnlyResourcesInResourceList2() { doTest() }
void testOnlyResourcesInResourceList3() { doTest() }
void testOnlyResourcesInResourceList4() { doTest() }
void testOnlyResourcesInResourceList5() { doTest() }
void testMethodReferenceNoStatic() { doTest() }
void testMethodReferenceCallContext() { doTest() }
void testResourceParentInResourceList() {
configureByTestName()
assert 'MyOuterResource' == myFixture.lookupElementStrings[0]
assert 'MyClass' in myFixture.lookupElementStrings
myFixture.type('C\n')
checkResultByFile(getTestName(false) + "_after.java")
}
private void doTest() {
configureByTestName()
myFixture.type('\n')
checkResultByFile(getTestName(false) + "_after.java")
}
void testAfterTryWithResources() {
configureByTestName()
def strings = myFixture.lookupElementStrings
assert strings.containsAll(['final', 'finally', 'int', 'Util'])
}
void testNewObjectHashMapWithSmartEnter() {
configureByTestName()
myFixture.performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)
checkResultByFile(getTestName(false) + "_after.java")
}
}

View File

@@ -0,0 +1,35 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.completion
import com.intellij.codeInsight.lookup.LookupElementPresentation
/**
* @author peter
*/
class Normal6CompletionTest extends NormalCompletionTestCase {
void testMakeMultipleArgumentsFinalWhenInInner() {
configure()
def item = lookup.items.find { 'a, b' == it.lookupString }
assert item
lookup.currentItem = item
type '\n'
checkResult()
}
void testOverwriteGenericsAfterNew() { doTest('\n') }
void testExplicitTypeArgumentsWhenParameterTypesDoNotDependOnTypeParameters() { doTest() }
void testClassNameWithGenericsTab2() { doTest('\t') }
void testClassNameGenerics() { doTest('\n') }
void testDoubleExpectedTypeFactoryMethod() throws Throwable {
configure()
assertStringItems('Key', 'create', 'create')
assert LookupElementPresentation.renderElement(myItems[1]).itemText == 'Key.<Boolean>create'
assert LookupElementPresentation.renderElement(myItems[2]).itemText == 'Key.create'
}
}

View File

@@ -17,13 +17,12 @@ package com.intellij.java.codeInsight.completion
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase
import com.intellij.codeInsight.lookup.LookupElementPresentation
import com.intellij.testFramework.LightProjectDescriptor
/**
* @author anna
*/
class Normal8CompletionTest extends LightFixtureCompletionTestCase {
class Normal8CompletionTest extends NormalCompletionTestCase {
final LightProjectDescriptor projectDescriptor = JAVA_8
final String basePath = JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/lambda/completion/normal/"

View File

@@ -15,19 +15,11 @@
*/
package com.intellij.java.codeInsight.completion
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase
import com.intellij.testFramework.LightProjectDescriptor
/**
* @author peter
*/
class NormalCompletionDfaTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal/"
}
class NormalCompletionDfaTest extends NormalCompletionTestCase {
@Override
protected LightProjectDescriptor getProjectDescriptor() {
return JAVA_8
@@ -80,11 +72,6 @@ public class FooImpl extends Foo {
doTest()
}
private void doTest() throws Exception {
configureByTestName()
checkResultByFile(getTestName(false) + "_after.java")
}
void testCastInstanceofedQualifierInLambda() { doTest() }
void testCastInstanceofedQualifierInLambda2() { doTest() }

View File

@@ -15,13 +15,11 @@
*/
package com.intellij.java.codeInsight.completion
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.codeInsight.JavaProjectCodeInsightSettings
import com.intellij.codeInsight.completion.CompletionType
import com.intellij.codeInsight.completion.CompletionUtil
import com.intellij.codeInsight.completion.JavaPsiClassReferenceElement
import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementPresentation
@@ -37,13 +35,15 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
import com.intellij.psi.codeStyle.JavaCodeStyleSettings
import com.intellij.psi.impl.PsiDocumentManagerBase
import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.util.ui.UIUtil
import com.siyeh.ig.style.UnqualifiedFieldAccessInspection
class NormalCompletionTest extends LightFixtureCompletionTestCase {
class NormalCompletionTest extends NormalCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal/"
protected LightProjectDescriptor getProjectDescriptor() {
return JAVA_9
}
void testSimple() throws Exception {
@@ -408,7 +408,8 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
void testExcludeStringBuffer() throws Throwable {
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, StringBuffer.name)
doAntiTest()
configure()
assert !('StringBuffer' in myFixture.lookupElementStrings)
}
void testExcludeInstanceInnerClasses() throws Throwable {
@@ -669,7 +670,7 @@ public class ListUtils {
assertStringItems("*")
}
void testMembersInStaticImports() { doTest() }
void testMembersInStaticImports() { doTest('\n') }
void testPackageNamedVariableBeforeAssignment() throws Throwable {
doTest()
@@ -696,9 +697,7 @@ public class ListUtils {
assert myFixture.lookupElementStrings == ['MyParam']
}
void testMethodReturnType() throws Throwable {
doTest()
}
void testMethodReturnType() { doTest('\n') }
void testMethodReturnTypeNoSpace() throws Throwable {
configureByFile(getTestName(false) + ".java")
@@ -831,10 +830,6 @@ public class ListUtils {
doTest()
}
void testClassNameGenerics() throws Throwable {
doTest('\n')
}
void testClassNameAnonymous() throws Throwable {
doTest('\n')
}
@@ -886,10 +881,6 @@ public class ListUtils {
assertTrue 'boolean' in myFixture.lookupElementStrings
}
private def configure() {
configureByTestName()
}
void testFinalInForLoop() throws Throwable {
configure()
assertStringItems 'final'
@@ -957,17 +948,6 @@ public class ListUtils {
doAntiTest()
}
private void doTest() throws Exception {
configure()
checkResult()
}
private void doTest(String finishChar) throws Exception {
configure()
type finishChar
checkResult()
}
void testSecondAnonymousClassParameter() { doTest() }
void testSpaceAfterReturn() throws Throwable {
@@ -976,10 +956,6 @@ public class ListUtils {
checkResult()
}
private def checkResult() {
checkResultByFile(getTestName(false) + "_after.java")
}
void testIntersectionTypeMembers() throws Throwable {
configure()
assertStringItems "fooa", "foob"
@@ -1049,13 +1025,6 @@ public class ListUtils {
assertStringItems('XFOO', 'XFOX')
}
void testDoubleExpectedTypeFactoryMethod() throws Throwable {
configure()
assertStringItems('Key', 'create', 'create')
assert renderElement(myItems[1]).itemText == 'Key.<Boolean>create'
assert renderElement(myItems[2]).itemText == 'Key.create'
}
void testSuggestExpectedTypeMembersNonImported() throws Throwable {
myFixture.addClass("package foo; public class Super { public static final Super FOO = null; }")
myFixture.addClass("package foo; public class Usage { public static void foo(Super s) {} }")
@@ -1076,8 +1045,6 @@ public class ListUtils {
void testClassNameWithGenericsTab() throws Throwable { doTest('\t') }
void testClassNameWithGenericsTab2() throws Throwable { doTest('\t') }
void testLiveTemplatePrefixTab() throws Throwable { doTest('\t') }
void testOnlyAnnotationsAfterAt() throws Throwable { doTest() }
@@ -1383,7 +1350,7 @@ class XInternalError {}
void testPackageInMemberType() { doTest() }
void testConstantInAnno() { doTest() }
void testConstantInAnno() { doTest('\n') }
void testCharsetName() {
myFixture.addClass("package java.nio.charset; public class Charset { public static Charset forName(String s) {} }")
@@ -1473,17 +1440,6 @@ class XInternalError {}
checkResult()
}
void testMakeMultipleArgumentsFinalWhenInInner() {
configure()
def item = lookup.items.find { 'a, b' == it.lookupString }
assert item
lookup.currentItem = item
type '\n'
checkResult()
}
void testExplicitTypeArgumentsWhenParameterTypesDoNotDependOnTypeParameters() { doTest() }
void testNoFinalInAnonymousConstructor() { doTest() }
void testListArrayListCast() { doTest('\n') }
@@ -1494,8 +1450,6 @@ class XInternalError {}
void testInnerChainedReturnType() { doTest() }
void testOverwriteGenericsAfterNew() { doTest('\n') }
private CommonCodeStyleSettings getCodeStyleSettings() {
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE)
}
@@ -1846,4 +1800,47 @@ class Bar {{
void testNoNonAnnotationMethods() { doAntiTest() }
void testPreferBigDecimalToJavaUtilInner() {
configure()
myFixture.assertPreferredCompletionItems 0, 'BigDecimal', 'BigDecimalLayoutForm'
}
void testOnlyExceptionsInMultiCatch1() { doTest('\n') }
void testOnlyExceptionsInMultiCatch2() { doTest('\n') }
void testOnlyResourcesInResourceList1() { doTest('\n') }
void testOnlyResourcesInResourceList2() { doTest('\n') }
void testOnlyResourcesInResourceList3() { doTest('\n') }
void testOnlyResourcesInResourceList4() { doTest('\n') }
void testOnlyResourcesInResourceList5() { doTest('\n') }
void testMethodReferenceNoStatic() { doTest('\n') }
void testMethodReferenceCallContext() { doTest('\n') }
void testResourceParentInResourceList() {
configureByTestName()
assert 'MyOuterResource' == myFixture.lookupElementStrings[0]
assert 'MyClass' in myFixture.lookupElementStrings
myFixture.type('C\n')
checkResultByFile(getTestName(false) + "_after.java")
}
void testAfterTryWithResources() {
configureByTestName()
def strings = myFixture.lookupElementStrings
assert strings.containsAll(['final', 'finally', 'int', 'Util'])
}
void testNewObjectHashMapWithSmartEnter() {
configureByTestName()
myFixture.performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)
checkResultByFile(getTestName(false) + "_after.java")
}
}

View File

@@ -0,0 +1,34 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.completion
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase
/**
* @author peter
*/
abstract class NormalCompletionTestCase extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/normal/"
}
def configure() {
configureByTestName()
}
def checkResult() {
checkResultByFile(getTestName(false) + "_after.java")
}
void doTest(String finishChar) {
configure()
type finishChar
checkResult()
}
void doTest() throws Exception {
configure()
checkResult()
}
}