Add multi-file completion handler tests for FIR code completion
This is a temporary (and dirty) solution to start using those tests as fast as possible. We certainly need to refactor them so they can be generated from the testData
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo() {
|
fun foo() {
|
||||||
KtCla<caret>
|
KtCla<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
import pack.KtClass
|
import pack.KtClass
|
||||||
|
|
||||||
|
// FIR_COMPARISON
|
||||||
fun foo() {
|
fun foo() {
|
||||||
KtClass<caret>
|
KtClass<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val s = "fo<caret>something"
|
val s = "fo<caret>something"
|
||||||
}
|
}
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val s = "foo.txtsomething"
|
val s = "foo.txtsomething"
|
||||||
}
|
}
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val s = "fo<caret>something"
|
val s = "fo<caret>something"
|
||||||
}
|
}
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val s = "foo.txt"
|
val s = "foo.txt"
|
||||||
}
|
}
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
object XXX {
|
object XXX {
|
||||||
fun authorize(handler: String.() -> Unit) { }
|
fun authorize(handler: String.() -> Unit) { }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
import ppp.globalFun
|
import ppp.globalFun
|
||||||
|
|
||||||
|
// FIR_COMPARISON
|
||||||
object XXX {
|
object XXX {
|
||||||
fun authorize(handler: String.() -> Unit) { }
|
fun authorize(handler: String.() -> Unit) { }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package some
|
package some
|
||||||
|
|
||||||
import test.SomeTestObject
|
import test.SomeTestObject
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package some
|
package some
|
||||||
|
|
||||||
import test.SomeTestObject
|
import test.SomeTestObject
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package classimporttest
|
package classimporttest
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package classimporttest
|
package classimporttest
|
||||||
|
|
||||||
import forimport.TTTest
|
import forimport.TTTest
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package a
|
package a
|
||||||
|
|
||||||
class Goo {
|
class Goo {
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import a.b.foo
|
import a.b.foo
|
||||||
|
|||||||
+6
-3
@@ -17,7 +17,7 @@ import org.junit.runner.RunWith
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
||||||
class CompletionMultiFileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
|
open class CompletionMultiFileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
|
||||||
fun testExtensionFunctionImport() {
|
fun testExtensionFunctionImport() {
|
||||||
doTest()
|
doTest()
|
||||||
}
|
}
|
||||||
@@ -118,8 +118,11 @@ class CompletionMultiFileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
|
|||||||
doTest()
|
doTest()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doTest(completionChar: Char = '\n', vararg extraFileNames: String, tailText: String? = null) {
|
private fun doTest(completionChar: Char = '\n', vararg extraFileNames: String, tailText: String? = null) {
|
||||||
val fileName = getTestName(false)
|
doTest(getTestName(false), completionChar, extraFileNames, tailText)
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun doTest(fileName: String, completionChar: Char, extraFileNames: Array<out String>, tailText: String?) {
|
||||||
|
|
||||||
val defaultFiles = listOf("$fileName-1.kt", "$fileName-2.kt")
|
val defaultFiles = listOf("$fileName-1.kt", "$fileName-2.kt")
|
||||||
val filteredFiles = defaultFiles.filter { File(testDataPath, it).exists() }
|
val filteredFiles = defaultFiles.filter { File(testDataPath, it).exists() }
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.completion.test.handlers
|
||||||
|
|
||||||
|
import com.intellij.testFramework.LightProjectDescriptor
|
||||||
|
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
|
||||||
|
import org.jetbrains.kotlin.test.uitls.IgnoreTests
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
||||||
|
class HighLevelCompletionMultifileHandlerTest : CompletionMultiFileHandlerTest() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a temporary solution! This test should be rewritten to be generated!
|
||||||
|
*/
|
||||||
|
override fun doTest(fileName: String, completionChar: Char, extraFileNames: Array<out String>, tailText: String?) {
|
||||||
|
val testFile = Paths.get(testDataPath, "$fileName-1.kt")
|
||||||
|
|
||||||
|
IgnoreTests.runTestIfEnabledByFileDirective(testFile, IgnoreTests.DIRECTIVES.FIR_COMPARISON) {
|
||||||
|
super.doTest(fileName, completionChar, extraFileNames, tailText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val captureExceptions: Boolean = false
|
||||||
|
|
||||||
|
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user