From 2b52988f1b98ebfcafdbdb831b89861bad118ed9 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 20 Jul 2020 11:45:58 +0300 Subject: [PATCH] [FIR TEST] Add failing BB test with Deprecated annotation --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 18 ++++++++++++++++++ .../ir/irText/firProblems/deprecated.fir.txt | 19 +++++++++++++++++++ .../ir/irText/firProblems/deprecated.kt | 9 +++++++++ .../ir/irText/firProblems/deprecated.txt | 19 +++++++++++++++++++ .../kotlin/ir/IrTextTestCaseGenerated.java | 18 ++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 compiler/testData/ir/irText/firProblems/deprecated.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/deprecated.kt create mode 100644 compiler/testData/ir/irText/firProblems/deprecated.txt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 675bb8dafa1..6d512872353 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1690,6 +1690,24 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { } } + @TestMetadata("compiler/testData/ir/irText/firProblems") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FirProblems extends AbstractFir2IrTextTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); + } + + public void testAllFilesPresentInFirProblems() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("deprecated.kt") + public void testDeprecated() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); + } + } + @TestMetadata("compiler/testData/ir/irText/lambdas") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/testData/ir/irText/firProblems/deprecated.fir.txt b/compiler/testData/ir/irText/firProblems/deprecated.fir.txt new file mode 100644 index 00000000000..9506401baea --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/deprecated.fir.txt @@ -0,0 +1,19 @@ +FILE fqName: fileName:/deprecated.kt + FUN name:create visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun create (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" + FUN name:create visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.String + annotations: + Deprecated(message = 'Use create() instead()', replaceWith = ReplaceWith(expression = 'create()', imports = ), level = ) + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun create (s: kotlin.String): kotlin.String declared in ' + CALL 'public final fun create (): kotlin.String declared in ' type=kotlin.String origin=null + FUN name:create visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.String + annotations: + Deprecated(message = 'Use create() instead()', replaceWith = , level = ) + VALUE_PARAMETER name:b index:0 type:kotlin.Boolean + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun create (b: kotlin.Boolean): kotlin.String declared in ' + CALL 'public final fun create (): kotlin.String declared in ' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/firProblems/deprecated.kt b/compiler/testData/ir/irText/firProblems/deprecated.kt new file mode 100644 index 00000000000..c71316aeb93 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/deprecated.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME + +fun create() = "OK" + +@Deprecated("Use create() instead()", replaceWith = ReplaceWith("create()")) +fun create(s: String) = create() + +@Deprecated("Use create() instead()") +fun create(b: Boolean) = create() diff --git a/compiler/testData/ir/irText/firProblems/deprecated.txt b/compiler/testData/ir/irText/firProblems/deprecated.txt new file mode 100644 index 00000000000..8e6406d7db2 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/deprecated.txt @@ -0,0 +1,19 @@ +FILE fqName: fileName:/deprecated.kt + FUN name:create visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun create (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" + FUN name:create visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.String + annotations: + Deprecated(message = 'Use create() instead()', replaceWith = ReplaceWith(expression = 'create()', imports = []), level = ) + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun create (s: kotlin.String): kotlin.String declared in ' + CALL 'public final fun create (): kotlin.String declared in ' type=kotlin.String origin=null + FUN name:create visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.String + annotations: + Deprecated(message = 'Use create() instead()', replaceWith = , level = ) + VALUE_PARAMETER name:b index:0 type:kotlin.Boolean + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun create (b: kotlin.Boolean): kotlin.String declared in ' + CALL 'public final fun create (): kotlin.String declared in ' type=kotlin.String origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 9f0d4f8dc45..18da02b3c04 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1689,6 +1689,24 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { } } + @TestMetadata("compiler/testData/ir/irText/firProblems") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FirProblems extends AbstractIrTextTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInFirProblems() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("deprecated.kt") + public void testDeprecated() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); + } + } + @TestMetadata("compiler/testData/ir/irText/lambdas") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)