FIR IDE: add completion weighers tests for return/if/while

This commit is contained in:
Ilya Kirillov
2020-12-13 17:57:30 +01:00
parent b16ebe2dc4
commit 7be8d69870
7 changed files with 159 additions and 0 deletions
@@ -0,0 +1,18 @@
// FIR_COMPARISON
object x {
val b: Boolean = true
val c: String = "true"
val d: Int = 1
val e: Long = 1L
val f: Boolean = true
fun foo(): Boolean = true
}
fun test() {
if(x.<caret>){
}
// ORDER: b, f, foo
@@ -0,0 +1,13 @@
val b: Boolean = true
val c: String = "true"
val d: Int = 1
val e: Long = 1L
val f: Boolean = true
fun foo(): Boolean
fun test(): Int {
return <caret>
}
//ORDER: test, d
@@ -0,0 +1,17 @@
// FIR_COMPARISON
object x {
val b: Boolean = true
val c: String = "true"
val d: Int = 1
val e: Long = 1L
val f: Boolean = true
fun foo(): Int
}
fun test(): Int {
return x.<caret>
}
//ORDER: d, foo, f
@@ -0,0 +1,17 @@
// FIR_COMPARISON
val a: Int
val b: String
val c: Long
val d: Int
fun test(): Int {
receiveLambda {
return@receiveLambda <caret>
}
return 2
}
fun receiveLambda(x: () -> Int){}
// ORDER: a, d, test
@@ -0,0 +1,18 @@
// FIR_COMPARISON
object x {
val b: Boolean = true
val c: String = "true"
val d: Int = 1
val e: Long = 1L
val f: Boolean = true
fun foo(): Boolean = true
}
fun x() {
while(x.<caret>){
}
// ORDER: b, f, foo
@@ -485,6 +485,44 @@ public class BasicCompletionWeigherTestGenerated extends AbstractBasicCompletion
}
}
@TestMetadata("idea/idea-completion/testData/weighers/basic/expectedType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ExpectedType extends AbstractBasicCompletionWeigherTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInExpectedType() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-completion/testData/weighers/basic/expectedType"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true);
}
@TestMetadata("ifConditionQualified.kt")
public void testIfConditionQualified() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt");
}
@TestMetadata("returnFromFunction.kt")
public void testReturnFromFunction() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt");
}
@TestMetadata("returnFromFunctionQualifiedSelector.kt")
public void testReturnFromFunctionQualifiedSelector() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt");
}
@TestMetadata("returnFromLambda.kt")
public void testReturnFromLambda() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt");
}
@TestMetadata("whileConditionQualified.kt")
public void testWhileConditionQualified() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt");
}
}
@TestMetadata("idea/idea-completion/testData/weighers/basic/parameterNameAndType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -485,6 +485,44 @@ public class HighLevelWeigherTestGenerated extends AbstractHighLevelWeigherTest
}
}
@TestMetadata("idea/idea-completion/testData/weighers/basic/expectedType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ExpectedType extends AbstractHighLevelWeigherTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInExpectedType() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-completion/testData/weighers/basic/expectedType"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true);
}
@TestMetadata("ifConditionQualified.kt")
public void testIfConditionQualified() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt");
}
@TestMetadata("returnFromFunction.kt")
public void testReturnFromFunction() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt");
}
@TestMetadata("returnFromFunctionQualifiedSelector.kt")
public void testReturnFromFunctionQualifiedSelector() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt");
}
@TestMetadata("returnFromLambda.kt")
public void testReturnFromLambda() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt");
}
@TestMetadata("whileConditionQualified.kt")
public void testWhileConditionQualified() throws Exception {
runTest("idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt");
}
}
@TestMetadata("idea/idea-completion/testData/weighers/basic/parameterNameAndType")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)