Minor: test methods rename
This commit is contained in:
@@ -39,7 +39,7 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun testInjectionPresent(text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) {
|
protected fun assertInjectionPresent(text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) {
|
||||||
myFixture.configureByText("${getTestName(true)}.kt", text.trimMargin())
|
myFixture.configureByText("${getTestName(true)}.kt", text.trimMargin())
|
||||||
|
|
||||||
TestCase.assertFalse("Injection action is available. There's probably no injection at caret place",
|
TestCase.assertFalse("Injection action is available. There's probably no injection at caret place",
|
||||||
@@ -56,7 +56,7 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun testNoInjection(text: String) {
|
protected fun assertNoInjection(text: String) {
|
||||||
myFixture.configureByText("${getTestName(true)}.kt", text.trimMargin())
|
myFixture.configureByText("${getTestName(true)}.kt", text.trimMargin())
|
||||||
|
|
||||||
TestCase.assertTrue("Injection action is not available. There's probably some injection but nothing was expected.",
|
TestCase.assertTrue("Injection action is not available. There's probably some injection but nothing was expected.",
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class KotlinInjectionTest : AbstractInjectionTest() {
|
|||||||
TestCase.assertNull(myFixture.getReferenceAtCaretPosition())
|
TestCase.assertNull(myFixture.getReferenceAtCaretPosition())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testInjectionOnJavaPredefinedMethodWithAnnotation() = testInjectionPresent(
|
fun testInjectionOnJavaPredefinedMethodWithAnnotation() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test1 = java.util.regex.Pattern.compile("<caret>pattern")
|
|val test1 = java.util.regex.Pattern.compile("<caret>pattern")
|
||||||
""",
|
""",
|
||||||
@@ -63,7 +63,7 @@ class KotlinInjectionTest : AbstractInjectionTest() {
|
|||||||
try {
|
try {
|
||||||
Configuration.getInstance().replaceInjections(listOf(customInjection), listOf(), true)
|
Configuration.getInstance().replaceInjections(listOf(customInjection), listOf(), true)
|
||||||
|
|
||||||
testInjectionPresent(
|
assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val stringBuilder = StringBuilder().replace(0, 0, "<caret><html></html>")
|
|val stringBuilder = StringBuilder().replace(0, 0, "<caret><html></html>")
|
||||||
""",
|
""",
|
||||||
@@ -76,34 +76,34 @@ class KotlinInjectionTest : AbstractInjectionTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testInjectionWithCommentOnProperty() = testInjectionPresent(
|
fun testInjectionWithCommentOnProperty() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|//language=file-reference
|
|//language=file-reference
|
||||||
|val test = "<caret>simple"
|
|val test = "<caret>simple"
|
||||||
""")
|
""")
|
||||||
|
|
||||||
fun testInjectionWithUsageOnReceiverWithRuntime() = testInjectionPresent(
|
fun testInjectionWithUsageOnReceiverWithRuntime() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test = "<caret>some"
|
|val test = "<caret>some"
|
||||||
|fun foo() = test.toRegex()
|
|fun foo() = test.toRegex()
|
||||||
""",
|
""",
|
||||||
languageId = RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false)
|
languageId = RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false)
|
||||||
|
|
||||||
fun testInjectionWithUsageInParameterWithRuntime() = testInjectionPresent(
|
fun testInjectionWithUsageInParameterWithRuntime() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test = "<caret>some"
|
|val test = "<caret>some"
|
||||||
|fun foo() = Regex(test)
|
|fun foo() = Regex(test)
|
||||||
""",
|
""",
|
||||||
languageId = RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false)
|
languageId = RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false)
|
||||||
|
|
||||||
fun testNoInjectionThoughSeveralAssignmentsWithRuntime() = testNoInjection(
|
fun testNoInjectionThoughSeveralAssignmentsWithRuntime() = assertNoInjection(
|
||||||
"""
|
"""
|
||||||
|val first = "<caret>some"
|
|val first = "<caret>some"
|
||||||
|val test = first
|
|val test = first
|
||||||
|fun foo() = Regex(test)
|
|fun foo() = Regex(test)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
fun testInjectionWithMultipleCommentsOnFun() = testInjectionPresent(
|
fun testInjectionWithMultipleCommentsOnFun() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|// Some comment
|
|// Some comment
|
||||||
|// Other comment
|
|// Other comment
|
||||||
@@ -111,7 +111,7 @@ class KotlinInjectionTest : AbstractInjectionTest() {
|
|||||||
|fun test() = "<caret>simple"
|
|fun test() = "<caret>simple"
|
||||||
""")
|
""")
|
||||||
|
|
||||||
fun testInjectionWithAnnotationOnPropertyWithAnnotation() = testInjectionPresent(
|
fun testInjectionWithAnnotationOnPropertyWithAnnotation() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|@org.intellij.lang.annotations.Language("file-reference")
|
|@org.intellij.lang.annotations.Language("file-reference")
|
||||||
|val test = "<caret>simple"
|
|val test = "<caret>simple"
|
||||||
|
|||||||
@@ -20,50 +20,50 @@ import org.intellij.lang.regexp.RegExpLanguage
|
|||||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||||
|
|
||||||
class KotlinStdlibInjectionTest : AbstractInjectionTest() {
|
class KotlinStdlibInjectionTest : AbstractInjectionTest() {
|
||||||
fun testOnRegex0() = testInjection(
|
fun testOnRegex0() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test1 = kotlin.text.Regex("<caret>some")
|
|val test1 = kotlin.text.Regex("<caret>some")
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testOnRegex1() = testInjection(
|
fun testOnRegex1() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test1 = kotlin.text.Regex("<caret>some", RegexOption.COMMENTS)
|
|val test1 = kotlin.text.Regex("<caret>some", RegexOption.COMMENTS)
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testOnRegex2() = testInjection(
|
fun testOnRegex2() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test1 = kotlin.text.Regex("<caret>some", setOf(RegexOption.COMMENTS))
|
|val test1 = kotlin.text.Regex("<caret>some", setOf(RegexOption.COMMENTS))
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testToRegex0() = testInjection(
|
fun testToRegex0() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test = "hi<caret>".toRegex()
|
|val test = "hi<caret>".toRegex()
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testToRegex1() = testInjection(
|
fun testToRegex1() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test = "hi<caret>".toRegex(RegexOption.CANON_EQ)
|
|val test = "hi<caret>".toRegex(RegexOption.CANON_EQ)
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testToRegex2() = testInjection(
|
fun testToRegex2() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
|val test = "hi<caret>".toRegex(setOf(RegexOption.LITERAL))
|
|val test = "hi<caret>".toRegex(setOf(RegexOption.LITERAL))
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun testInjection(text: String, languageId: String) {
|
private fun assertInjectionPresent(text: String, languageId: String) {
|
||||||
testInjectionPresent(text, languageId, false)
|
assertInjectionPresent(text, languageId, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
|
|||||||
Reference in New Issue
Block a user