FIR IDE: add tests which failing with exceptions inside FIR

This commit is contained in:
Ilya Kirillov
2020-07-06 23:45:19 +03:00
parent 9cf4fdfb71
commit 055b975699
9 changed files with 261 additions and 194 deletions
@@ -980,11 +980,14 @@ fun main(args: Array<String>) {
} }
} }
testGroup("idea/idea-fir/tests", "idea/testData") { testGroup("idea/idea-fir/tests", "idea") {
testClass<AbstractFirHighlightingTest> { testClass<AbstractFirHighlightingTest> {
model("highlighter") model("testData/highlighter")
model("idea-fir/testData/highlighterFir", pattern = KT_WITHOUT_DOTS_IN_NAME)
}
} }
testGroup("idea/idea-fir/tests", "idea/testData") {
testClass<AbstractFirReferenceResolveTest> { testClass<AbstractFirReferenceResolveTest> {
model("resolve/references", pattern = KT_WITHOUT_DOTS_IN_NAME) model("resolve/references", pattern = KT_WITHOUT_DOTS_IN_NAME)
} }
@@ -0,0 +1,3 @@
interface X
class B(private val parent: X, private val int: Int = 42)
+3
View File
@@ -0,0 +1,3 @@
class A : X {
private val x = B(this)
}
@@ -0,0 +1,5 @@
interface A {
val q: Int
}
val A.extension: Int get() = q
@@ -0,0 +1,3 @@
class C(val a: A) {
val e = a.extension
}
@@ -0,0 +1,5 @@
interface A {
fun bar(a: String = "", b: C, c: String = "")
}
interface C
+8
View File
@@ -0,0 +1,8 @@
class B {
fun q(): C {}
private val y = q()
fun foo(a: A) = with(a) {
bar("a", y)
}
}
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.idea.highlighter package org.jetbrains.kotlin.idea.highlighter
import org.jetbrains.kotlin.idea.addExternalTestFiles
import org.jetbrains.kotlin.idea.shouldBeRethrown import org.jetbrains.kotlin.idea.shouldBeRethrown
import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources
import org.jetbrains.kotlin.idea.withPossiblyDisabledDuplicatedFirSourceElementsException import org.jetbrains.kotlin.idea.withPossiblyDisabledDuplicatedFirSourceElementsException
@@ -17,6 +18,11 @@ abstract class AbstractFirHighlightingTest : AbstractHighlightingTest() {
override fun isFirPlugin() = true override fun isFirPlugin() = true
override fun doTest(unused: String?) {
addExternalTestFiles(testPath())
super.doTest(unused)
}
override fun checkHighlighting(fileText: String) { override fun checkHighlighting(fileText: String) {
val doComparison = !InTextDirectivesUtils.isDirectiveDefined(myFixture.file.text, "IGNORE_FIR") val doComparison = !InTextDirectivesUtils.isDirectiveDefined(myFixture.file.text, "IGNORE_FIR")
val checkInfos = !InTextDirectivesUtils.isDirectiveDefined(fileText, NO_CHECK_INFOS_PREFIX); val checkInfos = !InTextDirectivesUtils.isDirectiveDefined(fileText, NO_CHECK_INFOS_PREFIX);
@@ -16,10 +16,12 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ /** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all") @SuppressWarnings("all")
@RunWith(JUnit3RunnerWithInners.class)
public class FirHighlightingTestGenerated extends AbstractFirHighlightingTest {
@TestMetadata("idea/testData/highlighter") @TestMetadata("idea/testData/highlighter")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
public class FirHighlightingTestGenerated extends AbstractFirHighlightingTest { public static class Highlighter extends AbstractFirHighlightingTest {
private void runTest(String testDataFilePath) throws Exception { private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
} }
@@ -251,3 +253,32 @@ public class FirHighlightingTestGenerated extends AbstractFirHighlightingTest {
} }
} }
} }
@TestMetadata("idea/idea-fir/testData/highlighterFir")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class HighlighterFir extends AbstractFirHighlightingTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInHighlighterFir() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-fir/testData/highlighterFir"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("consturctor.kt")
public void testConsturctor() throws Exception {
runTest("idea/idea-fir/testData/highlighterFir/consturctor.kt");
}
@TestMetadata("extensionProperty.kt")
public void testExtensionProperty() throws Exception {
runTest("idea/idea-fir/testData/highlighterFir/extensionProperty.kt");
}
@TestMetadata("withCall.kt")
public void testWithCall() throws Exception {
runTest("idea/idea-fir/testData/highlighterFir/withCall.kt");
}
}
}