From 67f9025f9eeef5a6ff07830b4264d3b32130fdab Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 8 Jun 2022 16:19:11 +0300 Subject: [PATCH] Add test data for parsing of complicated <..> and <..>= combinations ^KT-52684 Related ^KT-8263 Related --- ...CompilerTestFE10TestdataTestGenerated.java | 22 +++++ ...irOldFrontendDiagnosticsTestGenerated.java | 22 +++++ ...DiagnosticsWithLightTreeTestGenerated.java | 22 +++++ .../tests/syntax/complicatedLTGT.fir.kt | 8 ++ .../tests/syntax/complicatedLTGT.kt | 8 ++ .../tests/syntax/complicatedLTGTE.fir.kt | 8 ++ .../tests/syntax/complicatedLTGTE.kt | 8 ++ compiler/testData/psi/complicateLTGT.kt | 3 + compiler/testData/psi/complicateLTGT.txt | 93 ++++++++++++++++++ compiler/testData/psi/complicateLTGTE.kt | 3 + compiler/testData/psi/complicateLTGTE.txt | 97 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 22 +++++ .../kotlin/parsing/ParsingTestGenerated.java | 10 ++ 13 files changed, 326 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/syntax/complicatedLTGT.fir.kt create mode 100644 compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt create mode 100644 compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.fir.kt create mode 100644 compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt create mode 100644 compiler/testData/psi/complicateLTGT.kt create mode 100644 compiler/testData/psi/complicateLTGT.txt create mode 100644 compiler/testData/psi/complicateLTGTE.kt create mode 100644 compiler/testData/psi/complicateLTGTE.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index da542a71e6c..4a852242e7f 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -31153,6 +31153,28 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/syntax") + @TestDataPath("$PROJECT_ROOT") + public class Syntax { + @Test + public void testAllFilesPresentInSyntax() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/syntax"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("complicatedLTGT.kt") + public void testComplicatedLTGT() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt"); + } + + @Test + @TestMetadata("complicatedLTGTE.kt") + public void testComplicatedLTGTE() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 765746b283d..2b1dac04be6 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -31153,6 +31153,28 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/syntax") + @TestDataPath("$PROJECT_ROOT") + public class Syntax { + @Test + public void testAllFilesPresentInSyntax() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/syntax"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("complicatedLTGT.kt") + public void testComplicatedLTGT() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt"); + } + + @Test + @TestMetadata("complicatedLTGTE.kt") + public void testComplicatedLTGTE() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 147a10423ee..1600bcebda4 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -31153,6 +31153,28 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/syntax") + @TestDataPath("$PROJECT_ROOT") + public class Syntax { + @Test + public void testAllFilesPresentInSyntax() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/syntax"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("complicatedLTGT.kt") + public void testComplicatedLTGT() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt"); + } + + @Test + @TestMetadata("complicatedLTGTE.kt") + public void testComplicatedLTGTE() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/diagnostics/tests/syntax/complicatedLTGT.fir.kt b/compiler/testData/diagnostics/tests/syntax/complicatedLTGT.fir.kt new file mode 100644 index 00000000000..7fe44c53a54 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntax/complicatedLTGT.fir.kt @@ -0,0 +1,8 @@ +// SKIP_TXT +// ISSUE: KT-8263 + +fun test(x: Int, y: Int) { + if (x < (if (y > 115) 1 else 2)) { + Unit + } +} diff --git a/compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt b/compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt new file mode 100644 index 00000000000..5ae615475da --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt @@ -0,0 +1,8 @@ +// SKIP_TXT +// ISSUE: KT-8263 + +fun test(x: Int, y: Int) { + if (x < (if (y > 115) 1 else 2)) { + Unit + } +} diff --git a/compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.fir.kt b/compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.fir.kt new file mode 100644 index 00000000000..613b3745e38 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.fir.kt @@ -0,0 +1,8 @@ +// SKIP_TXT +// ISSUE: KT-52684 + +fun test(x: Int, y: Int) { + if (x < (if (y >= 115) 1 else 2)) { + Unit + } +} diff --git a/compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt b/compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt new file mode 100644 index 00000000000..1989342ce34 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt @@ -0,0 +1,8 @@ +// SKIP_TXT +// ISSUE: KT-52684 + +fun test(x: Int, y: Int) { + if (x < (if (y >= 115) 1 else 2)) { + Unit + } +} diff --git a/compiler/testData/psi/complicateLTGT.kt b/compiler/testData/psi/complicateLTGT.kt new file mode 100644 index 00000000000..57a49e9edb6 --- /dev/null +++ b/compiler/testData/psi/complicateLTGT.kt @@ -0,0 +1,3 @@ +fun test(x: Int, y: Int) { + if (x < (if (y > 115) 1 else 2)) {} +} diff --git a/compiler/testData/psi/complicateLTGT.txt b/compiler/testData/psi/complicateLTGT.txt new file mode 100644 index 00000000000..cbeb21e8477 --- /dev/null +++ b/compiler/testData/psi/complicateLTGT.txt @@ -0,0 +1,93 @@ +KtFile: complicateLTGT.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + PsiErrorElement:Type expected + PsiElement(if)('if') + PsiErrorElement:Expecting comma or ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Expecting ')' + PsiElement(LPAR)('(') + PsiErrorElement:Expecting '->' to specify return type of a function type + + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiErrorElement:Expecting ') + + PsiWhiteSpace(' ') + THEN + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('115') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/complicateLTGTE.kt b/compiler/testData/psi/complicateLTGTE.kt new file mode 100644 index 00000000000..14db9e542c6 --- /dev/null +++ b/compiler/testData/psi/complicateLTGTE.kt @@ -0,0 +1,3 @@ +fun test(x: Int, y: Int) { + if (x < (if (y >= 115) 1 else 2)) {} +} diff --git a/compiler/testData/psi/complicateLTGTE.txt b/compiler/testData/psi/complicateLTGTE.txt new file mode 100644 index 00000000000..a9970ec24a5 --- /dev/null +++ b/compiler/testData/psi/complicateLTGTE.txt @@ -0,0 +1,97 @@ +KtFile: complicateLTGTE.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + PsiErrorElement:Type expected + PsiElement(if)('if') + PsiErrorElement:Expecting comma or ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Expecting ')' + PsiElement(LPAR)('(') + PsiErrorElement:Expecting '->' to specify return type of a function type + + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(GT)('>') + OPERATION_REFERENCE + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('115') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index e4891a6f4c3..d0abb77112e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -31243,6 +31243,28 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/syntax") + @TestDataPath("$PROJECT_ROOT") + public class Syntax { + @Test + public void testAllFilesPresentInSyntax() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/syntax"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("complicatedLTGT.kt") + public void testComplicatedLTGT() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGT.kt"); + } + + @Test + @TestMetadata("complicatedLTGTE.kt") + public void testComplicatedLTGTE() throws Exception { + runTest("compiler/testData/diagnostics/tests/syntax/complicatedLTGTE.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java index ac046886540..57d07990f54 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java @@ -131,6 +131,16 @@ public class ParsingTestGenerated extends AbstractParsingTest { runTest("compiler/testData/psi/CommentsBindingInStatementBlock.kt"); } + @TestMetadata("complicateLTGT.kt") + public void testComplicateLTGT() throws Exception { + runTest("compiler/testData/psi/complicateLTGT.kt"); + } + + @TestMetadata("complicateLTGTE.kt") + public void testComplicateLTGTE() throws Exception { + runTest("compiler/testData/psi/complicateLTGTE.kt"); + } + @TestMetadata("Constructors.kt") public void testConstructors() throws Exception { runTest("compiler/testData/psi/Constructors.kt");