KT-59801 [FIR] scripting: tests for reference shortening

This commit is contained in:
Andrei Klunnyi
2023-07-13 15:19:56 +02:00
parent 3d40eba379
commit 0323b0fb19
7 changed files with 60 additions and 3 deletions
@@ -43,7 +43,7 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerForWholeFileTestG
@Test
public void testAllFilesPresentInReferenceShortenerWholeFile() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
}
@Test
@@ -57,4 +57,16 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerForWholeFileTestG
public void testFileWithMultipleDeclarations() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/fileWithMultipleDeclarations.kt");
}
@Test
@TestMetadata("scriptFileWithImportStatement.kts")
public void testScriptFileWithImportStatement() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/scriptFileWithImportStatement.kts");
}
@Test
@TestMetadata("scriptFileWithoutImportStatements.kts")
public void testScriptFileWithoutImportStatements() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/scriptFileWithoutImportStatements.kts");
}
}
@@ -43,7 +43,7 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerForWholeFi
@Test
public void testAllFilesPresentInReferenceShortenerWholeFile() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
}
@Test
@@ -57,4 +57,16 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerForWholeFi
public void testFileWithMultipleDeclarations() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/fileWithMultipleDeclarations.kt");
}
@Test
@TestMetadata("scriptFileWithImportStatement.kts")
public void testScriptFileWithImportStatement() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/scriptFileWithImportStatement.kts");
}
@Test
@TestMetadata("scriptFileWithoutImportStatements.kts")
public void testScriptFileWithoutImportStatements() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/scriptFileWithoutImportStatements.kts");
}
}
@@ -0,0 +1,11 @@
// FILE: main.kts
import a.b.c.dependency.Foo
fun foo<caret>(): a.b.c.dependency.Foo = t
// FILE: dependency.kt
package a.b.c.dependency
class Foo {
class Nested
}
@@ -0,0 +1,7 @@
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] a.b.c.dependency.Foo
with SHORTEN_AND_IMPORT:
[type] a.b.c.dependency.Foo
with SHORTEN_AND_STAR_IMPORT:
[type] a.b.c.dependency.Foo
@@ -0,0 +1,9 @@
// FILE: main.kts
fun foo<caret>(): a.b.c.dependency.Foo = t
// FILE: dependency.kt
package a.b.c.dependency
class Foo {
class Nested
}
@@ -0,0 +1,6 @@
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] a.b.c.dependency.Foo
with SHORTEN_AND_STAR_IMPORT:
[type] a.b.c.dependency.Foo
@@ -235,7 +235,7 @@ private fun AnalysisApiTestGroup.generateAnalysisApiComponentsTests() {
model("referenceShortener")
}
test(AbstractReferenceShortenerForWholeFileTest::class) {
model("referenceShortenerWholeFile")
model("referenceShortenerWholeFile", pattern = TestGeneratorUtil.KT_OR_KTS)
}
}