Check unique symbols in Goto*Tests
This commit is contained in:
@@ -15,5 +15,4 @@ private val test = 4
|
|||||||
// REF: (for Int in privateTopLevelDeclarations.kt in foo.bar).test
|
// REF: (for Int in privateTopLevelDeclarations.kt in foo.bar).test
|
||||||
// REF: (for Int in privateTopLevelDeclarations.kt in foo.bar).test()
|
// REF: (for Int in privateTopLevelDeclarations.kt in foo.bar).test()
|
||||||
// REF: (privateTopLevelDeclarations.kt in foo.bar).test
|
// REF: (privateTopLevelDeclarations.kt in foo.bar).test
|
||||||
// REF: (privateTopLevelDeclarations.kt in foo.bar).test
|
|
||||||
// REF: (privateTopLevelDeclarations.kt in foo.bar).test()
|
// REF: (privateTopLevelDeclarations.kt in foo.bar).test()
|
||||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
|||||||
import org.jetbrains.kotlin.test.util.renderAsGotoImplementation
|
import org.jetbrains.kotlin.test.util.renderAsGotoImplementation
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
object GotoCheck {
|
object GotoCheck {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -38,11 +39,11 @@ object GotoCheck {
|
|||||||
val searchText = searchTextList.first()
|
val searchText = searchTextList.first()
|
||||||
|
|
||||||
val foundSymbols = model.getNames(includeNonProjectSymbols).filter { it?.startsWith(searchText) ?: false }.flatMap {
|
val foundSymbols = model.getNames(includeNonProjectSymbols).filter { it?.startsWith(searchText) ?: false }.flatMap {
|
||||||
model.getElementsByName(it, includeNonProjectSymbols, "$it*").toSet()
|
model.getElementsByName(it, includeNonProjectSymbols, "$it*").toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val inexactMatching = InTextDirectivesUtils.isDirectiveDefined(documentText, "// ALLOW_MORE_RESULTS")
|
val inexactMatching = InTextDirectivesUtils.isDirectiveDefined(documentText, "// ALLOW_MORE_RESULTS")
|
||||||
val renderedSymbols = foundSymbols.map { (it as PsiElement).renderAsGotoImplementation() }
|
val renderedSymbols = foundSymbols.map { (it as PsiElement).renderAsGotoImplementation() }.toSet()
|
||||||
|
|
||||||
if (checkNavigation && (expectedReferences.size != 1 || inexactMatching)) {
|
if (checkNavigation && (expectedReferences.size != 1 || inexactMatching)) {
|
||||||
error("Cannot check navigation targets when multiple references are expected")
|
error("Cannot check navigation targets when multiple references are expected")
|
||||||
@@ -55,7 +56,10 @@ object GotoCheck {
|
|||||||
}
|
}
|
||||||
if (!checkNavigation) return
|
if (!checkNavigation) return
|
||||||
|
|
||||||
assertNavigationElementMatches(foundSymbols.single() as PsiElement, documentText)
|
assertTrue(foundSymbols.isNotEmpty())
|
||||||
|
foundSymbols.forEach {
|
||||||
|
assertNavigationElementMatches(it as PsiElement, documentText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
|||||||
import org.jetbrains.kotlin.test.util.renderAsGotoImplementation
|
import org.jetbrains.kotlin.test.util.renderAsGotoImplementation
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
object GotoCheck {
|
object GotoCheck {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -38,11 +39,11 @@ object GotoCheck {
|
|||||||
val searchText = searchTextList.first()
|
val searchText = searchTextList.first()
|
||||||
|
|
||||||
val foundSymbols = model.getNames(includeNonProjectSymbols).filter { it?.startsWith(searchText) ?: false }.flatMap {
|
val foundSymbols = model.getNames(includeNonProjectSymbols).filter { it?.startsWith(searchText) ?: false }.flatMap {
|
||||||
model.getElementsByName(it, includeNonProjectSymbols, "$it*").toSet()
|
model.getElementsByName(it, includeNonProjectSymbols, "$it*").toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val inexactMatching = InTextDirectivesUtils.isDirectiveDefined(documentText, "// ALLOW_MORE_RESULTS")
|
val inexactMatching = InTextDirectivesUtils.isDirectiveDefined(documentText, "// ALLOW_MORE_RESULTS")
|
||||||
val renderedSymbols = foundSymbols.map { (it as PsiElement).renderAsGotoImplementation() }
|
val renderedSymbols = foundSymbols.map { (it as PsiElement).renderAsGotoImplementation() }.toSet()
|
||||||
|
|
||||||
if (checkNavigation && (expectedReferences.size != 1 || inexactMatching)) {
|
if (checkNavigation && (expectedReferences.size != 1 || inexactMatching)) {
|
||||||
error("Cannot check navigation targets when multiple references are expected")
|
error("Cannot check navigation targets when multiple references are expected")
|
||||||
@@ -55,7 +56,10 @@ object GotoCheck {
|
|||||||
}
|
}
|
||||||
if (!checkNavigation) return
|
if (!checkNavigation) return
|
||||||
|
|
||||||
assertNavigationElementMatches(foundSymbols.single() as PsiElement, documentText)
|
assertTrue(foundSymbols.isNotEmpty())
|
||||||
|
foundSymbols.forEach {
|
||||||
|
assertNavigationElementMatches(it as PsiElement, documentText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
Reference in New Issue
Block a user