FIR IDE: ignore attributes in completion tests
This commit is contained in:
committed by
teamcityserver
parent
72e26771d8
commit
167917cf07
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun String?.forNullableString(){}
|
||||
fun Any?.forNullableAny(){}
|
||||
fun String.forString(){}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface T1 {
|
||||
fun inT1(){}
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun String.extFunForString(){}
|
||||
fun Any.extFunForAny(){}
|
||||
fun String?.extFunForStringNullable(){}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun String.extFunForString(){}
|
||||
fun Any.extFunForAny(){}
|
||||
fun String?.extFunForStringNullable(){}
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun <T> List<T>.forListT(){}
|
||||
fun <T> Collection<T>.forCollectionT(){}
|
||||
fun <T> T.forT() {}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface T {
|
||||
fun fromTrait(){}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface T {
|
||||
fun fromTrait(){}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface T {
|
||||
fun f(){}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun globalFun(){}
|
||||
|
||||
interface T {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface R<T>
|
||||
|
||||
val <T> R<T>.prop: Int get() = TODO()
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:-NewInference
|
||||
|
||||
fun String.forString(){}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:-NewInference
|
||||
|
||||
interface A {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
interface Base {
|
||||
fun inBase()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
@DslMarker
|
||||
annotation class SimpleDsl
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
@DslMarker
|
||||
annotation class SimpleDsl
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun foo(param: String) {
|
||||
val s = "$param.<caret>bla-bla-bla"
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_COMPARISON
|
||||
fun String.extFunForString(){}
|
||||
fun Any.extFunForAny(){}
|
||||
fun String?.extFunForStringNullable(){}
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@ fun testCompletion(
|
||||
complete: (CompletionType, Int) -> Array<LookupElement>?,
|
||||
defaultCompletionType: CompletionType = CompletionType.BASIC,
|
||||
defaultInvocationCount: Int = 0,
|
||||
ignoreProperties: Collection<String> = emptyList(),
|
||||
additionalValidDirectives: Collection<String> = emptyList()
|
||||
) {
|
||||
testWithAutoCompleteSetting(fileText) {
|
||||
@@ -40,8 +41,8 @@ fun testCompletion(
|
||||
"Should be some assertions about completion",
|
||||
expected.size != 0 || unexpected.size != 0 || itemsNumber != null || nothingElse
|
||||
)
|
||||
ExpectedCompletionUtils.assertContainsRenderedItems(expected, items, ExpectedCompletionUtils.isWithOrder(fileText), nothingElse)
|
||||
ExpectedCompletionUtils.assertNotContainsRenderedItems(unexpected, items)
|
||||
ExpectedCompletionUtils.assertContainsRenderedItems(expected, items, ExpectedCompletionUtils.isWithOrder(fileText), nothingElse, ignoreProperties)
|
||||
ExpectedCompletionUtils.assertNotContainsRenderedItems(unexpected, items, ignoreProperties)
|
||||
|
||||
if (itemsNumber != null) {
|
||||
val expectedItems = ExpectedCompletionUtils.listToString(ExpectedCompletionUtils.getItemsInformation(items))
|
||||
|
||||
+7
-5
@@ -64,9 +64,10 @@ object ExpectedCompletionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
fun matches(expectedProposal: CompletionProposal): Boolean {
|
||||
fun matches(expectedProposal: CompletionProposal, ignoreProperties: Collection<String>): Boolean {
|
||||
return expectedProposal.map.entries.none { expected ->
|
||||
val actualValues = when (expected.key) {
|
||||
in ignoreProperties -> return@none false
|
||||
"lookupString" -> {
|
||||
// FIR IDE adds `.` after package names in completion
|
||||
listOf(map[expected.key]?.removeSuffix("."), map[expected.key])
|
||||
@@ -223,7 +224,8 @@ object ExpectedCompletionUtils {
|
||||
expected: Array<CompletionProposal>,
|
||||
items: Array<LookupElement>,
|
||||
checkOrder: Boolean,
|
||||
nothingElse: Boolean
|
||||
nothingElse: Boolean,
|
||||
ignoreProperties: Collection<String>,
|
||||
) {
|
||||
val itemsInformation = getItemsInformation(items)
|
||||
val allItemsString = listToString(itemsInformation)
|
||||
@@ -238,7 +240,7 @@ object ExpectedCompletionUtils {
|
||||
for (index in itemsInformation.indices) {
|
||||
val proposal = itemsInformation[index]
|
||||
|
||||
if (proposal.matches(expectedProposal)) {
|
||||
if (proposal.matches(expectedProposal, ignoreProperties)) {
|
||||
isFound = true
|
||||
|
||||
Assert.assertTrue(
|
||||
@@ -280,7 +282,7 @@ object ExpectedCompletionUtils {
|
||||
return InTextDirectivesUtils.getPrefixedInt(fileText, NUMBER_LINE_PREFIX)
|
||||
}
|
||||
|
||||
fun assertNotContainsRenderedItems(unexpected: Array<CompletionProposal>, items: Array<LookupElement>) {
|
||||
fun assertNotContainsRenderedItems(unexpected: Array<CompletionProposal>, items: Array<LookupElement>, ignoreProperties: Collection<String>) {
|
||||
val itemsInformation = getItemsInformation(items)
|
||||
val allItemsString = listToString(itemsInformation)
|
||||
|
||||
@@ -288,7 +290,7 @@ object ExpectedCompletionUtils {
|
||||
for (proposal in itemsInformation) {
|
||||
Assert.assertFalse(
|
||||
"Unexpected '$unexpectedProposal' presented in\n$allItemsString",
|
||||
proposal.matches(unexpectedProposal)
|
||||
proposal.matches(unexpectedProposal, ignoreProperties)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -46,6 +46,7 @@ abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsightFixtu
|
||||
{ completionType, count -> complete(completionType, count) },
|
||||
defaultCompletionType(),
|
||||
defaultInvocationCount(),
|
||||
ignoreProperties = ignoreProperties,
|
||||
additionalValidDirectives = CompilerTestDirectives.ALL_COMPILER_TEST_DIRECTIVES + IgnoreTests.DIRECTIVES.FIR_IDENTICAL
|
||||
)
|
||||
}
|
||||
@@ -55,6 +56,8 @@ abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsightFixtu
|
||||
}
|
||||
}
|
||||
|
||||
open val ignoreProperties: Collection<String> = emptyList()
|
||||
|
||||
protected open fun executeTest(test: () -> Unit) {
|
||||
test()
|
||||
}
|
||||
|
||||
+4
@@ -6,11 +6,15 @@
|
||||
package org.jetbrains.kotlin.idea.fir.completion
|
||||
|
||||
import org.jetbrains.kotlin.idea.completion.test.AbstractJvmBasicCompletionTest
|
||||
import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils
|
||||
import org.jetbrains.kotlin.test.utils.IgnoreTests
|
||||
|
||||
abstract class AbstractHighLevelJvmBasicCompletionTest : AbstractJvmBasicCompletionTest() {
|
||||
override val captureExceptions: Boolean = false
|
||||
|
||||
override val ignoreProperties: Collection<String> =
|
||||
listOf(ExpectedCompletionUtils.CompletionProposal.PRESENTATION_TEXT_ATTRIBUTES)
|
||||
|
||||
override fun executeTest(test: () -> Unit) {
|
||||
IgnoreTests.runTestIfEnabledByFileDirective(testDataFile().toPath(), IgnoreTests.DIRECTIVES.FIR_COMPARISON, ".after") {
|
||||
super.executeTest(test)
|
||||
|
||||
Reference in New Issue
Block a user