From 64f531fc9352ca134590bc3b18b9dc303e885c63 Mon Sep 17 00:00:00 2001 From: "victor.petukhov" Date: Wed, 31 Oct 2018 12:56:27 +0300 Subject: [PATCH] Reorganize spec tests infrastructure code - Add the tests mute system for the diagnostic tests - Move the code for the test info parsing to the separate package `parsers` - Unification of the `linked` and `not linked` spec tests - Package structure is refactored - Change the multiline comment format with a test information - Actualize `PrintSpecTestsStatistic` - Other different code improvements --- .../kotlin/checkers/BaseDiagnosticsTest.kt | 2 +- .../boolean-literals/p-1/pos/2.1.kt | 16 +- .../boolean-literals/p-1/pos/2.10.kt | 16 +- .../boolean-literals/p-1/pos/2.11.kt | 16 +- .../boolean-literals/p-1/pos/2.12.kt | 16 +- .../boolean-literals/p-1/pos/2.13.kt | 16 +- .../boolean-literals/p-1/pos/2.14.kt | 16 +- .../boolean-literals/p-1/pos/2.15.kt | 16 +- .../boolean-literals/p-1/pos/2.16.kt | 16 +- .../boolean-literals/p-1/pos/2.17.kt | 16 +- .../boolean-literals/p-1/pos/2.18.kt | 16 +- .../boolean-literals/p-1/pos/2.19.kt | 16 +- .../boolean-literals/p-1/pos/2.2.kt | 16 +- .../boolean-literals/p-1/pos/2.20.kt | 16 +- .../boolean-literals/p-1/pos/2.21.kt | 16 +- .../boolean-literals/p-1/pos/2.22.kt | 16 +- .../boolean-literals/p-1/pos/2.23.kt | 16 +- .../boolean-literals/p-1/pos/2.24.kt | 16 +- .../boolean-literals/p-1/pos/2.25.kt | 16 +- .../boolean-literals/p-1/pos/2.26.kt | 16 +- .../boolean-literals/p-1/pos/2.3.kt | 16 +- .../boolean-literals/p-1/pos/2.4.kt | 16 +- .../boolean-literals/p-1/pos/2.5.kt | 16 +- .../boolean-literals/p-1/pos/2.6.kt | 16 +- .../boolean-literals/p-1/pos/2.7.kt | 16 +- .../boolean-literals/p-1/pos/2.8.kt | 16 +- .../boolean-literals/p-1/pos/2.9.kt | 16 +- .../binary-integer-literals/p-1/pos/1.1.kt | 14 +- .../binary-integer-literals/p-1/pos/2.1.kt | 14 +- .../decimal-integer-literals/p-1/pos/1.1.kt | 14 +- .../decimal-integer-literals/p-1/pos/2.1.kt | 14 +- .../p-1/pos/1.1.kt | 14 +- .../p-1/pos/2.1.kt | 14 +- .../long-integer-literals/p-1/pos/1.1.kt | 14 +- .../long-integer-literals/p-1/pos/1.2.kt | 14 +- .../long-integer-literals/p-1/pos/1.3.kt | 14 +- .../templates/_layout/linkedTestsLayout.kt | 16 +- .../templates/_layout/notLinkedTestsLayout.kt | 14 +- .../tests-spec/testData/diagnostics/ReadMe.md | 136 ------ .../binary-integer-literals/p-1/neg/1.1.kt | 17 +- .../binary-integer-literals/p-1/neg/2.1.kt | 21 +- .../binary-integer-literals/p-1/neg/2.2.kt | 57 ++- .../binary-integer-literals/p-1/neg/2.2.txt | 22 +- .../binary-integer-literals/p-1/neg/2.3.kt | 27 +- .../decimal-integer-literals/p-1/neg/2.1.kt | 23 +- .../decimal-integer-literals/p-1/neg/2.2.kt | 29 +- .../p-1/neg/1.1.kt | 17 +- .../p-1/neg/2.1.kt | 21 +- .../p-1/neg/2.2.kt | 35 +- .../p-1/neg/2.3.kt | 27 +- .../long-integer-literals/p-1/neg/1.1.kt | 28 +- .../long-integer-literals/p-1/neg/1.2.kt | 21 +- .../long-integer-literals/p-1/neg/1.3.kt | 21 +- .../long-integer-literals/p-1/neg/2.1.kt | 15 +- .../long-integer-literals/p-1/neg/2.2.kt | 15 +- .../long-integer-literals/p-1/neg/2.3.kt | 30 +- .../long-integer-literals/p-1/neg/2.4.kt | 18 +- .../long-integer-literals/p-1/neg/2.5.kt | 25 +- .../long-integer-literals/p-1/pos/2.1.kt | 16 +- .../long-integer-literals/p-1/pos/2.2.kt | 27 +- .../long-integer-literals/p-1/pos/2.3.kt | 27 +- .../long-integer-literals/p-1/pos/2.4.kt | 27 +- .../long-integer-literals/p-1/pos/2.5.kt | 24 +- .../linked/when-expression/p-11/neg/1.1.kt | 20 +- .../linked/when-expression/p-11/neg/1.2.kt | 20 +- .../linked/when-expression/p-11/neg/3.1.kt | 28 +- .../linked/when-expression/p-11/neg/6.1.kt | 40 +- .../linked/when-expression/p-11/neg/7.1.kt | 36 +- .../linked/when-expression/p-11/neg/8.1.kt | 20 +- .../linked/when-expression/p-11/neg/8.2.kt | 44 +- .../linked/when-expression/p-11/neg/8.3.kt | 26 +- .../linked/when-expression/p-11/pos/1.1.kt | 20 +- .../linked/when-expression/p-11/pos/1.2.kt | 24 +- .../linked/when-expression/p-11/pos/1.3.kt | 30 +- .../linked/when-expression/p-11/pos/3.1.kt | 18 +- .../linked/when-expression/p-11/pos/6.1.kt | 42 +- .../linked/when-expression/p-11/pos/7.1.kt | 18 +- .../linked/when-expression/p-11/pos/8.1.kt | 18 +- .../linked/when-expression/p-11/pos/8.2.kt | 24 +- .../linked/when-expression/p-11/pos/8.3.kt | 34 +- .../linked/when-expression/p-2/pos/3.1.kt | 15 +- .../linked/when-expression/p-2/pos/3.2.kt | 15 +- .../linked/when-expression/p-3/neg/1.1.kt | 18 +- .../linked/when-expression/p-3/neg/2.1.kt | 15 +- .../linked/when-expression/p-3/neg/2.2.kt | 15 +- .../linked/when-expression/p-3/pos/1.1.kt | 64 +-- .../linked/when-expression/p-3/pos/2.1.kt | 44 +- .../linked/when-expression/p-3/pos/2.2.kt | 18 +- .../linked/when-expression/p-3/pos/2.3.kt | 30 +- .../linked/when-expression/p-5/neg/1.1.kt | 20 +- .../linked/when-expression/p-5/pos/1.1.kt | 18 +- .../linked/when-expression/p-6/neg/1.1.kt | 18 +- .../linked/when-expression/p-6/pos/1.1.kt | 64 +-- .../linked/when-expression/p-7/neg/1.1.kt | 20 +- .../linked/when-expression/p-7/neg/1.2.kt | 15 +- .../linked/when-expression/p-7/neg/3.1.kt | 15 +- .../linked/when-expression/p-7/neg/3.2.kt | 22 +- .../linked/when-expression/p-7/neg/5.1.kt | 18 +- .../linked/when-expression/p-7/neg/5.2.kt | 18 +- .../linked/when-expression/p-7/neg/7.1.kt | 20 +- .../linked/when-expression/p-7/pos/1.1.kt | 30 +- .../linked/when-expression/p-7/pos/1.2.kt | 32 +- .../linked/when-expression/p-7/pos/1.3.kt | 42 +- .../linked/when-expression/p-7/pos/1.4.kt | 36 +- .../linked/when-expression/p-7/pos/3.1.kt | 18 +- .../linked/when-expression/p-7/pos/3.2.kt | 18 +- .../linked/when-expression/p-7/pos/5.1.kt | 64 +-- .../linked/when-expression/p-7/pos/5.2.kt | 78 ++-- .../linked/when-expression/p-7/pos/7.1.kt | 22 +- .../linked/when-expression/p-9/neg/1.1.kt | 26 +- .../linked/when-expression/p-9/neg/1.2.kt | 22 +- .../linked/when-expression/p-9/neg/1.3.kt | 24 +- .../linked/when-expression/p-9/neg/1.4.kt | 34 +- .../linked/when-expression/p-9/pos/1.1.kt | 34 +- .../linked/when-expression/p-9/pos/1.2.kt | 22 +- .../linked/when-expression/p-9/pos/1.3.kt | 22 +- .../linked/when-expression/p-9/pos/1.4.kt | 34 +- .../contracts/analysis/common/neg/1.kt | 17 +- .../contracts/analysis/common/pos/1.kt | 17 +- .../contracts/analysis/common/pos/2.kt | 14 +- .../controlFlow/initialization/neg/1.kt | 19 +- .../controlFlow/initialization/neg/2.kt | 15 +- .../controlFlow/initialization/neg/3.kt | 39 +- .../controlFlow/initialization/neg/4.kt | 20 +- .../controlFlow/initialization/neg/5.kt | 16 +- .../controlFlow/initialization/neg/6.kt | 17 +- .../controlFlow/initialization/pos/1.kt | 14 +- .../controlFlow/initialization/pos/2.kt | 24 +- .../controlFlow/initialization/pos/3.kt | 22 +- .../controlFlow/initialization/pos/4.kt | 19 +- .../controlFlow/initialization/pos/5.kt | 17 +- .../controlFlow/initialization/pos/6.kt | 21 +- .../controlFlow/initialization/pos/7.kt | 17 +- .../controlFlow/unreachableCode/neg/1.kt | 13 +- .../controlFlow/unreachableCode/pos/1.kt | 19 +- .../controlFlow/unreachableCode/pos/2.kt | 15 +- .../controlFlow/unreachableCode/pos/3.kt | 17 +- .../controlFlow/unreachableCode/pos/4.kt | 14 +- .../controlFlow/unreachableCode/pos/5.kt | 13 +- .../controlFlow/unreachableCode/pos/6.kt | 13 +- .../controlFlow/unreachableCode/pos/7.kt | 17 +- .../contracts/analysis/smartcasts/neg/1.kt | 22 +- .../contracts/analysis/smartcasts/neg/10.kt | 410 ++++++++++-------- .../contracts/analysis/smartcasts/neg/10.txt | 114 ++--- .../contracts/analysis/smartcasts/neg/11.kt | 23 +- .../contracts/analysis/smartcasts/neg/12.kt | 21 +- .../contracts/analysis/smartcasts/neg/13.kt | 27 +- .../contracts/analysis/smartcasts/neg/14.kt | 58 +++ .../contracts/analysis/smartcasts/neg/14.txt | 126 ++++++ .../contracts/analysis/smartcasts/neg/15.kt | 23 +- .../contracts/analysis/smartcasts/neg/2.kt | 23 +- .../contracts/analysis/smartcasts/neg/3.kt | 27 +- .../contracts/analysis/smartcasts/neg/4.kt | 37 +- .../contracts/analysis/smartcasts/neg/5.kt | 25 +- .../contracts/analysis/smartcasts/neg/6.kt | 29 +- .../contracts/analysis/smartcasts/neg/7.kt | 29 +- .../contracts/analysis/smartcasts/neg/8.kt | 23 +- .../contracts/analysis/smartcasts/neg/9.kt | 15 +- .../contracts/analysis/smartcasts/pos/1.kt | 22 +- .../contracts/analysis/smartcasts/pos/10.kt | 19 +- .../contracts/analysis/smartcasts/pos/11.kt | 21 +- .../contracts/analysis/smartcasts/pos/12.kt | 19 +- .../contracts/analysis/smartcasts/pos/13.kt | 21 +- .../contracts/analysis/smartcasts/pos/14.kt | 25 +- .../contracts/analysis/smartcasts/pos/2.kt | 29 +- .../contracts/analysis/smartcasts/pos/3.kt | 25 +- .../contracts/analysis/smartcasts/pos/4.kt | 37 +- .../contracts/analysis/smartcasts/pos/5.kt | 25 +- .../contracts/analysis/smartcasts/pos/6.kt | 29 +- .../contracts/analysis/smartcasts/pos/7.kt | 29 +- .../contracts/analysis/smartcasts/pos/8.kt | 33 +- .../contracts/analysis/smartcasts/pos/9.kt | 31 +- .../contractBuilder/common/neg/1.kt | 83 +++- .../contractBuilder/common/neg/1.txt | 5 + .../contractBuilder/common/neg/10.kt | 14 +- .../contractBuilder/common/neg/11.kt | 31 +- .../contractBuilder/common/neg/11.txt | 9 +- .../contractBuilder/common/neg/12.kt | 36 +- .../contractBuilder/common/neg/12.txt | 13 +- .../contractBuilder/common/neg/13.kt | 14 +- .../contractBuilder/common/neg/14.kt | 24 +- .../contractBuilder/common/neg/14.txt | 2 +- .../contractBuilder/common/neg/15.kt | 17 +- .../contractBuilder/common/neg/16.kt | 20 +- .../contractBuilder/common/neg/17.kt | 18 +- .../common/{pos/4.kt => neg/19.kt} | 19 +- .../common/{pos/4.txt => neg/19.txt} | 0 .../contractBuilder/common/neg/2.kt | 15 +- .../contractBuilder/common/neg/3.kt | 17 +- .../contractBuilder/common/neg/4.kt | 14 +- .../contractBuilder/common/neg/5.kt | 29 +- .../contractBuilder/common/neg/6.kt | 14 +- .../contractBuilder/common/neg/7.kt | 22 +- .../contractBuilder/common/neg/7.txt | 2 +- .../contractBuilder/common/neg/8.kt | 16 +- .../contractBuilder/common/neg/9.kt | 14 +- .../contractBuilder/common/pos/1.kt | 14 +- .../contractBuilder/common/pos/2.kt | 13 +- .../contractBuilder/common/pos/3.kt | 53 --- .../contractBuilder/common/pos/3.txt | 7 - .../effects/callsInPlace/neg/1.kt | 28 +- .../effects/callsInPlace/neg/1.txt | 10 +- .../effects/callsInPlace/neg/2.kt | 17 +- .../effects/callsInPlace/pos/1.kt | 15 +- .../effects/callsInPlace/pos/2.kt | 18 +- .../effects/callsInPlace/pos/3.kt | 16 +- .../contractBuilder/effects/common/neg/1.kt | 19 +- .../contractBuilder/effects/returns/neg/1.kt | 17 +- .../contractBuilder/effects/returns/neg/2.kt | 15 +- .../contractBuilder/effects/returns/neg/3.kt | 14 +- .../contractBuilder/effects/returns/neg/4.kt | 16 +- .../contractBuilder/effects/returns/neg/5.kt | 14 +- .../contractBuilder/effects/returns/neg/6.kt | 18 +- .../contractBuilder/effects/returns/neg/7.kt | 17 +- .../contractBuilder/effects/returns/pos/1.kt | 23 +- .../contractBuilder/effects/returns/pos/2.kt | 15 +- .../contractBuilder/effects/returns/pos/3.kt | 14 +- .../declarations/contractFunction/neg/1.kt | 12 +- .../declarations/contractFunction/neg/2.kt | 27 +- .../declarations/contractFunction/neg/3.kt | 17 +- .../declarations/contractFunction/neg/4.kt | 20 +- .../declarations/contractFunction/pos/1.kt | 15 +- .../declarations/contractFunction/pos/2.kt | 35 -- .../declarations/contractFunction/pos/2.txt | 10 - .../boolean-literals/p-1/neg/2.1.kt | 16 +- .../boolean-literals/p-1/neg/2.10.kt | 16 +- .../boolean-literals/p-1/neg/2.11.kt | 16 +- .../boolean-literals/p-1/neg/2.12.kt | 16 +- .../boolean-literals/p-1/neg/2.13.kt | 16 +- .../boolean-literals/p-1/neg/2.14.kt | 16 +- .../boolean-literals/p-1/neg/2.15.kt | 16 +- .../boolean-literals/p-1/neg/2.16.kt | 16 +- .../boolean-literals/p-1/neg/2.17.kt | 16 +- .../boolean-literals/p-1/neg/2.18.kt | 16 +- .../boolean-literals/p-1/neg/2.19.kt | 16 +- .../boolean-literals/p-1/neg/2.2.kt | 16 +- .../boolean-literals/p-1/neg/2.20.kt | 16 +- .../boolean-literals/p-1/neg/2.21.kt | 16 +- .../boolean-literals/p-1/neg/2.22.kt | 16 +- .../boolean-literals/p-1/neg/2.23.kt | 16 +- .../boolean-literals/p-1/neg/2.24.kt | 16 +- .../boolean-literals/p-1/neg/2.25.kt | 16 +- .../boolean-literals/p-1/neg/2.26.kt | 16 +- .../boolean-literals/p-1/neg/2.3.kt | 16 +- .../boolean-literals/p-1/neg/2.4.kt | 16 +- .../boolean-literals/p-1/neg/2.5.kt | 16 +- .../boolean-literals/p-1/neg/2.6.kt | 16 +- .../boolean-literals/p-1/neg/2.7.kt | 16 +- .../boolean-literals/p-1/neg/2.8.kt | 16 +- .../boolean-literals/p-1/neg/2.9.kt | 16 +- .../boolean-literals/p-1/pos/2.1.kt | 16 +- .../boolean-literals/p-1/pos/2.10.kt | 16 +- .../boolean-literals/p-1/pos/2.11.kt | 16 +- .../boolean-literals/p-1/pos/2.12.kt | 16 +- .../boolean-literals/p-1/pos/2.13.kt | 16 +- .../boolean-literals/p-1/pos/2.14.kt | 16 +- .../boolean-literals/p-1/pos/2.15.kt | 16 +- .../boolean-literals/p-1/pos/2.16.kt | 16 +- .../boolean-literals/p-1/pos/2.17.kt | 16 +- .../boolean-literals/p-1/pos/2.18.kt | 16 +- .../boolean-literals/p-1/pos/2.19.kt | 16 +- .../boolean-literals/p-1/pos/2.2.kt | 16 +- .../boolean-literals/p-1/pos/2.20.kt | 16 +- .../boolean-literals/p-1/pos/2.21.kt | 16 +- .../boolean-literals/p-1/pos/2.22.kt | 16 +- .../boolean-literals/p-1/pos/2.23.kt | 16 +- .../boolean-literals/p-1/pos/2.24.kt | 16 +- .../boolean-literals/p-1/pos/2.25.kt | 16 +- .../boolean-literals/p-1/pos/2.26.kt | 16 +- .../boolean-literals/p-1/pos/2.3.kt | 16 +- .../boolean-literals/p-1/pos/2.4.kt | 16 +- .../boolean-literals/p-1/pos/2.5.kt | 16 +- .../boolean-literals/p-1/pos/2.6.kt | 16 +- .../boolean-literals/p-1/pos/2.7.kt | 16 +- .../boolean-literals/p-1/pos/2.8.kt | 16 +- .../boolean-literals/p-1/pos/2.9.kt | 16 +- .../binary-integer-literals/p-1/neg/1.1.kt | 14 +- .../binary-integer-literals/p-1/neg/1.2.kt | 14 +- .../binary-integer-literals/p-1/neg/2.1.kt | 14 +- .../binary-integer-literals/p-1/pos/1.1.kt | 14 +- .../binary-integer-literals/p-1/pos/1.2.kt | 14 +- .../binary-integer-literals/p-1/pos/1.3.kt | 14 +- .../binary-integer-literals/p-1/pos/2.1.kt | 14 +- .../binary-integer-literals/p-1/pos/2.2.kt | 14 +- .../binary-integer-literals/p-1/pos/2.3.kt | 14 +- .../binary-integer-literals/p-1/pos/2.4.kt | 14 +- .../decimal-integer-literals/p-1/neg/1.1.kt | 14 +- .../decimal-integer-literals/p-1/pos/1.1.kt | 14 +- .../decimal-integer-literals/p-1/pos/2.1.kt | 14 +- .../decimal-integer-literals/p-1/pos/2.2.kt | 14 +- .../decimal-integer-literals/p-1/pos/2.3.kt | 14 +- .../decimal-integer-literals/p-2/neg/1.1.kt | 14 +- .../decimal-integer-literals/p-2/neg/1.2.kt | 14 +- .../p-1/neg/1.1.kt | 14 +- .../p-1/neg/1.2.kt | 14 +- .../p-1/neg/2.1.kt | 14 +- .../p-1/pos/1.1.kt | 14 +- .../p-1/pos/1.2.kt | 14 +- .../p-1/pos/2.1.kt | 14 +- .../p-1/pos/2.2.kt | 14 +- .../p-1/pos/2.3.kt | 14 +- .../p-1/pos/2.4.kt | 14 +- .../long-integer-literals/p-1/neg/1.1.kt | 14 +- .../long-integer-literals/p-1/neg/1.2.kt | 14 +- .../long-integer-literals/p-1/neg/1.3.kt | 14 +- .../long-integer-literals/p-1/neg/1.4.kt | 14 +- .../long-integer-literals/p-1/pos/1.1.kt | 14 +- .../long-integer-literals/p-1/pos/1.10.kt | 14 +- .../long-integer-literals/p-1/pos/1.2.kt | 14 +- .../long-integer-literals/p-1/pos/1.3.kt | 14 +- .../long-integer-literals/p-1/pos/1.4.kt | 14 +- .../long-integer-literals/p-1/pos/1.5.kt | 14 +- .../long-integer-literals/p-1/pos/1.6.kt | 14 +- .../long-integer-literals/p-1/pos/1.7.kt | 14 +- .../long-integer-literals/p-1/pos/1.8.kt | 14 +- .../long-integer-literals/p-1/pos/1.9.kt | 14 +- .../templates/_layout/linkedTestsLayout.kt | 16 +- .../templates/_layout/notLinkedTestsLayout.kt | 14 +- .../checkers/AbstractDiagnosticsTestSpec.kt | 61 ++- .../DiagnosticsTestSpecGenerated.java | 25 +- .../AbstractBlackBoxCodegenTestSpec.kt | 28 +- .../kotlin/parsing/AbstractParsingTestSpec.kt | 31 +- .../parsing/ParsingTestSpecGenerated.java | 10 + .../tests/org/jetbrains/kotlin/spec/Common.kt | 83 ++++ .../Feature.kt | 2 +- .../FeatureInteractionTestDataGenerator.kt | 2 +- .../FeatureTemplatesConfig.kt | 4 +- .../GenerationConfig.kt | 8 +- .../GenerationUtils.kt | 2 +- .../TemplateSubstitutionTransformers.kt | 2 +- .../kotlin/spec/models/AbstractSpecTest.kt | 79 ++++ .../kotlin/spec/models/LinkedSpecTest.kt | 60 +++ .../kotlin/spec/models/NotLinkedSpecTest.kt | 50 +++ .../kotlin/spec/parsers/CommonParser.kt | 121 ++++++ .../jetbrains/kotlin/spec/parsers/Patterns.kt | 94 ++++ .../kotlin/spec/parsers/TestCasesParser.kt | 83 ++++ .../kotlin/spec/parsers/TestInfoParser.kt | 58 +++ .../GenerateFeatureInteractionSpecTestData.kt | 10 +- .../kotlin/spec/tasks/GenerateJsonTestsMap.kt | 15 +- .../spec/tasks/PrintSpecTestsStatistic.kt | 15 +- .../kotlin/spec/utils/TestsJsonMapBuilder.kt | 10 +- .../spec/utils/TestsStatisticCollector.kt | 32 +- .../validators/AbstractSpecTestValidator.kt | 288 ------------ .../spec/validators/AbstractTestValidator.kt | 60 +++ .../validators/DiagnosticTestTypeValidator.kt | 35 +- .../validators/LinkedSpecTestValidator.kt | 125 ------ .../validators/NotLinkedSpecTestValidator.kt | 112 ----- .../validators/ParsingTestTypeValidator.kt | 12 +- 348 files changed, 4722 insertions(+), 3802 deletions(-) delete mode 100644 compiler/tests-spec/testData/diagnostics/ReadMe.md create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.txt rename compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/{pos/4.kt => neg/19.kt} (52%) rename compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/{pos/4.txt => neg/19.txt} (100%) delete mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.kt delete mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.txt delete mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.kt delete mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.txt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/Common.kt rename compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/{featureinteraction => templates}/Feature.kt (93%) rename compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/{featureinteraction => templates}/FeatureInteractionTestDataGenerator.kt (98%) rename compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/{featureinteraction => templates}/FeatureTemplatesConfig.kt (93%) rename compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/{featureinteraction => templates}/GenerationConfig.kt (95%) rename compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/{featureinteraction => templates}/GenerationUtils.kt (92%) rename compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/{featureinteraction => templates}/TemplateSubstitutionTransformers.kt (86%) create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/AbstractSpecTest.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/LinkedSpecTest.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/NotLinkedSpecTest.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/CommonParser.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/Patterns.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestCasesParser.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestInfoParser.kt delete mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractSpecTestValidator.kt create mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractTestValidator.kt delete mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/LinkedSpecTestValidator.kt delete mode 100644 compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/NotLinkedSpecTestValidator.kt diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt index 2dc37705cf5..3731818839d 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt @@ -128,7 +128,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava = ArrayList() val actualDiagnostics: MutableList = ArrayList() val expectedText: String - private val clearText: String + val clearText: String private val createKtFile: Lazy private val whatDiagnosticsToConsider: Condition val customLanguageVersionSettings: LanguageVersionSettings? diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt index d7a9e38330b..67d70efc124 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 1 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 1 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ open class `true` { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt index e93bdfe8a86..7c44d0902e7 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 10 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the companionObject. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 10 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the companionObject. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt index 3c4d1a27677..41b6e33afa5 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 11 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the function. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 11 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the function. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun `true`(): Boolean { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt index 2207dbf3c14..b6bf1bada19 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 12 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the setter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 12 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the setter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt index ce04a6e3fa3..71dd5f7cde1 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 13 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the simpleUserType. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 13 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the simpleUserType. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt index 8fa6c0fd5ab..acd4005cb9a 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 14 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeParameter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 14 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeParameter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt index 38cf71d975b..5e4c31d8bc0 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 15 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the parameter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 15 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the parameter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1(`true`: Boolean) = !!!`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt index 50a000e93c4..2fb7de9a1b3 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 16 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationComplex. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 16 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationComplex. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @file:[org.jetbrains.`true`.`false`() `true`] diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt index 9f98b9b9449..f08a540fabb 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 17 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the object. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 17 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the object. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ open class A { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt index 5b441b72ca0..37db75c02bc 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 18 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeAlias. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 18 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeAlias. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ typealias `true` = Boolean diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt index fcb4d7abe06..61c2653f561 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 19 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the import. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 19 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the import. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ // FILE: 2_19_1.kt diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt index df0fd688a7a..49c7a6699a7 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 2 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelReference. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 2 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelReference. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun `true`() { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt index f42d0ff5b70..1f9edde404d 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 20 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the infixFunctionCall. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 20 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the infixFunctionCall. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ infix fun Int.`true`(value: Int) = value > 100 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt index 718709990cc..5b7f1d5a5f5 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 21 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the catchBlock. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 21 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the catchBlock. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ annotation class A diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt index 443d8a1aa6a..b5a73369c79 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 22 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelDefinition. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 22 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelDefinition. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @Retention(AnnotationRetention.SOURCE) diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt index 5d9a6688cdd..ca2a3003489 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 23 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the atomicExpression. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 23 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the atomicExpression. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun box(): String? { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt index c559352e63b..8716ac9de75 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt @@ -1,14 +1,14 @@ // WITH_RUNTIME /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 24 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the variableDeclarationEntry. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 24 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the variableDeclarationEntry. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ val `true` = {`false`: Boolean -> !`false` } diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt index bd27a9b132f..600035e9a6f 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt @@ -1,14 +1,14 @@ // WITH_RUNTIME /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 25 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the valueArgument. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 25 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the valueArgument. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1(`true`: Boolean, `false`: Boolean) = `true` && !!!`false` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt index f6a7a4631ae..84cb41c5ac9 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 26 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the callableReference. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 26 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the callableReference. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ val Boolean.`true`: Boolean diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt index e9ca47db7b6..a0c1aeec218 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 3 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeConstraint. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 3 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeConstraint. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A <`true`, `false`> diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt index 7d3a07cd097..ffe7aff8b49 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 4 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationSimple. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 4 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationSimple. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @file:`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt index 47bd6b24e7c..da9a2472aeb 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 5 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageComplex. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 5 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageComplex. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt index cd0d1007a99..20ac477d66b 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 6 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageSimple. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 6 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageSimple. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package `true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt index 0b00ccce880..24fd300012e 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 7 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the enumEntry. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 7 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the enumEntry. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ enum class A(val x: Boolean) { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt index 3062e7d5d4b..51a85ab2aa5 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt @@ -1,12 +1,12 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 8 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the stringTemplateElement. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 8 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the stringTemplateElement. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun box(): String? { diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt index fa1f379d09d..763f883073e 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt @@ -1,14 +1,14 @@ // HELPERS: REFLECT /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 9 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the unescapedAnnotation. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 9 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the unescapedAnnotation. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.`true` diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt index f5926bbac3f..d199109126f 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with binary digit symbols. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with binary digit symbols. */ val value_1 = 0b1110001100 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt index 876d4fa8451..2db21ebb959 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with binary digit symbols separated by underscores. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with binary digit symbols separated by underscores. */ val value_1 = 0b1_110110100 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt index 81d2f6dcc1e..2bda4e4b1dd 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with decimal digit symbols. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with decimal digit symbols. */ val value_1 = 1234567890 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt index a80eee210ae..4c6ce69a335 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Sequences with decimal digit symbols separated by underscores. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Sequences with decimal digit symbols separated by underscores. */ val value_1 = 1234_5678_90 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt index 8b837fd4a35..9834817ec47 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with hexadecimal digit symbols. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with hexadecimal digit symbols. */ val value_1 = 0x1234567890 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt index 5d0428d86d1..4958a2d0406 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with hexadecimal digit symbols separated by underscores. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with hexadecimal digit symbols separated by underscores. */ val value_1 = 0x1_23a567b90 diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt index 8d503ea28af..a57cb0e99cb 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Decimal integer literals with long literal mark. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Decimal integer literals with long literal mark. */ val value_1 = 0L diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt index 4daa1047b1f..14c5d75663b 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 2 - DESCRIPTION: Hexadecimal integer literals with long literal mark. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 2 + * DESCRIPTION: Hexadecimal integer literals with long literal mark. */ val value_1 = 0x0L diff --git a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt index 969176369ce..ad21ae04971 100644 --- a/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt +++ b/compiler/tests-spec/testData/codegen/box/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 3 - DESCRIPTION: Binary integer literals with long literal mark. + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 3 + * DESCRIPTION: Binary integer literals with long literal mark. */ val value_1 = 0b0L diff --git a/compiler/tests-spec/testData/codegen/box/templates/_layout/linkedTestsLayout.kt b/compiler/tests-spec/testData/codegen/box/templates/_layout/linkedTestsLayout.kt index 25b9e3e2344..961bdb7bb4d 100644 --- a/compiler/tests-spec/testData/codegen/box/templates/_layout/linkedTestsLayout.kt +++ b/compiler/tests-spec/testData/codegen/box/templates/_layout/linkedTestsLayout.kt @@ -1,10 +1,10 @@ /* - KOTLIN CODEGEN BOX SPEC TEST () - - SECTIONS: - PARAGRAPH: - SENTENCE: [] - NUMBER: - DESCRIPTION: - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN CODEGEN BOX SPEC TEST () + * + * SECTIONS: + * PARAGRAPH: + * SENTENCE: [] + * NUMBER: + * DESCRIPTION: + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/templates/_layout/notLinkedTestsLayout.kt b/compiler/tests-spec/testData/codegen/box/templates/_layout/notLinkedTestsLayout.kt index 4621eb4f9f7..1b422501182 100644 --- a/compiler/tests-spec/testData/codegen/box/templates/_layout/notLinkedTestsLayout.kt +++ b/compiler/tests-spec/testData/codegen/box/templates/_layout/notLinkedTestsLayout.kt @@ -1,9 +1,9 @@ /* - KOTLIN NOT LINKED CODEGEN BOX SPEC TEST () - - SECTION: - CATEGORIES: - NUMBER: - DESCRIPTION: - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN NOT LINKED CODEGEN BOX SPEC TEST () + * + * SECTION: + * CATEGORIES: + * NUMBER: + * DESCRIPTION: + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/ReadMe.md b/compiler/tests-spec/testData/diagnostics/ReadMe.md deleted file mode 100644 index 1754e1136b7..00000000000 --- a/compiler/tests-spec/testData/diagnostics/ReadMe.md +++ /dev/null @@ -1,136 +0,0 @@ -# Diagnostic specification tests - -Diagnostic specification tests are diagnostic tests for certain statements in the [Kotlin language specification](https://github.com/JetBrains/kotlin-spec). - -Note: diagnostic tests format specification you can see in the [diagnostic tests readme](https://github.com/JetBrains/kotlin/blob/master/compiler/testData/diagnostics/ReadMe.md). - -## Structure - -Each test relates to a specific section, paragraph, and sentence of the Kotlin language specification, and is either positive or negative. - -The folder structure is as follows: -* `` - * `p-` - * `` - * `..kt` (test source code) - * `..txt` (descriptors file) - -Example test file path: `testData/diagnostics/linked/when-expression/p-2/neg/3.1.kt` - -## Positive and negative tests - -Positive tests are considered to be tests in which there is no single diagnostics with a `ERROR` severity. -Positive tests can only contain diagnostics with a `WARNING` or `INFO` severity (or not contain at all). - -In a negative test, there must be at least one diagnostic with `ERROR` severity. - -## Tests format - -### Test description - -Each test file must contain meta information in the form of a multi-line comment. - -A comment with meta information has the following format: -``` -/* - KOTLIN SPEC TEST () - - SECTIONS: - PARAGRAPH: - SENTENCE: [] - NUMBER: - DESCRIPTION: - */ -``` -Example: -``` -/* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 2 - SENTENCE: [3] When expression has two different forms: with bound value and without it. - NUMBER: 1 - DESCRIPTION: Empty 'when' with bound value. - */ -``` - -Meta-information should be placed at the beginning of the file after directives (if any). - -### Case description - -The test can contain many cases. -Each case (if there are more than one) should be accompanied by a description. - -The case description is a single-line comment of the following format: -``` -// CASE DESCRIPTION: -``` -Example: -``` -// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes and null value are covered). -fun case_1(expr: Expr?): String = when (expr) { - is Const -> expr.n - is Sum -> expr.e1 + expr.e2 - is Mul -> expr.m1 + expr.m2 - null -> "" -} -``` - -## Test validation - -Before running the test, the following validation is performed: -- check for correspondence to the format of the folders and file names; -- check for correspondence to the format of the meta-information in the test file; -- check for consistency between the location and name of the test file and the meta-information in it; -- checking whether the test is positive or negative using information about diagnostics severity. - -If the validation fails, you will receive exception about it. - -## Test run log - -During the test run, the following information is displayed for each test: - -``` -DIAGNOSTICS SPEC TEST -SECTIONS: (paragraph: ) -SENTENCE : -TEST NUMBER: -TEST CASES: -DESCRIPTION: -DIAGNOSTICS: | -``` -Example: -``` -DIAGNOSTICS NEGATIVE SPEC TEST -SECTIONS: when-expression (paragraph: 3) -SENTENCE 1: -TEST NUMBER: 1 -NUMBER OF TEST CASES: 3 -DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body. -DIAGNOSTICS: {ERROR=2, WARNING=1} | {BREAK_OR_CONTINUE_IN_WHEN=2, UNREACHABLE_CODE=1} -``` - -## Statistics on specification tests - -To see statistics for existing tests you can run gradle task `printSpecTestStatistic` in the `:compiler:tests-spec`. - -Example output: -``` - -================================================== -SPEC TESTS STATISTIC --------------------------------------------------- -PSI: 0 tests -DIAGNOSTICS: 54 tests - when-expression: 54 tests - PARAGRAPH 9: 8 tests [ neg: 4 ] [ pos: 4 ] - PARAGRAPH 7: 16 tests [ neg: 7 ] [ pos: 9 ] - PARAGRAPH 6: 2 tests [ neg: 1 ] [ pos: 1 ] - PARAGRAPH 11: 17 tests [ neg: 8 ] [ pos: 9 ] - PARAGRAPH 3: 7 tests [ neg: 3 ] [ pos: 4 ] - PARAGRAPH 2: 2 tests [ pos: 2 ] - PARAGRAPH 5: 2 tests [ neg: 1 ] [ pos: 1 ] -CODEGEN: 0 tests - -``` \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt index 41eb45d1052..95409760f37 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt @@ -1,12 +1,15 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 1 - DESCRIPTION: Binary integer literals with the prefix only. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 1 + * DESCRIPTION: Binary integer literals with the prefix only. */ +// TESTCASE NUMBER: 1 val value_1 = 0b + +// TESTCASE NUMBER: 2 val value_2 = 0B diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt index 3ed06750da1..8246581ca71 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt @@ -1,14 +1,21 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Binary integer literals with an underscore after the prefix. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Binary integer literals with an underscore after the prefix. */ +// TESTCASE NUMBER: 1 val value_1 = 0b_1110100000 + +// TESTCASE NUMBER: 2 val value_2 = 0B_______11010000 + +// TESTCASE NUMBER: 3 val value_3 = 0B_1_1_0_1_0_0_0_0 + +// TESTCASE NUMBER: 4 val value_4 = 0b_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.kt index 31061f28782..a28d8738eff 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.kt @@ -1,21 +1,42 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 2 - DESCRIPTION: Binary integer literals with an underscore in the first position (it's considered as identifiers). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 2 + * DESCRIPTION: Binary integer literals with an underscore in the first position (it's considered as identifiers). */ -val value_0 = _____0b0_1_1_1_0_1 -val value_1 = _0B1_______1_______1_______0 -val value_2 = _0_0B1_0_1_1_1_0_1_1 -val value_3 = _0B000000000 -val value_4 = _0000000000b -val value_5 = _0_1b -val value_6 = ____________0b -val value_7 = _0_b_0 -val value_8 = _b_0 -val value_9 = _b -val value_10 = _b_ +// TESTCASE NUMBER: 1 +val value_1 = _____0b0_1_1_1_0_1 + +// TESTCASE NUMBER: 2 +val value_2 = _0B1_______1_______1_______0 + +// TESTCASE NUMBER: 3 +val value_3 = _0_0B1_0_1_1_1_0_1_1 + +// TESTCASE NUMBER: 4 +val value_4 = _0B000000000 + +// TESTCASE NUMBER: 5 +val value_5 = _0000000000b + +// TESTCASE NUMBER: 6 +val value_6 = _0_1b + +// TESTCASE NUMBER: 7 +val value_7 = ____________0b + +// TESTCASE NUMBER: 8 +val value_8 = _0_b_0 + +// TESTCASE NUMBER: 9 +val value_9 = _b_0 + +// TESTCASE NUMBER: 10 +val value_10 = _b + +// TESTCASE NUMBER: 12 +val value_12 = _b_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.txt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.txt index 5c2c9868e47..0f9b2997d6e 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.txt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.2.txt @@ -1,13 +1,13 @@ package -public val value_0: [ERROR : Type for _____0b0_1_1_1_0_1] -public val value_1: [ERROR : Type for _0B1_______1_______1_______0] -public val value_10: [ERROR : Type for _b_] -public val value_2: [ERROR : Type for _0_0B1_0_1_1_1_0_1_1] -public val value_3: [ERROR : Type for _0B000000000] -public val value_4: [ERROR : Type for _0000000000b] -public val value_5: [ERROR : Type for _0_1b] -public val value_6: [ERROR : Type for ____________0b] -public val value_7: [ERROR : Type for _0_b_0] -public val value_8: [ERROR : Type for _b_0] -public val value_9: [ERROR : Type for _b] +public val value_1: [ERROR : Type for _____0b0_1_1_1_0_1] +public val value_10: [ERROR : Type for _b] +public val value_12: [ERROR : Type for _b_] +public val value_2: [ERROR : Type for _0B1_______1_______1_______0] +public val value_3: [ERROR : Type for _0_0B1_0_1_1_1_0_1_1] +public val value_4: [ERROR : Type for _0B000000000] +public val value_5: [ERROR : Type for _0000000000b] +public val value_6: [ERROR : Type for _0_1b] +public val value_7: [ERROR : Type for ____________0b] +public val value_8: [ERROR : Type for _0_b_0] +public val value_9: [ERROR : Type for _b_0] diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.3.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.3.kt index eab7d7e8249..8a7bf8d929f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.3.kt @@ -1,17 +1,30 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 3 - DESCRIPTION: Binary integer literals with an underscore in the last position. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 3 + * DESCRIPTION: Binary integer literals with an underscore in the last position. */ +// TESTCASE NUMBER: 1 val value_1 = 0b0_1_1_0_1_1_____ + +// TESTCASE NUMBER: 2 val value_2 = 0B1_______1_______0_______1_ + +// TESTCASE NUMBER: 3 val value_3 = 0B000000000_ + +// TESTCASE NUMBER: 4 val value_4 = 0b_ + +// TESTCASE NUMBER: 5 val value_5 = 0B______________ + +// TESTCASE NUMBER: 6 val value_6 = 0B0_ + +// TESTCASE NUMBER: 7 val value_7 = 0B10_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.1.kt index cdb380843bb..5eb840ae8da 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.1.kt @@ -1,15 +1,24 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Integer literals with an underscore in the last position. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Integer literals with an underscore in the last position. */ +// TESTCASE NUMBER: 1 val value_1 = 1_ + +// TESTCASE NUMBER: 2 val value_2 = 1_00000000000000000_ + +// TESTCASE NUMBER: 3 val value_3 = 1_____________ + +// TESTCASE NUMBER: 4 val value_4 = 9____________0_ + +// TESTCASE NUMBER: 5 val value_5 = 1_______________________________________________________________________________________________________________________________________________________ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.2.kt index 2c56bbef1b7..31c7063e49d 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/2.2.kt @@ -1,18 +1,33 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 2 - DESCRIPTION: Integer literals with an underscore in the first position (it's considered as identifiers). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 2 + * DESCRIPTION: Integer literals with an underscore in the first position (it's considered as identifiers). */ +// TESTCASE NUMBER: 1 val value_1 = _5678_90 + +// TESTCASE NUMBER: 2 val value_2 = _2_3_4_5_6_7_8_9_ + +// TESTCASE NUMBER: 3 val value_3 = _____________0000 + +// TESTCASE NUMBER: 4 val value_4 = _______________________________________________________________________________________________________________________________________________________0 + +// TESTCASE NUMBER: 5 val value_5 = ____________________________________________________ + +// TESTCASE NUMBER: 6 val value_6 = _ + +// TESTCASE NUMBER: 7 val value_7 = _0_ + +// TESTCASE NUMBER: 8 val value_8 = _9_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt index 6aa64fa54d5..2cef9c72419 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt @@ -1,12 +1,15 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. - NUMBER: 1 - DESCRIPTION: Hexadecimal integer literals with the prefix only. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Hexadecimal integer literals with the prefix only. */ +// TESTCASE NUMBER: 1 val value_1 = 0x + +// TESTCASE NUMBER: 2 val value_2 = 0X diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt index c8838870320..d9eda12d74a 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt @@ -1,14 +1,21 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Hexadecimal integer literals with an underscore after the prefix. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Hexadecimal integer literals with an underscore after the prefix. */ +// TESTCASE NUMBER: 1 val value_1 = 0x_1234567890 + +// TESTCASE NUMBER: 2 val value_2 = 0X_______23456789 + +// TESTCASE NUMBER: 3 val value_3 = 0X_2_3_4_5_6_7_8_9 + +// TESTCASE NUMBER: 4 val value_4 = 0x_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.2.kt index 83ddcec3adf..a23f82f41b1 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.2.kt @@ -1,21 +1,42 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 2 - DESCRIPTION: Hexadecimal integer literals with an underscore in the first position (it's considered as identifiers). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 2 + * DESCRIPTION: Hexadecimal integer literals with an underscore in the first position (it's considered as identifiers). */ +// TESTCASE NUMBER: 1 val value_1 = _____0x3_4_5_6_7_8 + +// TESTCASE NUMBER: 2 val value_2 = _0X4_______5_______6_______7 + +// TESTCASE NUMBER: 3 val value_3 = _0_0X4_3_4_5_6_7_8_9 + +// TESTCASE NUMBER: 4 val value_4 = _0X000000000 + +// TESTCASE NUMBER: 5 val value_5 = _0000000000x + +// TESTCASE NUMBER: 6 val value_6 = _0_9x + +// TESTCASE NUMBER: 7 val value_7 = ____________0x + +// TESTCASE NUMBER: 8 val value_8 = _0_x_0 + +// TESTCASE NUMBER: 9 val value_9 = _x_0 + +// TESTCASE NUMBER: 10 val value_10 = _x + +// TESTCASE NUMBER: 11 val value_11 = _x_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.3.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.3.kt index 77119328201..3a0228b050c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.3.kt @@ -1,17 +1,30 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. - NUMBER: 3 - DESCRIPTION: Hexadecimal integer literals with an underscore in the last position. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. + * NUMBER: 3 + * DESCRIPTION: Hexadecimal integer literals with an underscore in the last position. */ +// TESTCASE NUMBER: 1 val value_1 = 0x3_4_5_6_7_8_____ + +// TESTCASE NUMBER: 2 val value_2 = 0X4_______5_______6_______7_ + +// TESTCASE NUMBER: 3 val value_3 = 0X000000000_ + +// TESTCASE NUMBER: 5 val value_5 = 0x_ + +// TESTCASE NUMBER: 6 val value_6 = 0X______________ + +// TESTCASE NUMBER: 7 val value_7 = 0X0_ + +// TESTCASE NUMBER: 8 val value_8 = 0X10_ diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt index 9f0fc5fa7c9..1fcababc2b4 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt @@ -1,19 +1,33 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 1 - DESCRIPTION: Binary and hexadecimal integer literals with a long literal mark only. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 1 + * DESCRIPTION: Binary and hexadecimal integer literals with a long literal mark only. */ +// TESTCASE NUMBER: 1 val value_1 = 0bl + +// TESTCASE NUMBER: 2 val value_2 = 0BL + +// TESTCASE NUMBER: 3 val value_3 = 0Xl + +// TESTCASE NUMBER: 4 val value_4 = 0xL +// TESTCASE NUMBER: 5 val value_5 = 0b_l + +// TESTCASE NUMBER: 6 val value_6 = 0B_L + +// TESTCASE NUMBER: 7 val value_7 = 0X____l + +// TESTCASE NUMBER: 8 val value_8 = 0x_L diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt index 24aa909683f..6a57659bb6b 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt @@ -1,14 +1,21 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 2 - DESCRIPTION: Various integer literals with a not allowed underscore before the long literal mark. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 2 + * DESCRIPTION: Various integer literals with a not allowed underscore before the long literal mark. */ +// TESTCASE NUMBER: 1 val value_1 = 0b0_l + +// TESTCASE NUMBER: 2 val value_2 = 0B12_L + +// TESTCASE NUMBER: 3 val value_3 = 0X234_l + +// TESTCASE NUMBER: 4 val value_4 = 0x3567_L diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt index b8733dad3ec..aabed99b671 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt @@ -1,14 +1,21 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 3 - DESCRIPTION: Various integer literals with not allowed long literal mark in lower case. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 3 + * DESCRIPTION: Various integer literals with not allowed long literal mark in lower case. */ +// TESTCASE NUMBER: 1 val value_1 = 0l + +// TESTCASE NUMBER: 2 val value_2 = 1000000000000000l + +// TESTCASE NUMBER: 3 val value_3 = 0X0l + +// TESTCASE NUMBER: 4 val value_4 = 0b101l diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.1.kt index d86547c9935..3166ed0e2ad 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.1.kt @@ -2,15 +2,16 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 1 - DESCRIPTION: Various integer literals with not allowed long literal mark in lower case (type checking). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 1 + * DESCRIPTION: Various integer literals with not allowed long literal mark in lower case (type checking). */ +// TESTCASE NUMBER: 1 fun case_1() { 0l checkType { _() } 10000000000000l checkType { _() } diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.2.kt index aaed6b475df..f3f72b38fcd 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.2.kt @@ -2,15 +2,16 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 2 - DESCRIPTION: Type checking (comparison with invalid types) of various integer literals with long literal mark. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 2 + * DESCRIPTION: Type checking (comparison with invalid types) of various integer literals with long literal mark. */ +// TESTCASE NUMBER: 1 fun case_1() { 0L checkType { _() } 1000000L checkType { _() } diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.3.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.3.kt index d6b31ca954a..cf9b6eb3ea7 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.3.kt @@ -2,20 +2,24 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 3 - DESCRIPTION: Type checking (comparison with invalid types) of various integer literals. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 3 + * DESCRIPTION: Type checking (comparison with invalid types) of various integer literals. */ +// TESTCASE NUMBER: 1 fun case_1() { 0 checkType { _() } 0 checkType { _() } 0 checkType { _() } +} +// TESTCASE NUMBER: 2 +fun case_2() { 127 checkType { _() } 127 checkType { _() } 127 checkType { _() } @@ -33,7 +37,10 @@ fun case_1() { -129 checkType { _() } -129 checkType { _() } -129 checkType { _() } +} +// TESTCASE NUMBER: 3 +fun case_3() { checkSubtype(32767) 32767 checkType { _() } 32767 checkType { _() } @@ -55,7 +62,10 @@ fun case_1() { -32769 checkType { _() } -32769 checkType { _() } -32769 checkType { _() } +} +// TESTCASE NUMBER: 4 +fun case_4() { checkSubtype(2147483647) checkSubtype(2147483647) 2147483647 checkType { _() } @@ -81,7 +91,10 @@ fun case_1() { -2147483649 checkType { _() } -2147483649 checkType { _() } -2147483649 checkType { _() } +} +// TESTCASE NUMBER: 5 +fun case_5() { checkSubtype(9223372036854775807) checkSubtype(9223372036854775807) checkSubtype(9223372036854775807) @@ -95,7 +108,10 @@ fun case_1() { -9223372036854775807 checkType { _() } -9223372036854775807 checkType { _() } -9223372036854775807 checkType { _() } +} +// TESTCASE NUMBER: 6 +fun case_6() { checkSubtype(-100000000000000000000000000000000) checkSubtype(-100000000000000000000000000000000) checkSubtype(-100000000000000000000000000000000) diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.4.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.4.kt index 864357ffab0..e3322c41aec 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.4.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.4.kt @@ -2,22 +2,26 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 4 - DESCRIPTION: Type checking (comparison with invalid types) of too a big integers. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 4 + * DESCRIPTION: Type checking (comparison with invalid types) of too a big integers. */ +// TESTCASE NUMBER: 1 fun case_1() { checkSubtype(-9223372036854775808L) -9223372036854775808L checkType { _() } checkSubtype(9223372036854775808L) 9223372036854775808L checkType { _() } +} +// TESTCASE NUMBER: 2 +fun case_2() { checkSubtype(100000000000000000000000000000000L) 100000000000000000000000000000000L checkType { _() } diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.5.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.5.kt index 62c42d0dcd3..749c9585b33 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.5.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/2.5.kt @@ -2,31 +2,33 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 5 - DESCRIPTION: Check of integer type selection depends on the context (incopatible types). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 5 + * DESCRIPTION: Check of integer type selection depends on the context (incopatible types). */ // FILE: functions.kt package functions +// TESTCASE NUMBER: 1 fun f1(x1: Byte) = x1 +// TESTCASE NUMBER: 2 fun f2(x1: Short) = x1 +// TESTCASE NUMBER: 3, 4 fun f3(x1: Int) = x1 -fun f4(x1: Long) = x1 - -// FILE: usages.kt +// FILE: main.kt import functions.* +// TESTCASE NUMBER: 1 fun case_1() { f1(128) f1(-129) @@ -40,6 +42,7 @@ fun case_1() { f1(-1000000000000000000000000000000000000000000000000) } +// TESTCASE NUMBER: 2 fun case_2() { f2(32768) f2(-32769) @@ -51,6 +54,7 @@ fun case_2() { f2(-1000000000000000000000000000000000000000000000000) } +// TESTCASE NUMBER: 3 fun case_3() { f3(9223372036854775807) f3(-9223372036854775807) @@ -58,6 +62,7 @@ fun case_3() { f3(-1000000000000000000000000000000000000000000000000) } +// TESTCASE NUMBER: 4 fun case_4() { f3(1000000000000000000000000000000000000000000000000) f3(-1000000000000000000000000000000000000000000000000) diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.1.kt index 0bc31263269..f9479ae6cc7 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.1.kt @@ -2,15 +2,16 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 1 - DESCRIPTION: Type checking of various integer literals with long literal mark. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 1 + * DESCRIPTION: Type checking of various integer literals with long literal mark. */ +// TESTCASE NUMBER: 1 fun case_1() { 0L checkType { _() } 10000000000000L checkType { _() } @@ -20,6 +21,7 @@ fun case_1() { 0b0L checkType { _() } } +// TESTCASE NUMBER: 2 fun case_2() { 9223372036854775807L checkType { _() } -9223372036854775807L checkType { _() } diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.2.kt index b816f11e8d8..3da752a3372 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.2.kt @@ -2,22 +2,26 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 2 - DESCRIPTION: Type checking of decimal integer literals. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 2 + * DESCRIPTION: Type checking of decimal integer literals. */ +// TESTCASE NUMBER: 1 fun case_1() { 0 checkType { _() } checkSubtype(0) checkSubtype(0) checkSubtype(0) checkSubtype(0) +} +// TESTCASE NUMBER: 2 +fun case_2() { 127 checkType { _() } checkSubtype(127) checkSubtype(127) @@ -39,7 +43,10 @@ fun case_1() { checkSubtype(-129) checkSubtype(-129) checkSubtype(-129) +} +// TESTCASE NUMBER: 3 +fun case_3() { 32767 checkType { _() } checkSubtype(32767) checkSubtype(32767) @@ -57,7 +64,10 @@ fun case_1() { -32769 checkType { _() } checkSubtype(-32769) checkSubtype(-32769) +} +// TESTCASE NUMBER: 4 +fun case_4() { 2147483647 checkType { _() } checkSubtype(2147483647) checkSubtype(2147483647) @@ -71,7 +81,10 @@ fun case_1() { -2147483649 checkType { _() } checkSubtype(-2147483649) +} +// TESTCASE NUMBER: 5 +fun case_5() { 9223372036854775807 checkType { _() } checkSubtype(9223372036854775807) diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.3.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.3.kt index ce7ba380123..070c0c71984 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.3.kt @@ -2,22 +2,26 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 3 - DESCRIPTION: Type checking of hexadecimal integer literals. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 3 + * DESCRIPTION: Type checking of hexadecimal integer literals. */ +// TESTCASE NUMBER: 1 fun case_1() { 0x0 checkType { _() } checkSubtype(0x0) checkSubtype(0x0) checkSubtype(0x0) checkSubtype(0x0) +} +// TESTCASE NUMBER: 2 +fun case_2() { 0x7F checkType { _() } checkSubtype(0x7F) checkSubtype(0x7F) @@ -39,7 +43,10 @@ fun case_1() { checkSubtype(-0x81) checkSubtype(-0x81) checkSubtype(-0x81) +} +// TESTCASE NUMBER: 3 +fun case_3() { 0x7FFF checkType { _() } checkSubtype(0x7FFF) checkSubtype(0x7FFF) @@ -57,7 +64,10 @@ fun case_1() { -0X8001 checkType { _() } checkSubtype(-0X8001) checkSubtype(-0X8001) +} +// TESTCASE NUMBER: 4 +fun case_4() { 0x7FFFFFFF checkType { _() } checkSubtype(0x7FFFFFFF) checkSubtype(0x7FFFFFFF) @@ -71,7 +81,10 @@ fun case_1() { -0x80000001 checkType { _() } checkSubtype(-0x80000001) +} +// TESTCASE NUMBER: 5 +fun case_5() { 0X7FFFFFFFFFFFFFFF checkType { _() } checkSubtype(0X7FFFFFFFFFFFFFFF) diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.4.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.4.kt index 8c23a1b7afb..4ba5b2c3188 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.4.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.4.kt @@ -2,22 +2,26 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 4 - DESCRIPTION: Type checking of binary integer literals. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 4 + * DESCRIPTION: Type checking of binary integer literals. */ +// TESTCASE NUMBER: 1 fun case_1() { 0b0 checkType { _() } checkSubtype(0b0) checkSubtype(0b0) checkSubtype(0b0) checkSubtype(0b0) +} +// TESTCASE NUMBER: 2 +fun case_2() { 0B1111111 checkType { _() } checkSubtype(0B1111111) checkSubtype(0B1111111) @@ -39,7 +43,10 @@ fun case_1() { checkSubtype(-0b10000001) checkSubtype(-0b10000001) checkSubtype(-0b10000001) +} +// TESTCASE NUMBER: 3 +fun case_3() { 0B111111111111111 checkType { _() } checkSubtype(0B111111111111111) checkSubtype(0B111111111111111) @@ -57,7 +64,10 @@ fun case_1() { -0B1000000000000001 checkType { _() } checkSubtype(-0B1000000000000001) checkSubtype(-0B1000000000000001) +} +// TESTCASE NUMBER: 4 +fun case_4() { 0b1111111111111111111111111111111 checkType { _() } checkSubtype(0b1111111111111111111111111111111) checkSubtype(0b1111111111111111111111111111111) @@ -71,7 +81,10 @@ fun case_1() { -0b10000000000000000000000000000001 checkType { _() } checkSubtype(-0b10000000000000000000000000000001) +} +// TESTCASE NUMBER: 5 +fun case_5() { 0b111111111111111111111111111111111111111111111111111111111111111 checkType { _() } checkSubtype(0b111111111111111111111111111111111111111111111111111111111111111) diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.5.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.5.kt index 1d0d5957ba9..ee76c27ae88 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.5.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/2.5.kt @@ -2,37 +2,43 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. - NUMBER: 5 - DESCRIPTION: Check of integer type selection depends on the context. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise. + * NUMBER: 5 + * DESCRIPTION: Check of integer type selection depends on the context. */ // FILE: functions.kt package functions +// TESTCASE NUMBER: 1 fun f1(x1: Byte, x2: Short, x3: Int, x4: Long) = x1 + x2 + x3 + x4 +// TESTCASE NUMBER: 2 fun f2(x1: Short, x2: Int, x3: Long) = x1 + x2 + x3 +// TESTCASE NUMBER: 3 fun f3(x1: Int, x2: Long) = x1 + x2 +// TESTCASE NUMBER: 4 fun f4(x1: Long) = x1 -// FILE: usages.kt +// FILE: main.kt import functions.* +// TESTCASE NUMBER: 1 fun case_1() { f1(0, 0, 0, 0) f1(127, 127, 127, 127) f1(-128, -128, -128, -128) } +// TESTCASE NUMBER: 2 fun case_2() { f2(128, 128, 128) f2(-129, -129, -129) @@ -40,6 +46,7 @@ fun case_2() { f2(-32768, -32768, -32768) } +// TESTCASE NUMBER: 3 fun case_3() { f3(32768, 32768) f3(-32769, -32769) @@ -47,6 +54,7 @@ fun case_3() { f3(-2147483648, -2147483648) } +// TESTCASE NUMBER: 4 fun case_4() { f4(2147483648) f4(-2147483649) diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.1.kt index ff5a2befda6..7971190521f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.1.kt @@ -1,24 +1,24 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [1] It has an else entry; - NUMBER: 1 - DESCRIPTION: Checking for not exhaustive when without bound value when there is no else branch. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [1] It has an else entry; + * NUMBER: 1 + * DESCRIPTION: Checking for not exhaustive when without bound value when there is no else branch. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String = when { value_1 == 1 -> "" value_1 == 2 -> "" value_1 == 3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch). +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String = when { value_1 == 1 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches). +// TESTCASE NUMBER: 3 fun case_3(): Int = when {} diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.2.kt index 5237be3d0d8..f67ffd0cdb7 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.2.kt @@ -1,26 +1,26 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [1] It has an else entry; - NUMBER: 2 - DESCRIPTION: Checking for not exhaustive when with bound value when there is no else branch. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [1] It has an else entry; + * NUMBER: 2 + * DESCRIPTION: Checking for not exhaustive when with bound value when there is no else branch. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String = when (value_1) { 1 -> "" 2 -> "" 3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch). +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String = when (value_1) { 1 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches). +// TESTCASE NUMBER: 3 fun case_3(value_1: Int): Int = when (value_1) {} diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/3.1.kt index 98a220b592f..22e01bfc488 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/3.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/3.1.kt @@ -1,38 +1,38 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: - NUMBER: 1 - DESCRIPTION: Checking for not exhaustive 'when' when not contains by all Boolean values or 'when' does not have bound value. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: + * NUMBER: 1 + * DESCRIPTION: Checking for not exhaustive 'when' when not contains by all Boolean values or 'when' does not have bound value. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only true branch). +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean): String = when(value_1) { true -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only false branch). +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean): String = when(value_1) { false -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (no branches). +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean): Int = when(value_1) { } -// CASE DESCRIPTION: Checking for not exhaustive 'when' without bound value on the Boolean. +// TESTCASE NUMBER: 4 fun case_4(value_1: Boolean): String = when { value_1 == true -> "" value_1 == false -> "" } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' with both Boolean values covered, but using variables. - DISCUSSION: maybe use const propagation here? - ISSUES: KT-25265 + * TESTCASE NUMBER: 5 + * DISCUSSION: maybe use const propagation here? + * ISSUES: KT-25265 */ fun case_5(value_1: Boolean): String { val trueValue = true diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/6.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/6.1.kt index 20ab970c73b..7b20737d592 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/6.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/6.1.kt @@ -2,55 +2,55 @@ // !WITH_SEALED_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression; - NUMBER: 1 - DESCRIPTION: Checking for not exhaustive 'when' when not covered by all possible subtypes or 'when' does not have bound value. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression; + * NUMBER: 1 + * DESCRIPTION: Checking for not exhaustive 'when' when not covered by all possible subtypes or 'when' does not have bound value. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking). +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass): String = when(value_1) { is _SealedChild1 -> "" is _SealedChild2 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking with enumeration). +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClass): String = when(value_1) { is _SealedChild1, is _SealedChild2 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object). +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClassMixed): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" _SealedMixedChildObject1 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object with enumeration). +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClassMixed): String = when(value_1) { _SealedMixedChildObject1, is _SealedMixedChild2, is _SealedMixedChild1 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking). +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClassMixed): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" is _SealedMixedChild3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with several subtypes (no branches). +// TESTCASE NUMBER: 6 fun case_6(value_1: _SealedClassMixed): Int = when(value_1) { } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with one subtype (no branches). +// TESTCASE NUMBER: 7 fun case_7(value_1: _SealedClassSingleWithObject): Int = when(value_1) { } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes). +// TESTCASE NUMBER: 8 fun case_8(value_1: _SealedClassEmpty): String = when (value_1) { } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the not sealed class. +// TESTCASE NUMBER: 9 fun case_9(value_1: Number): String = when (value_1) { is Byte -> "" is Double -> "" @@ -61,21 +61,21 @@ fun case_9(value_1: Number): String = when (value_1) { } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on the Any. - DISCUSSION: maybe make exhaustive without else? + * TESTCASE NUMBER: 10 + * DISCUSSION: maybe make exhaustive without else? */ fun case_10(value_1: Any): String = when (value_1) { is Any -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' without bound value on the Sealed class with all subtypes covered. +// TESTCASE NUMBER: 11 fun case_11(value_1: _SealedClass): String = when { value_1 is _SealedChild1 -> "" value_1 is _SealedChild2 -> "" value_1 is _SealedChild3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking). +// TESTCASE NUMBER: 12 fun case_12(value_1: _SealedClassMixed): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/7.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/7.1.kt index d279561a5a8..629ae4067ff 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/7.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/7.1.kt @@ -2,42 +2,42 @@ // !WITH_ENUM_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; - NUMBER: 1 - DESCRIPTION: Checking for not exhaustive when when not covered by all enumerated values. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; + * NUMBER: 1 + * DESCRIPTION: Checking for not exhaustive when when not covered by all enumerated values. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values). +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass): String = when(value_1) { _EnumClass.EAST -> "" _EnumClass.SOUTH -> "" _EnumClass.NORTH -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values with enumerations). +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClass): String = when(value_1) { _EnumClass.EAST, _EnumClass.SOUTH, _EnumClass.NORTH -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (one branch). +// TESTCASE NUMBER: 3 fun case_3(value_1: _EnumClass): String = when(value_1) { _EnumClass.EAST -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with several values (no branches). +// TESTCASE NUMBER: 4 fun case_4(value_1: _EnumClass): String = when(value_1) { } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with one value (no branches). +// TESTCASE NUMBER: 5 fun case_5(value_1: _EnumClassSingle): String = when(value_1) { } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' with all Enum values covered, but using variable. - DISCUSSION: maybe use const propagation here? - ISSUES: KT-25265 + * TESTCASE NUMBER: 6 + * DISCUSSION: maybe use const propagation here? + * ISSUES: KT-25265 */ fun case_6(value_1: _EnumClass): String { val west = _EnumClass.WEST @@ -51,8 +51,8 @@ fun case_6(value_1: _EnumClass): String { } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class. - DISCUSSION - ISSUES: KT-26044 + * TESTCASE NUMBER: 7 + * DISCUSSION + * ISSUES: KT-26044 */ fun case_7(value_1: _EnumClassEmpty): String = when (value_1) { } diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.1.kt index ac63c9dad39..c6677a46f6a 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.1.kt @@ -1,26 +1,26 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. - NUMBER: 1 - DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. + * NUMBER: 1 + * DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without null-check branch. +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean?): String = when(value_1) { true -> "" false -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean with null-check branch, but all possible values not covered. +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean?): String = when(value_1) { true -> "" null -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without branches. +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean?): Int = when(value_1) { } diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.2.kt index 6d985d82b68..0bf51f85df5 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.2.kt @@ -2,23 +2,23 @@ // !WITH_SEALED_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. - NUMBER: 2 - DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. + * NUMBER: 2 + * DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed). */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch. +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass?): String = when(value_1) { is _SealedChild1 -> "" is _SealedChild2 -> "" is _SealedChild3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with mixed checks (type and object check) and null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClassMixed?): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" @@ -26,12 +26,12 @@ fun case_2(value_1: _SealedClassMixed?): String = when(val null -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with enumeration mixed checks (type and object check) and null-check branch. +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClassMixed?): String = when(value_1) { null, is _SealedMixedChild1, is _SealedMixedChild2, _SealedMixedChildObject1 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with all subtypes and objects covered without null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClassMixed?): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" @@ -41,17 +41,17 @@ fun case_4(value_1: _SealedClassMixed?): String = when(val _SealedMixedChildObject3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and all subtypes covered, but objects not covered. +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClassMixed?): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" is _SealedMixedChild3 -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without branches. +// TESTCASE NUMBER: 6 fun case_6(value_1: _SealedClassMixed?): Int = when(value_1) {} -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with null-check branch and all subtypes covered, but objects not covered. +// TESTCASE NUMBER: 7 fun case_7(value_1: _SealedClassMixed?): String = when(value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2-> "" @@ -59,23 +59,23 @@ fun case_7(value_1: _SealedClassMixed?): String = when(val null -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and only object covered. +// TESTCASE NUMBER: 8 fun case_8(value_1: _SealedClassMixed?): String = when(value_1) { _SealedMixedChildObject1 -> "" } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable Any. - DISCUSSION: maybe make exhaustive without else? + * TESTCASE NUMBER: 9 + * DISCUSSION: maybe make exhaustive without else? */ -fun case_10(value_1: Any?): String = when (value_1) { +fun case_9(value_1: Any?): String = when (value_1) { is Any -> "" null -> "" } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes). - DISCUSSION - ISSUES: KT-26044 + * TESTCASE NUMBER: 10 + * DISCUSSION + * ISSUES: KT-26044 */ -fun case_11(value: _SealedClassEmpty): String = when (value) {} +fun case_10(value: _SealedClassEmpty): String = when (value) {} diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.3.kt index ece11e6a51f..c1b5526dfdd 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.3.kt @@ -2,16 +2,16 @@ // !WITH_ENUM_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. - NUMBER: 3 - DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. + * NUMBER: 3 + * DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums. */ -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without null-check branch. +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass?): String = when(value_1) { _EnumClass.EAST -> "" _EnumClass.SOUTH -> "" @@ -19,7 +19,7 @@ fun case_1(value_1: _EnumClass?): String = when(value_1) { _EnumClass.WEST -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered. +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClass?): String = when(value_1) { _EnumClass.EAST -> "" _EnumClass.SOUTH -> "" @@ -27,20 +27,20 @@ fun case_2(value_1: _EnumClass?): String = when(value_1) { null -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered. +// TESTCASE NUMBER: 3 fun case_3(value_1: _EnumClass?): String = when(value_1) { _EnumClass.EAST, null, _EnumClass.SOUTH, _EnumClass.NORTH -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without branches. +// TESTCASE NUMBER: 4 fun case_4(value_1: _EnumClassSingle): Int = when(value_1) {} -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class (with only one value) without null-check branch. +// TESTCASE NUMBER: 5 fun case_5(value_1: _EnumClassSingle?): String = when(value_1) { _EnumClassSingle.EVERYTHING -> "" } -// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class (with only one value) with null-check branch, but value not covered. +// TESTCASE NUMBER: 6 fun case_6(value_1: _EnumClassSingle?): String = when(value_1) { null -> "" } diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.1.kt index 98a135422db..979a851b355 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.1.kt @@ -1,14 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [1] It has an else entry; - NUMBER: 1 - DESCRIPTION: Check when exhaustive via else entry (when without bound value). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [1] It has an else entry; + * NUMBER: 1 + * DESCRIPTION: Check when exhaustive via else entry (when without bound value). */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (several value check branches and 'else' branch). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String = when { value_1 == 0 -> "" value_1 > 0 && value_1 <= 10 -> "" @@ -17,13 +17,13 @@ fun case_1(value_1: Int): String = when { else -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch). +// TESTCASE NUMBER: 2 fun case_2(): String = when { true -> "" else -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch). +// TESTCASE NUMBER: 3 fun case_3(): String = when { else -> "" } \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.2.kt index 35f7ae49f56..e7321369c22 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.2.kt @@ -1,16 +1,16 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [1] It has an else entry; - NUMBER: 2 - DESCRIPTION: Check when exhaustive via else entry (when with bound value). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [1] It has an else entry; + * NUMBER: 2 + * DESCRIPTION: Check when exhaustive via else entry (when with bound value). */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (several branches). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String = when (value_1) { 0 -> "" 1 -> "" @@ -19,22 +19,22 @@ fun case_1(value_1: Int): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch). +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean): String = when (value_1) { true -> "" else -> "" } /* - CASE DESCRIPTION: Checking for exhaustive 'when' with constant bound value (value check branch and 'else' branch). - NOTE: for potential bound value constant analysis. + * TESTCASE NUMBER: 3 + * NOTE: for a potential bound value constant analysis. */ fun case_3(): String = when (true) { true -> "" else -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch). +// TESTCASE NUMBER: 4 fun case_4(value_1: Int): String = when(value_1) { else -> "" } \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.3.kt index 5c99de7f9e4..1530ab68a5f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.3.kt @@ -2,16 +2,16 @@ // !WITH_SEALED_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [1] It has an else entry; - NUMBER: 3 - DESCRIPTION: Check when exhaustive via else entry (when with bound value, redundant else). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [1] It has an else entry; + * NUMBER: 3 + * DESCRIPTION: Check when exhaustive via else entry (when with bound value, redundant else). */ -// CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values covered). +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass): String = when (value_1) { _EnumClass.EAST -> "" _EnumClass.NORTH -> "" @@ -20,7 +20,7 @@ fun case_1(value_1: _EnumClass): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values and null value covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClass?): String = when (value_1) { _EnumClass.EAST -> "" _EnumClass.NORTH -> "" @@ -30,14 +30,14 @@ fun case_2(value_1: _EnumClass?): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (both boolean value covered). +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean): String = when (value_1) { true -> "" false -> "" else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (both boolean value and null value covered). +// TESTCASE NUMBER: 4 fun case_4(value_1: Boolean?): String = when (value_1) { true -> "" false -> "" @@ -45,7 +45,7 @@ fun case_4(value_1: Boolean?): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (all sealed class subtypes covered). +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClass): String = when (value_1) { is _SealedChild1 -> "" is _SealedChild2 -> "" @@ -53,7 +53,7 @@ fun case_5(value_1: _SealedClass): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (all sealed class subtypes and null value covered). +// TESTCASE NUMBER: 6 fun case_6(value_1: _SealedClass?): String = when (value_1) { is _SealedChild1 -> "" is _SealedChild2 -> "" @@ -62,13 +62,13 @@ fun case_6(value_1: _SealedClass?): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (sealed class itself covered). +// TESTCASE NUMBER: 7 fun case_7(value_1: _SealedClassSingle): String = when (value_1) { is _SealedClassSingle -> "" else -> "" } -// CASE DESCRIPTION: Checking for redundant 'else' branch (sealed class itself and null value covered). +// TESTCASE NUMBER: 8 fun case_8(value_1: _SealedClassSingle?): String = when (value_1) { is _SealedClassSingle -> "" null -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/3.1.kt index f37a1a1e588..e6414bf5355 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/3.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/3.1.kt @@ -1,20 +1,20 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: - NUMBER: 1 - DESCRIPTION: Check when exhaustive via boolean bound value and evaluating to value true and false. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: + * NUMBER: 1 + * DESCRIPTION: Check when exhaustive via boolean bound value and evaluating to value true and false. */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value covered). +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean): String = when (value_1) { true -> "" false -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value as complex expression covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean): String = when (value_1) { true && false && ((true || false)) || true && !!!false && !!!true -> "" true && false && ((true || false)) || true && !!!false -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/6.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/6.1.kt index 8f909712253..000cee7bf41 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/6.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/6.1.kt @@ -2,42 +2,42 @@ // !WITH_SEALED_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession; - NUMBER: 1 - DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession; + * NUMBER: 1 + * DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered. */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes covered). +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass): Int = when (value_1) { is _SealedChild1 -> value_1.number is _SealedChild2 -> value_1.e1 + value_1.e2 is _SealedChild3 -> value_1.m1 + value_1.m2 } -// CASE DESCRIPTION: Checking for exhaustive 'when' (single sealed class subtypes covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClass): String = when (value_1) { is _SealedClass -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes with methods covered). +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClassWithMethods): String = when (value_1) { is _SealedWithMethodsChild1 -> value_1.m1() is _SealedWithMethodsChild2 -> value_1.m2() is _SealedWithMethodsChild3 -> value_1.m3() } -// CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator). +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClassWithObjects): String = when (value_1) { _SealedWithObjectsChild1 -> "" _SealedWithObjectsChild2 -> "" _SealedWithObjectsChild3 -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered). +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClassMixed): String = when (value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" @@ -48,8 +48,8 @@ fun case_5(value_1: _SealedClassMixed): String = when (value_1) { } /* - CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered). - DISCUSSION: is it correct that objects can be checked using the type checking operator? + * TESTCASE NUMBER: 6 + * DISCUSSION: is it correct that objects can be checked using the type checking operator? */ fun case_6(value_1: _SealedClassMixed): String = when (value_1) { is _SealedMixedChild1 -> "" @@ -60,24 +60,24 @@ fun case_6(value_1: _SealedClassMixed): String = when (value_1) { is _SealedMixedChildObject3 -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' on the empty sealed class (without subtypes). +// TESTCASE NUMBER: 7 fun case_7(value_1: _SealedClassEmpty): String = when (value_1) { else -> "" } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types. - UNEXPECTED BEHAVIOUR: must be exhaustive - ISSUES: KT-22996 + * TESTCASE NUMBER: 8 + * UNEXPECTED BEHAVIOUR: must be exhaustive + * ISSUES: KT-22996 */ fun case_8(value: _SealedClass?): String = when (value) { is _SealedChild1, !is _SealedChild3?, is _SealedChild3? -> "" } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types. - UNEXPECTED BEHAVIOUR: must be exhaustive - ISSUES: KT-22996 + * TESTCASE NUMBER: 9 + * UNEXPECTED BEHAVIOUR: must be exhaustive + * ISSUES: KT-22996 */ fun case_9(value: _SealedClass?): String = when (value) { is _SealedChild1, !is _SealedChild3 -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/7.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/7.1.kt index d87fa06de19..737af95bba0 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/7.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/7.1.kt @@ -1,16 +1,16 @@ // !WITH_ENUM_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; - NUMBER: 1 - DESCRIPTION: Check when exhaustive when all enumerated values are checked. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; + * NUMBER: 1 + * DESCRIPTION: Check when exhaustive when all enumerated values are checked. */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (all enum values covered). +// TESTCASE NUMBER: 1 fun case_1(dir: _EnumClass): String = when (dir) { _EnumClass.EAST -> "" _EnumClass.NORTH -> "" @@ -18,7 +18,7 @@ fun case_1(dir: _EnumClass): String = when (dir) { _EnumClass.WEST -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClassSingle): String = when (value_1) { _EnumClassSingle.EVERYTHING -> "" } diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.1.kt index 70064a771e5..3ed5fcc0150 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.1.kt @@ -1,21 +1,21 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. - NUMBER: 1 - DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. + * NUMBER: 1 + * DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check. */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values and null value covered). +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean?): String = when (value_1) { true -> "" false -> "" null -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values as complex expressions and null value covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean?): String = when (value_1) { true && false && ((true || false)) || true && !!!false && !!!true -> "" true && false && ((true || false)) || true && !!!false -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.2.kt index c6a87649dcb..b3ac72b6b38 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.2.kt @@ -1,16 +1,16 @@ // !WITH_ENUM_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. - NUMBER: 2 - DESCRIPTION: Check when exhaustive when enumerated values are checked and contains a null check. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. + * NUMBER: 2 + * DESCRIPTION: Check when exhaustive when enumerated values are checked and contains a null check. */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (both enum values and null value covered). +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass?): String = when (value_1) { _EnumClass.EAST -> "" _EnumClass.NORTH -> "" @@ -19,16 +19,16 @@ fun case_1(value_1: _EnumClass?): String = when (value_1) { null -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value and null value covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClassSingle?): String = when (value_1) { _EnumClassSingle.EVERYTHING -> "" null -> "" } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable enum class. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26044 + * TESTCASE NUMBER: 3 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26044 */ fun case_3(value_1: _EnumClassEmpty?): String = when(value_1) { null -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.3.kt index 2225144d12d..b1df4252fa0 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.3.kt @@ -1,16 +1,16 @@ // !WITH_SEALED_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 11 - SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. - NUMBER: 3 - DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 11 + * SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. + * NUMBER: 3 + * DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check. */ -// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes and null value covered). +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass?): Int = when (value_1) { is _SealedChild1 -> value_1.number is _SealedChild2 -> value_1.e1 + value_1.e2 @@ -18,13 +18,13 @@ fun case_1(value_1: _SealedClass?): Int = when (value_1) { null -> 0 } -// CASE DESCRIPTION: Checking for exhaustive 'when' (sealed class itself and null value covered). +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClass?): String = when (value_1) { is _SealedClass -> "" null -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class with methods subtypes and null value covered). +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) { is _SealedWithMethodsChild1 -> value_1.m1() is _SealedWithMethodsChild2 -> value_1.m2() @@ -32,7 +32,7 @@ fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) { null -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator and null value covered). +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) { _SealedWithObjectsChild1 -> "" _SealedWithObjectsChild2 -> "" @@ -40,7 +40,7 @@ fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) { null -> "" } -// CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered + null value covered). +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClassMixed?): String = when (value_1) { is _SealedMixedChild1 -> "" is _SealedMixedChild2 -> "" @@ -52,8 +52,8 @@ fun case_5(value_1: _SealedClassMixed?): String = when (value_1) { } /* - CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered + null value covered). - DISCUSSION: is it correct that objects can be checked using the type checking operator? + * TESTCASE NUMBER: 6 + * DISCUSSION: is it correct that objects can be checked using the type checking operator? */ fun case_6(value_1: _SealedClassMixed?): String = when (value_1) { is _SealedMixedChild1 -> "" @@ -66,9 +66,9 @@ fun case_6(value_1: _SealedClassMixed?): String = when (value_1) { } /* - CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable sealed class (without subtypes). - UNEXPECTED BEHAVIOUR: must be exhaustive - ISSUES: KT-26044 + * TESTCASE NUMBER: 7 + * UNEXPECTED BEHAVIOUR: must be exhaustive + * ISSUES: KT-26044 */ fun case_7(value: _SealedClassEmpty?): String = when (value) { null -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.1.kt index f48e4312c3e..22b9260cdd1 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.1.kt @@ -1,13 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 2 - SENTENCE: [3] When expression has two different forms: with bound value and without it. - NUMBER: 1 - DESCRIPTION: Empty 'when' with bound value. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 2 + * SENTENCE: [3] When expression has two different forms: with bound value and without it. + * NUMBER: 1 + * DESCRIPTION: Empty 'when' with bound value. */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Int) { when (value_1) {} } diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.2.kt index 98c48c8e754..2b95cb47378 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.2.kt @@ -1,13 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 2 - SENTENCE: [3] When expression has two different forms: with bound value and without it. - NUMBER: 2 - DESCRIPTION: Empty 'when' without bound value. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 2 + * SENTENCE: [3] When expression has two different forms: with bound value and without it. + * NUMBER: 2 + * DESCRIPTION: Empty 'when' without bound value. */ +// TESTCASE NUMBER: 1 fun case_1() { when {} } diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/1.1.kt index 9b8a3c7dba4..73263a8dd5e 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/1.1.kt @@ -1,14 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry. - NUMBER: 1 - DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry. + * NUMBER: 1 + * DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body. */ -// CASE DESCRIPTION: 'When' with break expression (without label). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String { while (true) { when { @@ -19,7 +19,7 @@ fun case_1(value_1: Int): String { return "" } -// CASE DESCRIPTION: 'When' with continue expression (without label). +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String { while (true) { when { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.1.kt index f47c05d806d..3696a52f1c5 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.1.kt @@ -1,15 +1,16 @@ // !WITH_BASIC_TYPES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. - NUMBER: 1 - DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. + * NUMBER: 1 + * DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'. */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: String, value_3: _BasicTypesProvider): String { when { .012f / value_1 -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.2.kt index f08d4ad618e..c52a7500865 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.2.kt @@ -1,15 +1,16 @@ // !WITH_BASIC_TYPES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. - NUMBER: 2 - DESCRIPTION: 'When' without bound value and not allowed comma in when entry. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. + * NUMBER: 2 + * DESCRIPTION: 'When' without bound value and not allowed comma in when entry. */ +// TESTCASE NUMBER: 1 fun case_1(value_1: _BasicTypesProvider) { when { getBoolean(), value_1.getBoolean() -> return diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/1.1.kt index d8071a1e725..3e34de89fe4 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/1.1.kt @@ -4,16 +4,16 @@ // !WITH_FUNCTIONS /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry. - NUMBER: 1 - DESCRIPTION: 'When' without bound value and with different variants of expressions in the control structure body. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry. + * NUMBER: 1 + * DESCRIPTION: 'When' without bound value and with different variants of expressions in the control structure body. */ -// CASE DESCRIPTION: 'When' with control structure body as literals. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int) { when { value_1 == 1 -> true @@ -25,7 +25,7 @@ fun case_1(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) { when { value_1 == 1 -> -.09 % 10L @@ -34,7 +34,7 @@ fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) { } } -// CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison). +// TESTCASE NUMBER: 3 fun case_3(value_1: Int, value_2: Boolean, value_3: Long) { when { value_1 == 1 -> value_2 @@ -46,7 +46,7 @@ fun case_3(value_1: Int, value_2: Boolean, value_3: Long) { } } -// CASE DESCRIPTION: 'When' with control structure body as concatenations. +// TESTCASE NUMBER: 4 fun case_4(value_1: Int, value_2: String, value_3: String) { when { value_1 == 1 -> "..." + value_2 + "" + "$value_3" + "..." @@ -54,7 +54,7 @@ fun case_4(value_1: Int, value_2: String, value_3: String) { } } -// CASE DESCRIPTION: 'When' with control structure body as when expression. +// TESTCASE NUMBER: 5 fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { when { value_1 == 1 -> when { @@ -80,7 +80,7 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { } } -// CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive). +// TESTCASE NUMBER: 6 fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when { value_1 == 1 -> when { value_2 > 1000 -> 1 @@ -94,7 +94,7 @@ fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when { } } -// CASE DESCRIPTION: 'When' with control structure body as if expression. +// TESTCASE NUMBER: 7 fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) { when { value_1 == 1 -> if (value_2 > 1000) "1" @@ -109,7 +109,7 @@ fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) { } } -// CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive). +// TESTCASE NUMBER: 8 fun case_8(value_1: Int, value_2: Int) = when { value_1 == 1 -> if (value_2 > 1000) "1" else "2" @@ -118,14 +118,14 @@ fun case_8(value_1: Int, value_2: Int) = when { else "4" } -// CASE DESCRIPTION: 'When' with control structure body as try expression. +// TESTCASE NUMBER: 9 fun case_9(value_1: Int, value_2: String, value_3: String) = when { value_1 == 1 -> try { 4 } catch (e: Exception) { 5 } value_1 == 2 -> try { throw Exception() } catch (e: Exception) { value_2 } else -> try { throw Exception() } catch (e: Exception) { {value_3} } finally { } } -// CASE DESCRIPTION: 'When' with control structure body as elvis operator expression. +// TESTCASE NUMBER: 10 fun case_10(value_1: Int, value_2: String?, value_3: String?) { when { value_1 == 1 -> value_2 ?: true @@ -134,7 +134,7 @@ fun case_10(value_1: Int, value_2: String?, value_3: String?) { } } -// CASE DESCRIPTION: 'When' with control structure body as range expression. +// TESTCASE NUMBER: 11 fun case_11(value_1: Int) { when { value_1 == 1 -> 1..10 @@ -143,7 +143,7 @@ fun case_11(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as cast expression. +// TESTCASE NUMBER: 12 fun case_12(value_1: Int, value_2: Collection, value_3: Collection?) { when { value_1 == 1 -> value_2 as MutableList @@ -153,7 +153,7 @@ fun case_12(value_1: Int, value_2: Collection, value_3: Collection?) { } } -// CASE DESCRIPTION: 'When' with control structure body as prefix operator expression. +// TESTCASE NUMBER: 13 fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) { var mutablevalue_2 = value_2 var mutablevalue_3 = value_3 @@ -165,7 +165,7 @@ fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) { } } -// CASE DESCRIPTION: 'When' with control structure body as postfix operator expression. +// TESTCASE NUMBER: 14 fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) { var mutablevalue_2 = value_2 var mutablevalue_3 = value_3 @@ -177,7 +177,7 @@ fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) { } } -// CASE DESCRIPTION: 'When' with control structure body as indexing expression. +// TESTCASE NUMBER: 15 fun case_15(value_1: Int, value_2: List, value_3: List>>>) { when { value_1 == 1 -> value_2[0] @@ -185,7 +185,7 @@ fun case_15(value_1: Int, value_2: List, value_3: List> } } -// CASE DESCRIPTION: 'When' with control structure body as call expression. +// TESTCASE NUMBER: 16 fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) { fun __fun_1(): () -> Unit { return fun() { } } @@ -198,7 +198,7 @@ fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as property access expression. +// TESTCASE NUMBER: 17 fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) { when { value_1 == 1 -> value_2.prop_1 @@ -208,7 +208,7 @@ fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) { } } -// CASE DESCRIPTION: 'When' with control structure body as fun literal. +// TESTCASE NUMBER: 18 fun case_18(value_1: Int) { val fun_1 = fun(): Int { return 0 } @@ -220,7 +220,7 @@ fun case_18(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as lambda literal. +// TESTCASE NUMBER: 19 fun case_19(value_1: Int): () -> Any { val lambda_1 = { 0 } @@ -233,7 +233,7 @@ fun case_19(value_1: Int): () -> Any { } } -// CASE DESCRIPTION: 'When' with control structure body as object literal. +// TESTCASE NUMBER: 20 fun case_20(value_1: Int) { val object_1 = object { val prop_1 = 1 @@ -249,7 +249,7 @@ fun case_20(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as this expression. +// TESTCASE NUMBER: 21 class A { val prop_1 = 1 val lambda_1 = { 1 } @@ -269,7 +269,7 @@ class A { } } -// CASE DESCRIPTION: 'When' with control structure body as throw expression. +// TESTCASE NUMBER: 22 fun case_22(value_1: Int) { when { value_1 == 1 -> throw Exception() @@ -277,7 +277,7 @@ fun case_22(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as return expression. +// TESTCASE NUMBER: 23 fun case_23(value_1: Int) { fun r_1() { when { @@ -296,7 +296,7 @@ fun case_23(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as continue expression. +// TESTCASE NUMBER: 24 fun case_24(value_1: Int) { loop1@ while (true) { loop2@ while (true) { @@ -308,7 +308,7 @@ fun case_24(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as break expression. +// TESTCASE NUMBER: 25 fun case_25(value_1: Int) { loop1@ while (true) { loop2@ while (true) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.1.kt index 93326b2bd03..ae391636c23 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.1.kt @@ -3,16 +3,16 @@ // !WITH_ENUM_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. - NUMBER: 1 - DESCRIPTION: 'When' without bound value and different variants of the boolean conditions (logical, equality, comparison, type checking operator, containment operator). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. + * NUMBER: 1 + * DESCRIPTION: 'When' without bound value and different variants of the boolean conditions (logical, equality, comparison, type checking operator, containment operator). */ -// CASE DESCRIPTION: 'When' with boolean expressions and else branch. +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean, value_2: Long): Int { return when { value_1 -> 1 @@ -26,8 +26,8 @@ fun case_1(value_1: Boolean, value_2: Long): Int { } /* - CASE DESCRIPTION: 'When' with boolean expressions. - NOTE: for potential analysys on exhaustive by enum of when without bound value. + * TESTCASE NUMBER: 2 + * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value. */ fun case_2(value_1: _EnumClass) { when { @@ -39,8 +39,8 @@ fun case_2(value_1: _EnumClass) { } /* - CASE DESCRIPTION: 'When' with boolean expressions. - NOTE: for potential analysys on exhaustive by boolean of when without bound value. + * TESTCASE NUMBER: 3 + * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value. */ fun case_3(value_1: Boolean) { when { @@ -50,8 +50,8 @@ fun case_3(value_1: Boolean) { } /* - CASE DESCRIPTION: 'When' with boolean literals. - NOTE: for potential mark code after true branch as unreacable. + * TESTCASE NUMBER: 4 + * NOTE: for a potential mark the code after the true branch as unreacable. */ fun case_4(value_1: Boolean) { when { @@ -62,8 +62,8 @@ fun case_4(value_1: Boolean) { } /* - CASE DESCRIPTION: 'When' with boolean constants. - NOTE: for potential const propagation use in this case. + * TESTCASE NUMBER: 5 + * NOTE: for a potential const propagation. */ fun case_5(value_1: Boolean) { val value_2 = false @@ -76,7 +76,7 @@ fun case_5(value_1: Boolean) { } } -// CASE DESCRIPTION: 'When' with type checking operator. +// TESTCASE NUMBER: 6 fun case_6(value_1: Any) { when { value_1 is Nothing -> {} @@ -90,8 +90,8 @@ fun case_6(value_1: Any) { } /* - CASE DESCRIPTION: 'When' with invert type checking operator. - NOTE: for potential analysys on exhaustive of when without bound value_1. + * TESTCASE NUMBER: 7 + * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value. */ fun case_7(value_1: Any) { when { @@ -103,8 +103,8 @@ fun case_7(value_1: Any) { } /* - CASE DESCRIPTION: 'When' with type checking operator by sealed class. - NOTE: for potential analysys on exhaustive by sealed class of when without bound value_1. + * TESTCASE NUMBER: 8 + * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value. */ fun case_8(value_1: _SealedClass) { when { @@ -114,7 +114,7 @@ fun case_8(value_1: _SealedClass) { } } -// CASE DESCRIPTION: 'When' with containment operator. +// TESTCASE NUMBER: 9 fun case_9(value_1: Int, value_2: IntRange) { when { value_1 in -10..100L -> {} diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.2.kt index 1e87de7a6cf..ea4df2b7b1f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.2.kt @@ -1,19 +1,19 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. - NUMBER: 2 - DESCRIPTION: 'When' without bound value and only one 'else' branch. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. + * NUMBER: 2 + * DESCRIPTION: 'When' without bound value and only one 'else' branch. */ -// CASE DESCRIPTION: 'When' as expression with only one 'else' branch. +// TESTCASE NUMBER: 1 fun case_1() = when { else -> "" } -// CASE DESCRIPTION: 'When' as statement with only one 'else' branch. +// TESTCASE NUMBER: 2 fun case_2(): String { when { else -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.3.kt index 84beea6b1d5..12afa7771d0 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.3.kt @@ -1,18 +1,18 @@ // !WITH_BASIC_TYPES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 3 - SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. - NUMBER: 3 - DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean). - DISCUSSION - ISSUES: KT-25948 + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 3 + * SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. + * NUMBER: 3 + * DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean). + * DISCUSSION + * ISSUES: KT-25948 */ -// CASE DESCRIPTION: 'When' with return expression in condition. +// TESTCASE NUMBER: 1 fun case_1(value_1: _BasicTypesProvider) { when { return -> return @@ -23,7 +23,7 @@ fun case_1(value_1: _BasicTypesProvider) { } } -// CASE DESCRIPTION: 'When' with throw expression in condition. +// TESTCASE NUMBER: 2 fun case_2(value_1: _BasicTypesProvider) { when { throw Exception() -> return @@ -34,7 +34,7 @@ fun case_2(value_1: _BasicTypesProvider) { } } -// CASE DESCRIPTION: 'When' with break expression in condition. +// TESTCASE NUMBER: 3 fun case_3(value_1: _BasicTypesProvider) { loop1@ while (true) { loop2@ while (true) { @@ -49,7 +49,7 @@ fun case_3(value_1: _BasicTypesProvider) { } } -// CASE DESCRIPTION: 'When' with continue expression in condition. +// TESTCASE NUMBER: 4 fun case_4(value_1: _BasicTypesProvider): String { loop1@ while (true) { loop2@ while (true) { @@ -64,7 +64,7 @@ fun case_4(value_1: _BasicTypesProvider): String { } } -// CASE DESCRIPTION: 'When' with values of Nothing type. +// TESTCASE NUMBER: 6 fun case_6(value_1: Nothing, value_2: _BasicTypesProvider): String { when { value_1 -> return "" @@ -76,7 +76,7 @@ fun case_6(value_1: Nothing, value_2: _BasicTypesProvider return "" } -// CASE DESCRIPTION: 'When' with mixed Nothing expression in condition. +// TESTCASE NUMBER: 5 fun case_5(value_1: _BasicTypesProvider, value_2: Nothing) { loop1@ while (true) { loop2@ while (true) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg/1.1.kt index 8103358f061..91fe31595ae 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg/1.1.kt @@ -1,27 +1,27 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 5 - SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated. - NUMBER: 1 - DESCRIPTION: 'When' without bound value and with 'else' branch not in the last position. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 5 + * SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated. + * NUMBER: 1 + * DESCRIPTION: 'When' without bound value and with 'else' branch not in the last position. */ -// CASE DESCRIPTION: 'When' with 'else' branch in the first position. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String = when { else -> "" value_1 == 1 -> "" } -// CASE DESCRIPTION: 'When' with 'else' branch in the middle position. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String = when { value_1 == 1 -> "" else -> "" value_1 == 2 -> "" } -// CASE DESCRIPTION: 'When' with two 'else' branches. +// TESTCASE NUMBER: 3 fun case_3(): String { when { else -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos/1.1.kt index beda52d25c5..1b8c30d0b2c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos/1.1.kt @@ -1,14 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 5 - SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated. - NUMBER: 1 - DESCRIPTION: 'When' without bound value and with else branch in the last position. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 5 + * SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated. + * NUMBER: 1 + * DESCRIPTION: 'When' without bound value and with else branch in the last position. */ -// CASE DESCRIPTION: 'When' with else branch as statement +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String { when { value_1 == 1 -> return "" @@ -17,7 +17,7 @@ fun case_1(value_1: Int): String { } } -// CASE DESCRIPTION: 'When' with else branch as expression +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String = when { value_1 == 1 -> "" value_1 == 2 -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg/1.1.kt index e4a65f865c9..29760b9724c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg/1.1.kt @@ -1,14 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 6 - SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in the control structure body. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 6 + * SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in the control structure body. */ -// CASE DESCRIPTION: 'When' with break expression (without label). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): Int { while (true) { when (value_1) { @@ -20,7 +20,7 @@ fun case_1(value_1: Int): Int { return 0 } -// CASE DESCRIPTION: 'When' with continue expression (without label). +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): Int { while (true) { when (value_1) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos/1.1.kt index 050414e9411..5c7107d5592 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos/1.1.kt @@ -4,16 +4,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 6 - SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and with different variants of expressions in the control structure body. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 6 + * SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and with different variants of expressions in the control structure body. */ -// CASE DESCRIPTION: 'When' with control structure body as literals. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int) { when (value_1) { 1 -> true @@ -25,7 +25,7 @@ fun case_1(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) { when (value_1) { 1 -> -.09 % 10L @@ -35,7 +35,7 @@ fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) { } } -// CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison). +// TESTCASE NUMBER: 3 fun case_3(value_1: Int, value_2: Boolean, value_3: Long) { when (value_1) { 1 -> value_2 @@ -47,7 +47,7 @@ fun case_3(value_1: Int, value_2: Boolean, value_3: Long) { } } -// CASE DESCRIPTION: 'When' with control structure body as concatenations. +// TESTCASE NUMBER: 4 fun case_4(value_1: Int, value_2: String, value_3: String) { when (value_1) { 1 -> "..." + value_2 + "" + "$value_3" + "..." @@ -55,7 +55,7 @@ fun case_4(value_1: Int, value_2: String, value_3: String) { } } -// CASE DESCRIPTION: 'When' with control structure body as when expression. +// TESTCASE NUMBER: 5 fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { when (value_1) { 1 -> when (value_3) { @@ -81,7 +81,7 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { } } -// CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive). +// TESTCASE NUMBER: 6 fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when (value_1) { 1 -> when (value_3) { value_2 > 1000 -> 1 @@ -95,7 +95,7 @@ fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when (value_1) { } } -// CASE DESCRIPTION: 'When' with control structure body as if expression. +// TESTCASE NUMBER: 7 fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) { when (value_1) { 1 -> if (value_2 > 1000) "1" @@ -110,7 +110,7 @@ fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) { } } -// CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive). +// TESTCASE NUMBER: 8 fun case_8(value_1: Int, value_2: Int) = when (value_1) { 1 -> if (value_2 > 1000) "1" else "2" @@ -119,7 +119,7 @@ fun case_8(value_1: Int, value_2: Int) = when (value_1) { else "4" } -// CASE DESCRIPTION: 'When' with control structure body as try expression. +// TESTCASE NUMBER: 9 fun case_9(value_1: Int, value_2: String, value_3: String): Any { return when (value_1) { 1 -> try { 4 } catch (e: Exception) { 5 } @@ -128,7 +128,7 @@ fun case_9(value_1: Int, value_2: String, value_3: String): Any { } } -// CASE DESCRIPTION: 'When' with control structure body as elvis operator expression. +// TESTCASE NUMBER: 10 fun case_10(value_1: Int, value_2: String?, value_3: String?) { when (value_1) { 1 -> value_2 ?: true @@ -137,7 +137,7 @@ fun case_10(value_1: Int, value_2: String?, value_3: String?) { } } -// CASE DESCRIPTION: 'When' with control structure body as range expression. +// TESTCASE NUMBER: 11 fun case_11(value_1: Int) { when (value_1) { 1 -> 1..10 @@ -146,7 +146,7 @@ fun case_11(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as cast expression. +// TESTCASE NUMBER: 12 fun case_12(value_1: Int, value_2: Collection, value_3: Collection?) { when (value_1) { 1 -> value_2 as MutableList @@ -156,7 +156,7 @@ fun case_12(value_1: Int, value_2: Collection, value_3: Collection?) { } } -// CASE DESCRIPTION: 'When' with control structure body as prefix operator expression. +// TESTCASE NUMBER: 13 fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) { var mutableValue1 = value_2 var mutableValue2 = value_3 @@ -168,7 +168,7 @@ fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) { } } -// CASE DESCRIPTION: 'When' with control structure body as postfix operator expression. +// TESTCASE NUMBER: 14 fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) { var mutableValue1 = value_2 var mutableValue2 = value_3 @@ -180,7 +180,7 @@ fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) { } } -// CASE DESCRIPTION: 'When' with control structure body as indexing expression. +// TESTCASE NUMBER: 15 fun case_15(value_1: Int, value_2: List, value_3: List>>>) { when (value_1) { 1 -> value_2[0] @@ -188,7 +188,7 @@ fun case_15(value_1: Int, value_2: List, value_3: List> } } -// CASE DESCRIPTION: 'When' with control structure body as call expression. +// TESTCASE NUMBER: 16 fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) { fun __fun_1(): () -> Unit { return fun() { } } @@ -201,7 +201,7 @@ fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as property access expression. +// TESTCASE NUMBER: 17 fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) { when (value_1) { 1 -> value_2.prop_1 @@ -211,7 +211,7 @@ fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) { } } -// CASE DESCRIPTION: 'When' with control structure body as fun literal. +// TESTCASE NUMBER: 18 fun case_18(value_1: Int) { val fun_1 = fun(): Int { return 0 } @@ -223,7 +223,7 @@ fun case_18(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as lambda literal. +// TESTCASE NUMBER: 19 fun case_19(value_1: Int): Any { val lambda_1 = { 0 } @@ -236,7 +236,7 @@ fun case_19(value_1: Int): Any { } } -// CASE DESCRIPTION: 'When' with control structure body as object literal. +// TESTCASE NUMBER: 20 fun case_20(value_1: Int) { val object_1 = object { val prop_1 = 1 @@ -252,7 +252,7 @@ fun case_20(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as this expression. +// TESTCASE NUMBER: 21 class A { val prop_1 = 1 val lambda_1 = { 1 } @@ -272,7 +272,7 @@ class A { } } -// CASE DESCRIPTION: 'When' with control structure body as throw expression. +// TESTCASE NUMBER: 22 fun case_22(value_1: Int) { when (value_1) { 1 -> throw Exception() @@ -280,7 +280,7 @@ fun case_22(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as return expression. +// TESTCASE NUMBER: 23 fun case_23(value_1: Int) { fun r_1() { when (value_1) { @@ -299,7 +299,7 @@ fun case_23(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as continue expression. +// TESTCASE NUMBER: 24 fun case_24(value_1: Int) { loop1@ while (true) { loop2@ while (true) { @@ -311,7 +311,7 @@ fun case_24(value_1: Int) { } } -// CASE DESCRIPTION: 'When' with control structure body as break expression. +// TESTCASE NUMBER: 25 fun case_25(value_1: Int) { loop1@ while (true) { loop2@ while (true) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.1.kt index eddd68f7359..985ddb11723 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.1.kt @@ -1,16 +1,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [1] Type test condition: type checking operator followed by type. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and type test condition (without companion object in classes), but without type checking operator. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [1] Type test condition: type checking operator followed by type. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and type test condition (without companion object in classes), but without type checking operator. */ -// CASE DESCRIPTION: 'When' with custom class type test condition. +// TESTCASE NUMBER: 1 fun case_1(value_1: Any): String { when (value_1) { _EmptyClass -> return "" @@ -19,7 +19,7 @@ fun case_1(value_1: Any): String { return "" } -// CASE DESCRIPTION: 'When' with Any type test condition. +// TESTCASE NUMBER: 2 fun case_2(value_1: Any): String { when (value_1) { Any -> return "" @@ -28,7 +28,7 @@ fun case_2(value_1: Any): String { return "" } -// CASE DESCRIPTION: 'When' with Nothing type test condition. +// TESTCASE NUMBER: 3 fun case_3(value_1: Any): String { when (value_1) { Nothing -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.2.kt index 101797376b8..1c24cb8c109 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.2.kt @@ -1,15 +1,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [1] Type test condition: type checking operator followed by type. - NUMBER: 2 - DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [1] Type test condition: type checking operator followed by type. + * NUMBER: 2 + * DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator. */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Any, value_2: Int): String { when (value_1) { is value_2 -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.1.kt index f2eb648ed2e..5684c78192b 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.1.kt @@ -1,15 +1,16 @@ // !WITH_BASIC_TYPES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [3] Contains test condition: containment operator followed by an expression. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [3] Contains test condition: containment operator followed by an expression. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator. */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: _BasicTypesProvider): String { when (value_1) { -1000L..100 -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.2.kt index 643342aaf92..4aecb70f5d8 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.2.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [3] Contains test condition: containment operator followed by an expression. - NUMBER: 2 - DESCRIPTION: 'When' with bound value and 'when condition' with contains operator and type without defined contains operator. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [3] Contains test condition: containment operator followed by an expression. + * NUMBER: 2 + * DESCRIPTION: 'When' with bound value and 'when condition' with contains operator and type without defined contains operator. */ -// CASE DESCRIPTION: 'When' with values of types without defined contains operator. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: _EmptyClass, value_3: Int, value_4: Any): String { when (value_1) { in value_2 -> return "" @@ -23,9 +23,9 @@ fun case_1(value_1: Int, value_2: _EmptyClass, value_3: Int, value_4: Any): Stri } /* - CASE DESCRIPTION: 'When' with values of Nothing (all existing contains operators used here). - DISCUSSION - ISSUES: KT-25948 + * TESTCASE NUMBER: 2 + * DISCUSSION + * ISSUES: KT-25948 */ fun case_2(value_1: Int, value_3: Nothing) { when (value_1) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.1.kt index 29ca1ac31e1..b06541783b0 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.1.kt @@ -1,16 +1,16 @@ // !DIAGNOSTICS: -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [5] Any other expression. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and non-expressions in 'when condition'. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [5] Any other expression. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and non-expressions in 'when condition'. */ -// CASE DESCRIPTION: 'When' with cycles in when condition. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: List): String { when (value_1) { while (false) {} -> return "" @@ -21,7 +21,7 @@ fun case_1(value_1: Int, value_2: List): String { return "" } -// CASE DESCRIPTION: 'When' with assignments in when condition. +// TESTCASE NUMBER: 4 fun case_4(value_1: Int): String { var value_2: Int var value_3 = 10 diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.2.kt index 491c00981f2..c75b2373ce7 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.2.kt @@ -1,14 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [5] Any other expression. - NUMBER: 2 - DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in 'when condition'. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [5] Any other expression. + * NUMBER: 2 + * DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in 'when condition'. */ -// CASE DESCRIPTION: 'When' with break expression (without label). +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String { while (true) { when (value_1) { @@ -19,7 +19,7 @@ fun case_1(value_1: Int): String { return "" } -// CASE DESCRIPTION: 'When' with continue expression (without label). +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String { while (true) { when (value_1) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/7.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/7.1.kt index 86576916b45..8261ef1ce4c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/7.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/7.1.kt @@ -1,29 +1,29 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and with else branch not in the last position. + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and with else branch not in the last position. */ -// CASE DESCRIPTION: 'When' with 'else' branch in the first position. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String = when (value_1) { else -> "" 1 -> "" } -// CASE DESCRIPTION: 'When' with 'else' branch in the middle position. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String = when (value_1) { 1 -> "" else -> "" 2 -> "" } -// CASE DESCRIPTION: 'When' with two 'else' branches. +// TESTCASE NUMBER: 3 fun case_3(value_1: Int): String { when (value_1) { else -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.1.kt index cd4ea91f282..07072bd9190 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.1.kt @@ -2,16 +2,16 @@ // !WITH_OBJECTS /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [1] Type test condition: type checking operator followed by type. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and type test condition. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [1] Type test condition: type checking operator followed by type. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and type test condition. */ -// CASE DESCRIPTION: 'When' with type test condition on the various basic types. +// TESTCASE NUMBER: 1 fun case_1(value_1: Any): String { when (value_1) { is Int -> return "" @@ -25,29 +25,29 @@ fun case_1(value_1: Any): String { return "" } -// CASE DESCRIPTION: 'When' with type test condition on the various nullable basic types. +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?): String = when (value_1) { is Int? -> "" // if value is null then this branch will be executed is Float -> "" else -> "" } -// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on Any. +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?): String = when (value_1) { is Any -> "" else -> "" } -// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on nullable (redundant) Any. +// TESTCASE NUMBER: 4 fun case_4(value_1: Any): String = when (value_1) { is Any? -> "" else -> "" } /* - CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check). - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 5 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_5(value_1: Any?): String = when (value_1) { is Double -> "" @@ -59,7 +59,7 @@ fun case_5(value_1: Any?): String = when (value_1) { else -> "" } -// CASE DESCRIPTION: 'When' with type test condition on the objetcs. +// TESTCASE NUMBER: 6 fun case_6(value_1: Any): String { when (value_1) { is _EmptyObject -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.2.kt index c40cc7e7dd8..85522debcd7 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.2.kt @@ -3,16 +3,16 @@ // !WITH_OBJECTS /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [1] Type test condition: type checking operator followed by type. - NUMBER: 2 - DESCRIPTION: 'When' with bound value and type test condition (invert type checking operator). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [1] Type test condition: type checking operator followed by type. + * NUMBER: 2 + * DESCRIPTION: 'When' with bound value and type test condition (invert type checking operator). */ -// CASE DESCRIPTION: 'When' in which all branches includes invert type checking operators. +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass) = when (value_1) { !is _SealedChild1 -> {} !is _SealedChild2 -> {} @@ -20,9 +20,9 @@ fun case_1(value_1: _SealedClass) = when (value_1) { } /* - CASE DESCRIPTION: 'When' with direct and invert (with null-check) type checking operators on the same types and redundant null-check. - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_2(value_1: _SealedClass?): String = when (value_1) { !is _SealedChild2 -> "" // including null @@ -30,7 +30,7 @@ fun case_2(value_1: _SealedClass?): String = when (value_1) { null -> "" // redundant } -// CASE DESCRIPTION: 'When' with direct and invert type checking operators on the same types and null-check. +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClass?): String = when (value_1) { !is _SealedChild2? -> "" // null isn't included is _SealedChild2 -> "" @@ -38,9 +38,9 @@ fun case_3(value_1: _SealedClass?): String = when (value_1) { } /* - CASE DESCRIPTION: 'When' with direct and invert (with null-check) type checking operators on the same types. - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 4 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_4(value_1: _SealedClass?) { when (value_1) { @@ -49,7 +49,7 @@ fun case_4(value_1: _SealedClass?) { } } -// CASE DESCRIPTION: 'When' with direct and invert type checking operator on the objects. +// TESTCASE NUMBER: 5 fun case_5(value_1: Any): String { when (value_1) { is _EmptyObject -> return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.3.kt index 67654c7f75b..c17198f27e2 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.3.kt @@ -3,16 +3,16 @@ // !WITH_OBJECTS /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [1] Type test condition: type checking operator followed by type. - NUMBER: 3 - DESCRIPTION: 'When' with bound value and enumaration of type test conditions. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [1] Type test condition: type checking operator followed by type. + * NUMBER: 3 + * DESCRIPTION: 'When' with bound value and enumaration of type test conditions. */ -// CASE DESCRIPTION: 'When' with type test condition on the various basic types. +// TESTCASE NUMBER: 1 fun case_1(value_1: Any) = when (value_1) { is Int -> {} is Float, is Char, is Boolean -> {} @@ -20,7 +20,7 @@ fun case_1(value_1: Any) = when (value_1) { else -> {} } -// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types. +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) = when (value_1) { is Float, is Char, is _SealedClass? -> "" // if value is null then this branch will be executed is Double, is Boolean, is _ClassWithCompanionObject.Companion -> "" @@ -28,9 +28,9 @@ fun case_2(value_1: Any?) = when (value_1) { } /* - CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check in the different branches). - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 3 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_3(value_1: Any?) = when (value_1) { is Float, is Char, is Int? -> "" // if value is null then this branch will be executed @@ -39,9 +39,9 @@ fun case_3(value_1: Any?) = when (value_1) { } /* - CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check in the one branch). - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 4 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_4(value_1: Any?) = when (value_1) { is Float, is Char?, is Int? -> "" // double nullable type check in the one branch @@ -50,9 +50,9 @@ fun case_4(value_1: Any?) = when (value_1) { } /* - CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check). - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 5 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_5(value_1: Any?): String { when (value_1) { @@ -64,9 +64,9 @@ fun case_5(value_1: Any?): String { } /* - CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two different nullable type check in the one branch). - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 6 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_6(value_1: Any?): String { when (value_1) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.4.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.4.kt index 1e2b4ea007b..5decab61159 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.4.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.4.kt @@ -1,46 +1,46 @@ // !WITH_SEALED_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [1] Type test condition: type checking operator followed by type. - NUMBER: 4 - DESCRIPTION: 'When' with bound value and enumaration of type test conditions (with invert type checking operator). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [1] Type test condition: type checking operator followed by type. + * NUMBER: 4 + * DESCRIPTION: 'When' with bound value and enumaration of type test conditions (with invert type checking operator). */ -// CASE DESCRIPTION: 'When' with direct and invert type checking operator in the one branch and other branch. +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass): String = when (value_1) { is _SealedChild1, !is _SealedChild3 -> "" is _SealedChild3 -> "" } -// CASE DESCRIPTION: 'When' with three invert type checking operator in the one branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClass) = when (value_1) { !is _SealedChild1, !is _SealedChild2, !is _SealedChild3 -> {} } -// CASE DESCRIPTION: 'When' with direct (first) and invert (second) type checking operator on the some type in the one branch. +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClass): String = when (value_1) { is _SealedChild2, !is _SealedChild2 -> "" } -// CASE DESCRIPTION: 'When' with direct (second) and invert (first) type checking operator in the one branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClass): String = when (value_1) { !is _SealedChild1, is _SealedChild1 -> "" } -// CASE DESCRIPTION: 'When' with direct and invert (nullable) type checking operator on the some type in the one branch. +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?): String = when (value_1) { is _SealedChild3, !is _SealedChild3? -> "" else -> "" } /* - CASE DESCRIPTION: 'When' with direct and invert type checking operator in the one branch and other branch and double nullable type check. - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 6 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_6(value_1: Any?): String = when (value_1) { is Boolean?, !is _SealedChild3 -> "" // double nullable type check in the one branch @@ -49,9 +49,9 @@ fun case_6(value_1: Any?): String = when (value_1) { } /* - CASE DESCRIPTION: 'When' with direct and invert type checking operator and null-check in the one branch. - UNEXPECTED BEHAVIOUR - ISSUES: KT-22996 + * TESTCASE NUMBER: 7 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-22996 */ fun case_7(value_1: Any?): String = when (value_1) { is Number?, null, !is _SealedChild3 -> "" // triple nullable type check in the one branch diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.1.kt index f054eebe1a9..10dd3bc7531 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.1.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [3] Contains test condition: containment operator followed by an expression. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and containment operator. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [3] Contains test condition: containment operator followed by an expression. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and containment operator. */ -// CASE DESCRIPTION: 'When' with range operator. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: Int, value_3: Short): String { when (value_1) { in Long.MIN_VALUE..-100 -> return "" @@ -23,7 +23,7 @@ fun case_1(value_1: Int, value_2: Int, value_3: Short): String { return "" } -// CASE DESCRIPTION: 'When' on types with contains method defined. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int, value_2: List, value_3: _Class) = when (value_1) { in value_2[0] -> "" !in listOf(0, 1, 2, 3, 4) -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.2.kt index 4697257df2c..2ae61d7590e 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.2.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [3] Contains test condition: containment operator followed by an expression. - NUMBER: 2 - DESCRIPTION: 'When' with bound value and enumeration of the containment operators. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [3] Contains test condition: containment operator followed by an expression. + * NUMBER: 2 + * DESCRIPTION: 'When' with bound value and enumeration of the containment operators. */ -// CASE DESCRIPTION: 'When' with range operator. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: Int, value_3: Short): String { when (value_1) { in Long.MIN_VALUE..-100, in -99..0 -> return "" @@ -21,7 +21,7 @@ fun case_1(value_1: Int, value_2: Int, value_3: Short): String { return "" } -// CASE DESCRIPTION: 'When' on types with contains method defined. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int, value_2: List, value_3: _Class) = when (value_1) { !in value_2[0], !in listOf(0, 1, 2, 3, 4), !in value_3.getIntArray(90) -> "" else -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.1.kt index fe33e590e08..1105e20d40c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.1.kt @@ -3,16 +3,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [5] Any other expression. - NUMBER: 1 - DESCRIPTION: 'When' with enumeration of the different variants of expressions in 'when condition'. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [5] Any other expression. + * NUMBER: 1 + * DESCRIPTION: 'When' with enumeration of the different variants of expressions in 'when condition'. */ -// CASE DESCRIPTION: 'When' with condition as literals. +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { when (value_1) { true -> {} @@ -24,7 +24,7 @@ fun case_1(value_1: Any?) { } } -// CASE DESCRIPTION: 'When' with condition as arithmetic expressions. +// TESTCASE NUMBER: 2 fun case_2(value_1: Number, value_2: Int) { when (value_1) { -.09 % 10L -> {} @@ -33,7 +33,7 @@ fun case_2(value_1: Number, value_2: Int) { } } -// CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison). +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) { when (value_1) { value_2 -> {} @@ -45,7 +45,7 @@ fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) { } } -// CASE DESCRIPTION: 'When' with condition as concatenations. +// TESTCASE NUMBER: 4 fun case_4(value_1: String, value_2: String, value_3: String) { when (value_1) { "..." + value_2 + "" + "$value_3" + "..." -> {} @@ -53,7 +53,7 @@ fun case_4(value_1: String, value_2: String, value_3: String) { } } -// CASE DESCRIPTION: 'When' with condition as when expression. +// TESTCASE NUMBER: 5 fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { when (value_1) { when { @@ -73,7 +73,7 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { } } -// CASE DESCRIPTION: 'When' with condition as if expression. +// TESTCASE NUMBER: 6 fun case_6(value_1: Int, value_2: Int) { when (value_1) { if (value_2 > 1000) 1 @@ -84,7 +84,7 @@ fun case_6(value_1: Int, value_2: Int) { } } -// CASE DESCRIPTION: 'When' with condition as try expression. +// TESTCASE NUMBER: 7 fun case_7(value_1: Any, value_2: String, value_3: String) { when (value_1) { try { 4 } catch (e: Exception) { 5 } -> {} @@ -93,7 +93,7 @@ fun case_7(value_1: Any, value_2: String, value_3: String) { } } -// CASE DESCRIPTION: 'When' with condition as elvis operator expression. +// TESTCASE NUMBER: 8 fun case_8(value_1: Int, value_2: Int?, value_3: Int?) { when (value_1) { value_2 ?: 0 -> {} @@ -102,7 +102,7 @@ fun case_8(value_1: Int, value_2: Int?, value_3: Int?) { } } -// CASE DESCRIPTION: 'When' with condition as range expression. +// TESTCASE NUMBER: 9 fun case_9(value_1: Any) { when (value_1) { 1..10 -> {} @@ -111,7 +111,7 @@ fun case_9(value_1: Any) { } } -// CASE DESCRIPTION: 'When' with condition as cast expression. +// TESTCASE NUMBER: 10 fun case_10(value_1: Collection, value_2: Collection, value_3: Collection?) { when (value_1) { value_2 as MutableList -> {} @@ -121,7 +121,7 @@ fun case_10(value_1: Collection, value_2: Collection, value_3: Collect } } -// CASE DESCRIPTION: 'When' with condition as prefix operator expression. +// TESTCASE NUMBER: 11 fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) { var mutableValue1 = value_2 var mutableValue2 = value_3 @@ -133,7 +133,7 @@ fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) { } } -// CASE DESCRIPTION: 'When' with condition as postfix operator expression. +// TESTCASE NUMBER: 12 fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) { var mutableValue1 = value_2 var mutableValue2 = value_3 @@ -145,7 +145,7 @@ fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) { } } -// CASE DESCRIPTION: 'When' with condition as indexing expression. +// TESTCASE NUMBER: 13 fun case_13(value_1: Int, value_2: List, value_3: List>>>) { when (value_1) { value_2[0] -> {} @@ -153,7 +153,7 @@ fun case_13(value_1: Int, value_2: List, value_3: List> } } -// CASE DESCRIPTION: 'When' with condition as call expression. +// TESTCASE NUMBER: 14 fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) { fun __fun_1(): () -> Any { return fun() { } } @@ -166,7 +166,7 @@ fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) { } } -// CASE DESCRIPTION: 'When' with condition as property access expression. +// TESTCASE NUMBER: 15 fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) { when (value_1) { value_2.prop_1 -> {} @@ -176,7 +176,7 @@ fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) { } } -// CASE DESCRIPTION: 'When' with condition as fun literal. +// TESTCASE NUMBER: 16 fun case_16(value_1: () -> Any): Any { val fun_1 = fun() { return } @@ -189,7 +189,7 @@ fun case_16(value_1: () -> Any): Any { } } -// CASE DESCRIPTION: 'When' with condition as lambda literal. +// TESTCASE NUMBER: 17 fun case_17(value_1: () -> Any) { val lambda_1 = { 0 } @@ -202,7 +202,7 @@ fun case_17(value_1: () -> Any) { } } -// CASE DESCRIPTION: 'When' with condition as object literal. +// TESTCASE NUMBER: 18 fun case_18(value_1: Any) { val object_1 = object { val prop_1 = 1 @@ -218,7 +218,7 @@ fun case_18(value_1: Any) { } } -// CASE DESCRIPTION: 'When' with condition as this expression. +// TESTCASE NUMBER: 19 class A { val prop_1 = 1 val lambda_1 = { 1 } @@ -238,7 +238,7 @@ class A { } } -// CASE DESCRIPTION: 'When' with condition as throw expression. +// TESTCASE NUMBER: 20 fun case_20(value_1: Nothing) { when (value_1) { throw Exception() -> {} @@ -246,16 +246,16 @@ fun case_20(value_1: Nothing) { } } -// CASE DESCRIPTION: 'When' with condition as return expression. +// TESTCASE NUMBER: 21 fun case_21(value_1: Nothing) { - fun r_1() { + fun f1() { when (value_1) { return -> 1 return return return -> 2 } } - fun r_2(): List? { + fun f2(): List? { when (value_1) { return listOf(0, 1, 2) -> 1 return null -> 2 @@ -263,7 +263,7 @@ fun case_21(value_1: Nothing) { } } -// CASE DESCRIPTION: 'When' with condition as continue expression. +// TESTCASE NUMBER: 22 fun case_22(value_1: Nothing) { loop1@ while (true) { loop2@ while (true) { @@ -275,7 +275,7 @@ fun case_22(value_1: Nothing) { } } -// CASE DESCRIPTION: 'When' with condition as break expression. +// TESTCASE NUMBER: 23 fun case_23(value_1: Nothing) { loop1@ while (true) { loop2@ while (true) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.2.kt index bad2f707a51..9082720d7f9 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.2.kt @@ -3,16 +3,16 @@ // !WITH_FUNCTIONS /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [5] Any other expression. - NUMBER: 2 - DESCRIPTION: 'When' with different variants of the arithmetic expressions (additive expression and multiplicative expression) in 'when condition'. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [5] Any other expression. + * NUMBER: 2 + * DESCRIPTION: 'When' with different variants of the arithmetic expressions (additive expression and multiplicative expression) in 'when condition'. */ -// CASE DESCRIPTION: 'When' with condition as literals. +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { when (value_1) { true, 100, -.09f -> {} @@ -20,14 +20,14 @@ fun case_1(value_1: Any?) { } } -// CASE DESCRIPTION: 'When' with condition as arithmetic expressions. +// TESTCASE NUMBER: 2 fun case_2(value_1: Number, value_2: Int) { when (value_1) { -.09 % 10L, value_2 / -5, getByte(99) - 11 + 90 -> {} } } -// CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison). +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) { when (value_1) { value_2, !value_2, getBoolean() && value_2, getChar(10) != 'a' -> {} @@ -35,14 +35,14 @@ fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) { } } -// CASE DESCRIPTION: 'When' with condition as concatenations. +// TESTCASE NUMBER: 4 fun case_4(value_1: String, value_2: String, value_3: String) { when (value_1) { "..." + value_2 + "" + "$value_3" + "...", value_2 + getString() -> {} } } -// CASE DESCRIPTION: 'When' with condition as when expression. +// TESTCASE NUMBER: 5 fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { when (value_1) { when { @@ -60,35 +60,35 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) { } } -// CASE DESCRIPTION: 'When' with condition as if expression. +// TESTCASE NUMBER: 6 fun case_6(value_1: Int, value_2: Int) { when (value_1) { if (value_2 > 1000) 1 else 2, if (value_2 < 100) 1 else if (value_2 < 10) 2 else 3 -> {} } } -// CASE DESCRIPTION: 'When' with condition as try expression. +// TESTCASE NUMBER: 7 fun case_7(value_1: Any, value_2: String, value_3: String) { when (value_1) { try { 4 } catch (e: Exception) { 5 }, try { throw Exception() } catch (e: Exception) { value_2 }, try { throw Exception() } catch (e: Exception) { {value_3} } finally { } -> {} } } -// CASE DESCRIPTION: 'When' with condition as elvis operator expression. +// TESTCASE NUMBER: 8 fun case_8(value_1: Int, value_2: Int?, value_3: Int?) { when (value_1) { value_2 ?: 0, value_2 ?: value_3 ?: 0, value_2!! ?: 0 -> {} } } -// CASE DESCRIPTION: 'When' with condition as range expression. +// TESTCASE NUMBER: 9 fun case_9(value_1: Any) { when (value_1) { 1..10, -100L..100L, -getInt()..getLong() -> {} } } -// CASE DESCRIPTION: 'When' with condition as cast expression. +// TESTCASE NUMBER: 10 fun case_10(value_1: Collection, value_2: Collection, value_3: Collection?) { when (value_1) { value_2 as MutableList, value_2 as? MutableList -> {} @@ -96,7 +96,7 @@ fun case_10(value_1: Collection, value_2: Collection, value_3: Collect } } -// CASE DESCRIPTION: 'When' with condition as prefix operator expression. +// TESTCASE NUMBER: 11 fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) { var mutableValue1 = value_2 var mutableValue2 = value_3 @@ -106,7 +106,7 @@ fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) { } } -// CASE DESCRIPTION: 'When' with condition as postfix operator expression. +// TESTCASE NUMBER: 12 fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) { var mutableValue1 = value_2 var mutableValue2 = value_3 @@ -116,14 +116,14 @@ fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) { } } -// CASE DESCRIPTION: 'When' with condition as indexing expression. +// TESTCASE NUMBER: 13 fun case_13(value_1: Int, value_2: List, value_3: List>>>) { when (value_1) { value_2[0], value_3[0][-4][1][-1] -> {} } } -// CASE DESCRIPTION: 'When' with condition as call expression. +// TESTCASE NUMBER: 14 fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) { fun __fun_1(): () -> Unit { return fun() { } } @@ -133,7 +133,7 @@ fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) { } } -// CASE DESCRIPTION: 'When' with condition as property access expression. +// TESTCASE NUMBER: 15 fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) { when (value_1) { value_2.prop_1, value_3?.prop_2 -> {} @@ -141,7 +141,7 @@ fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) { } } -// CASE DESCRIPTION: 'When' with condition as fun literal. +// TESTCASE NUMBER: 16 fun case_16(value_1: () -> Any): Any { val fun_1 = fun() { return } @@ -151,7 +151,7 @@ fun case_16(value_1: () -> Any): Any { } } -// CASE DESCRIPTION: 'When' with condition as lambda literal. +// TESTCASE NUMBER: 17 fun case_17(value_1: () -> Any) { val lambda_1 = { 0 } @@ -161,7 +161,7 @@ fun case_17(value_1: () -> Any) { } } -// CASE DESCRIPTION: 'When' with condition as object literal. +// TESTCASE NUMBER: 18 fun case_18(value_1: Any) { val object_1 = object { val prop_1 = 1 @@ -175,7 +175,7 @@ fun case_18(value_1: Any) { } } -// CASE DESCRIPTION: 'When' with condition as this expression. +// TESTCASE NUMBER: 19 class A { val prop_1 = 1 val lambda_1 = { 1 } @@ -190,29 +190,29 @@ class A { } } -// CASE DESCRIPTION: 'When' with condition as throw expression. +// TESTCASE NUMBER: 20 fun case_20(value_1: Nothing) { when (value_1) { throw Exception(), throw throw throw Exception() -> {} } } -// CASE DESCRIPTION: 'When' with condition as return expression. +// TESTCASE NUMBER: 21 fun case_21(value_1: Nothing) { - fun r_1() { + fun f1() { when (value_1) { return, return return return -> 2 } } - fun r_2(): List? { + fun f2(): List? { when (value_1) { return listOf(0, 1, 2), return null -> 2 } } } -// CASE DESCRIPTION: 'When' with condition as continue expression. +// TESTCASE NUMBER: 22 fun case_22(value_1: Nothing) { loop1@ while (true) { loop2@ while (true) { @@ -223,7 +223,7 @@ fun case_22(value_1: Nothing) { } } -// CASE DESCRIPTION: 'When' with condition as break expression. +// TESTCASE NUMBER: 23 fun case_23(value_1: Nothing) { loop1@ while (true) { loop2@ while (true) { @@ -234,7 +234,7 @@ fun case_23(value_1: Nothing) { } } -// CASE DESCRIPTION: 'When' with condition as mixed Nothing expressions. +// TESTCASE NUMBER: 24 fun case_24(value_1: Nothing?) = when (value_1) { throw Exception(), return "" -> "" null, return return return "", throw throw throw Exception() -> "" @@ -242,9 +242,9 @@ fun case_24(value_1: Nothing?) = when (value_1) { } /* - CASE DESCRIPTION: 'When' with condition as mixed Nothing expressions. - DISCUSSION - ISSUES: KT-25948 + * TESTCASE NUMBER: 25 + * DISCUSSION + * ISSUES: KT-25948 */ fun case_25(value_1: Boolean) = when (value_1) { true -> {} @@ -253,9 +253,9 @@ fun case_25(value_1: Boolean) = when (value_1) { } /* - CASE DESCRIPTION: 'When' with two labels in condition: with const value and nullable const value. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26045 + * TESTCASE NUMBER: 26 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26045 */ fun case_26(value_1: Int?, value_2: _Class, value_3: _Class?) { when (value_1) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/7.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/7.1.kt index e7b42778469..f9391c1b926 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/7.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/7.1.kt @@ -1,14 +1,14 @@ /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 7 - SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. - NUMBER: 1 - DESCRIPTION: 'When' with bound value and else branch. + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 7 + * SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. + * NUMBER: 1 + * DESCRIPTION: 'When' with bound value and else branch. */ -// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and expression as when condition. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) = when (value_1) { 0 -> "" 1 -> "" @@ -16,7 +16,7 @@ fun case_1(value_1: Int?) = when (value_1) { else -> "" } -// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and type test as when condition. +// TESTCASE NUMBER: 2 fun case_2(value_1: Any) = when (value_1) { is Int -> "" is Boolean -> "" @@ -24,8 +24,8 @@ fun case_2(value_1: Any) = when (value_1) { else -> "" } -// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and range test as when condition. -fun case_2(value_1: Int) = when (value_1) { +// TESTCASE NUMBER: 3 +fun case_3(value_1: Int) = when (value_1) { in -10..10 -> "" in 11..1000 -> "" in 1000..Int.MAX_VALUE -> "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.1.kt index 7266d0e5ba2..ebbf1064ea7 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.1.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 1 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 1 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch). */ -// CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' without bound value. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String { val whenValue = when { value_1 == 0 -> _ClassLevel2() @@ -31,7 +31,7 @@ fun case_1(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' with bound value. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String { val whenValue = when (value_1) { 0 -> _ClassLevel2() @@ -51,7 +51,7 @@ fun case_2(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' without bound value. +// TESTCASE NUMBER: 3 fun case_3(value_1: Int): String { val whenValue = when { value_1 == 0 -> 1 + 1 @@ -78,7 +78,7 @@ fun case_3(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' with bound value. +// TESTCASE NUMBER: 4 fun case_4(value_1: Int): String { val whenValue = when (value_1) { 0 -> 1 + 1 @@ -105,7 +105,7 @@ fun case_4(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' without bound value. +// TESTCASE NUMBER: 5 fun case_5(value_1: Int): String { val whenValue = when { value_1 == 0 -> 10 @@ -124,7 +124,7 @@ fun case_5(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with bound value. +// TESTCASE NUMBER: 6 fun case_6(value_1: Int): String { val whenValue = when (value_1) { 0 -> 10 diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.2.kt index 2427682aada..3ead264b6d6 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.2.kt @@ -3,16 +3,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 2 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 2 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum). */ -// CASE DESCRIPTION: Checking all types except the correct one in 'when'. +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass): String { val whenValue = when (value_1) { _EnumClass.EAST -> _ClassLevel2() @@ -32,7 +32,7 @@ fun case_1(value_1: _EnumClass): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClass?): String { val whenValue = when (value_1) { _EnumClass.EAST -> _ClassLevel2() @@ -55,7 +55,7 @@ fun case_2(value_1: _EnumClass?): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 3 fun case_3(value_1: _EnumClass): String { val whenValue = when (value_1) { _EnumClass.EAST -> 10 @@ -74,7 +74,7 @@ fun case_3(value_1: _EnumClass): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: _EnumClass?): String { val whenValue = when (value_1) { _EnumClass.EAST -> 10 diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.3.kt index 49f64853db9..32bdad338d5 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.3.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 3 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 3 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value). */ -// CASE DESCRIPTION: Checking all types except the correct one in 'when'. +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean): String { val whenValue = when (value_1) { true -> _ClassLevel2() @@ -27,7 +27,7 @@ fun case_1(value_1: Boolean): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean?): String { val whenValue = when (value_1) { true -> _ClassLevel2() @@ -44,7 +44,7 @@ fun case_2(value_1: Boolean?): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean): String { val whenValue = when (value_1) { true -> 10 @@ -59,7 +59,7 @@ fun case_3(value_1: Boolean): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: Boolean?): String { val whenValue = when (value_1) { true -> 10 @@ -77,5 +77,3 @@ fun case_4(value_1: Boolean?): String { return "" } - - diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.4.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.4.kt index e79a5a7252a..2c95a226234 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.4.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.4.kt @@ -3,16 +3,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 4 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class). + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 4 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class). */ -// CASE DESCRIPTION: Checking all types except the correct one in 'when'. +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass): String { val whenValue = when (value_1) { is _SealedChild1 -> _ClassLevel2() @@ -29,7 +29,7 @@ fun case_1(value_1: _SealedClass): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClass?): String { val whenValue = when (value_1) { is _SealedChild1 -> _ClassLevel2() @@ -49,7 +49,7 @@ fun case_2(value_1: _SealedClass?): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClass): String { val whenValue = when (value_1) { is _SealedChild1 -> 10 @@ -65,7 +65,7 @@ fun case_3(value_1: _SealedClass): String { return "" } -// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClass?): String { val whenValue = when (value_1) { is _SealedChild1 -> 10 @@ -84,7 +84,7 @@ fun case_4(value_1: _SealedClass?): String { return "" } -// CASE DESCRIPTION: Checking objects except the correct one in 'when'. +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClassWithObjects): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> _ClassLevel2() @@ -101,7 +101,7 @@ fun case_5(value_1: _SealedClassWithObjects): String { return "" } -// CASE DESCRIPTION: Checking objects except the correct one in 'when' with null-check branch. +// TESTCASE NUMBER: 6 fun case_6(value_1: _SealedClassWithObjects?): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> _ClassLevel2() @@ -121,7 +121,7 @@ fun case_6(value_1: _SealedClassWithObjects?): String { return "" } -// CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 7 fun case_7(value_1: _SealedClassWithObjects): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> 10 @@ -137,7 +137,7 @@ fun case_7(value_1: _SealedClassWithObjects): String { return "" } -// CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 8 fun case_8(value_1: _SealedClassWithObjects?): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> 10 @@ -156,7 +156,7 @@ fun case_8(value_1: _SealedClassWithObjects?): String { return "" } -// CASE DESCRIPTION: Checking all types except the correct one in 'when' with 'else' branch. +// TESTCASE NUMBER: 9 fun case_9(value_1: _SealedClassWithObjects?): String { val whenValue = when (value_1) { is _SealedClassWithObjects -> _ClassLevel2() @@ -172,4 +172,4 @@ fun case_9(value_1: _SealedClassWithObjects?): String { checkSubtype<_ClassLevel3>(whenValue) return "" -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.1.kt index 3d588f0bfba..ad16139070e 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.1.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 1 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 1 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch). */ -// CASE DESCRIPTION: Checking correctness type (custom types) in 'when' without bound value. +// TESTCASE NUMBER: 1 fun case_1(value_1: Int): String { val whenValue = when { value_1 == 0 -> _ClassLevel2() @@ -26,7 +26,7 @@ fun case_1(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking correctness type (custom types) in 'when' with bound value. +// TESTCASE NUMBER: 2 fun case_2(value_1: Int): String { val whenValue = when (value_1) { 0 -> _ClassLevel2() @@ -42,9 +42,9 @@ fun case_2(value_1: Int): String { } /* - CASE DESCRIPTION: Checking correctness type (numbers) in 'when' without bound value. - UNEXPECTED BEHAVIOUR - ISSUES: KT-25268 + * TESTCASE NUMBER: 3 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-25268 */ fun case_3(value_1: Int): String { val whenValue = when { @@ -64,9 +64,9 @@ fun case_3(value_1: Int): String { } /* - CASE DESCRIPTION: Checking correctness type (numbers) in 'when' with bound value. - UNEXPECTED BEHAVIOUR - ISSUES: KT-25268 + * TESTCASE NUMBER: 4 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-25268 */ fun case_4(value_1: Int): String { val whenValue = when (value_1) { @@ -85,7 +85,7 @@ fun case_4(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' without bound value. +// TESTCASE NUMBER: 5 fun case_5(value_1: Int): String { val whenValue = when { value_1 == 0 -> 10 @@ -100,7 +100,7 @@ fun case_5(value_1: Int): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with bound value. +// TESTCASE NUMBER: 6 fun case_6(value_1: Int): String { val whenValue = when (value_1) { 0 -> 10 diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.2.kt index 171f5f67fb6..485db57ec02 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.2.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.2.kt @@ -3,16 +3,16 @@ // !WITH_ENUM_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 2 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 2 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum). */ -// CASE DESCRIPTION: Checking correct type in 'when'. +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass): String { val whenValue = when (value_1) { _EnumClass.EAST -> _ClassLevel2() @@ -27,7 +27,7 @@ fun case_1(value_1: _EnumClass): String { return "" } -// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: _EnumClass?): String { val whenValue = when (value_1) { _EnumClass.EAST -> _ClassLevel2() @@ -43,7 +43,7 @@ fun case_2(value_1: _EnumClass?): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 3 fun case_3(value_1: _EnumClass): String { val whenValue = when (value_1) { _EnumClass.EAST -> 10 @@ -58,7 +58,7 @@ fun case_3(value_1: _EnumClass): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: _EnumClass?): String { val whenValue = when (value_1) { _EnumClass.EAST -> 10 diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.3.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.3.kt index 85e1f1e4089..3706f34bb10 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.3.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.3.kt @@ -2,16 +2,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 3 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 3 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value). */ -// CASE DESCRIPTION: Checking correct type in 'when'. +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean): String { val whenValue = when (value_1) { true -> _ClassLevel2() @@ -24,7 +24,7 @@ fun case_1(value_1: Boolean): String { return "" } -// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean?): String { val whenValue = when (value_1) { true -> _ClassLevel2() @@ -39,7 +39,7 @@ fun case_2(value_1: Boolean?): String { } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 3 fun case_3(value_1: Boolean): String { val whenValue = when (value_1) { true -> 10 @@ -53,7 +53,7 @@ fun case_3(value_1: Boolean): String { } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: Boolean?): String { val whenValue = when (value_1) { true -> 10 diff --git a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.4.kt b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.4.kt index 40d8cea6310..58de05e0957 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.4.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.4.kt @@ -3,16 +3,16 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) - - SECTIONS: when-expression - PARAGRAPH: 9 - SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. - NUMBER: 4 - DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class). + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: when-expression + * PARAGRAPH: 9 + * SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. + * NUMBER: 4 + * DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class). */ -// CASE DESCRIPTION: Checking correct type in 'when'. +// TESTCASE NUMBER: 1 fun case_1(value_1: _SealedClass): String { val whenValue = when (value_1) { is _SealedChild1 -> _ClassLevel2() @@ -26,7 +26,7 @@ fun case_1(value_1: _SealedClass): String { return "" } -// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch. +// TESTCASE NUMBER: 2 fun case_2(value_1: _SealedClass?): String { val whenValue = when (value_1) { is _SealedChild1 -> _ClassLevel2() @@ -41,7 +41,7 @@ fun case_2(value_1: _SealedClass?): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'. +// TESTCASE NUMBER: 3 fun case_3(value_1: _SealedClass): String { val whenValue = when (value_1) { is _SealedChild1 -> 10 @@ -55,7 +55,7 @@ fun case_3(value_1: _SealedClass): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch. +// TESTCASE NUMBER: 4 fun case_4(value_1: _SealedClass?): String { val whenValue = when (value_1) { is _SealedChild1 -> 10 @@ -70,7 +70,7 @@ fun case_4(value_1: _SealedClass?): String { return "" } -// CASE DESCRIPTION: Checking correct type in 'when' (equality with objects). +// TESTCASE NUMBER: 5 fun case_5(value_1: _SealedClassWithObjects): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> _ClassLevel2() @@ -84,7 +84,7 @@ fun case_5(value_1: _SealedClassWithObjects): String { return "" } -// CASE DESCRIPTION: Checking correct type in 'when' (equality with objects) with null-check branch. +// TESTCASE NUMBER: 6 fun case_6(value_1: _SealedClassWithObjects?): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> _ClassLevel2() @@ -99,7 +99,7 @@ fun case_6(value_1: _SealedClassWithObjects?): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' (equality with objects). +// TESTCASE NUMBER: 7 fun case_7(value_1: _SealedClassWithObjects): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> 10 @@ -113,7 +113,7 @@ fun case_7(value_1: _SealedClassWithObjects): String { return "" } -// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch (equality with objects). +// TESTCASE NUMBER: 8 fun case_8(value_1: _SealedClassWithObjects?): String { val whenValue = when (value_1) { _SealedWithObjectsChild1 -> 10 @@ -128,7 +128,7 @@ fun case_8(value_1: _SealedClassWithObjects?): String { return "" } -// CASE DESCRIPTION: Checking correct basic type (Int) in 'when' with. +// TESTCASE NUMBER: 9 fun case_9(value_1: _SealedClassWithObjects): String { val whenValue = when (value_1) { is _SealedClassWithObjects -> 10 @@ -138,4 +138,4 @@ fun case_9(value_1: _SealedClassWithObjects): String { checkSubtype(whenValue) return "" -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/neg/1.kt index f75c0791a39..5d333e3a4c0 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/neg/1.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, common - NUMBER: 1 - DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, common + * NUMBER: 1 + * DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects. */ // FILE: contracts.kt @@ -15,6 +14,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(value_1: Int?, block: () -> Unit): Boolean { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -26,6 +26,7 @@ inline fun case_1(value_1: Int?, block: () -> Unit): Boolean { return value_1 != null } +// TESTCASE NUMBER: 2 inline fun T?.case_2(value_1: Int?, value_2: Any?, block: () -> Unit): Boolean? { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -42,10 +43,11 @@ inline fun T?.case_2(value_1: Int?, value_2: Any?, block: () -> Unit): Boole return null } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { val value_2: Int if (contracts.case_1(value_1) { value_2 = 10 }) { @@ -56,6 +58,7 @@ fun case_1(value_1: Int?) { } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?, value_2: Int?, value_3: Any?) { val value_4: Int when (value_1.case_2(value_2, value_3) { value_4 = 10 }) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/1.kt index 4f2cea79564..1208306d471 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/1.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, common - NUMBER: 1 - DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, common + * NUMBER: 1 + * DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects. */ // FILE: contracts.kt @@ -15,6 +14,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(value_1: Int?, block: () -> Unit): Boolean { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -24,6 +24,7 @@ inline fun case_1(value_1: Int?, block: () -> Unit): Boolean { return value_1 != null } +// TESTCASE NUMBER: 2 inline fun T?.case_2(value_1: Int?, value_2: Any?, block: () -> Unit): Boolean? { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -37,10 +38,11 @@ inline fun T?.case_2(value_1: Int?, value_2: Any?, block: () -> Unit): Boole return null } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { val value_3: Int if (contracts.case_1(value_1) { value_3 = 10 }) { @@ -51,6 +53,7 @@ fun case_1(value_1: Int?) { } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?, value_2: Int?, value_3: Any?) { val value_4: Int when (value_1.case_2(value_2, value_3) { value_4 = 10 }) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/2.kt index a089629b0e5..645229a114c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/common/pos/2.kt @@ -3,20 +3,21 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, common - NUMBER: 2 - DESCRIPTION: Recursion in the lambda of contract function. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, common + * NUMBER: 2 + * DESCRIPTION: Recursion in the lambda of contract function. */ +// TESTCASE NUMBER: 1 fun case_1(x: Int): Unit = funWithExactlyOnceCallsInPlace { if (x == 0) return if (x == 1) return return case_1(x - 2) } +// TESTCASE NUMBER: 2 fun case_2(x: Int) { funWithAtLeastOnceCallsInPlace { if (x == 0) return @@ -25,6 +26,7 @@ fun case_2(x: Int) { } } +// TESTCASE NUMBER: 3 fun case_3(x: Int) { funWithAtMostOnceCallsInPlace { if (x == 0) return diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/1.kt index 87dfe1acf10..b2bc171918d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/1.kt @@ -3,32 +3,35 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 1 - DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on CallsInPlace effect with wrong invocation kind + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 1 + * DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on CallsInPlace effect with wrong invocation kind */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithAtLeastOnceCallsInPlace { value_1 = 10 } value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { val value_1: Int funWithAtMostOnceCallsInPlace { value_1 = 10 } value_1.inc() } +// TESTCASE NUMBER: 3 fun case_3() { val value_1: Int funWithUnknownCallsInPlace { value_1 = 10 } value_1.inc() } +// TESTCASE NUMBER: 4 fun case_4() { var value_1: Int var value_2: Int @@ -38,6 +41,7 @@ fun case_4() { value_2.div(10) } +// TESTCASE NUMBER: 5 class case_5 { val value_1: Int val value_2: Int @@ -53,6 +57,7 @@ class case_5 { } } +// TESTCASE NUMBER: 6 fun case_6() { val value_1: Int for (i in 0..1) @@ -60,6 +65,7 @@ fun case_6() { value_1.dec() } +// TESTCASE NUMBER: 7 fun case_7() { var value_1: Int var i = 0 @@ -70,6 +76,7 @@ fun case_7() { value_1.dec() } +// TESTCASE NUMBER: 8 fun case_8() { var value_1: Int if (true) funWithAtLeastOnceCallsInPlace { value_1 = 10 } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/2.kt index 03149e80c11..d7ce0fb0c61 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/2.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 2 - DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on nested CallsInPlace effects with wrong invocation kind + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 2 + * DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on nested CallsInPlace effects with wrong invocation kind */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithAtLeastOnceCallsInPlace { @@ -28,6 +28,7 @@ fun case_1() { value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { val value_1: Int funWithAtMostOnceCallsInPlace { @@ -45,6 +46,7 @@ fun case_2() { value_1.inc() } +// TESTCASE NUMBER: 3 fun case_3() { var value_1: Int funWithAtLeastOnceCallsInPlace { @@ -62,6 +64,7 @@ fun case_3() { value_1.inc() } +// TESTCASE NUMBER: 4 fun case_4() { var value_1: Int funWithAtLeastOnceCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/3.kt index 5103421facb..f109765eab1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/3.kt @@ -4,14 +4,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 3 - DESCRIPTION: val/var reassignment and/or uninitialized variable usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 3 + * DESCRIPTION: val/var reassignment and/or uninitialized variable usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass?) { val value_2: Int @@ -25,6 +25,7 @@ fun case_1(value_1: _EnumClass?) { value_2.inc() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) { val value_2: Int @@ -41,6 +42,7 @@ fun case_2(value_1: Any?) { value_2.dec() } +// TESTCASE NUMBER: 3 class case_3(value_1: Any?) { var value_2: Int @@ -59,6 +61,7 @@ class case_3(value_1: Any?) { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: _EnumClassSingle?) { var value_2: Int @@ -77,6 +80,7 @@ fun case_4(value_1: _EnumClassSingle?) { value_2.minus(5) } +// TESTCASE NUMBER: 5 fun case_5() { var value_2: Int @@ -89,6 +93,7 @@ fun case_5() { value_2++ } +// TESTCASE NUMBER: 6 fun case_6() { var value_2: Int @@ -103,6 +108,7 @@ fun case_6() { value_2++ } +// TESTCASE NUMBER: 7 fun case_7() { var value_1: Int @@ -119,21 +125,8 @@ fun case_7() { println(value_1.inc()) } +// TESTCASE NUMBER: 8 fun case_8() { - val x: Int - funWithExactlyOnceCallsInPlace outer@ { - funWithAtMostOnceCallsInPlace { - funWithExactlyOnceCallsInPlace { - x = 42 - return@outer - } - } - throw Exception() - } - println(x.inc()) -} - -fun case_9() { val x: Int funWithExactlyOnceCallsInPlace outer@ { funWithAtMostOnceCallsInPlace { @@ -147,7 +140,8 @@ fun case_9() { println(x.inc()) } -fun case_10() { +// TESTCASE NUMBER: 9 +fun case_9() { val x: Int funWithExactlyOnceCallsInPlace outer@ { funWithAtMostOnceCallsInPlace { @@ -158,7 +152,8 @@ fun case_10() { println(x.inc()) } -fun case_11() { +// TESTCASE NUMBER: 10 +fun case_10() { var x: Int funWithAtLeastOnceCallsInPlace outer@ { funWithAtMostOnceCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/4.kt index 8a939cf50a2..8c0a0c81e09 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/4.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 4 - DESCRIPTION: CallsInPlace contract functions with name shadowing and wrong invocation kind + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 4 + * DESCRIPTION: CallsInPlace contract functions with name shadowing and wrong invocation kind */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace { @@ -20,6 +20,7 @@ fun case_1() { value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { val value_1: Int funWithExactlyOnceCallsInPlace { @@ -35,6 +36,7 @@ fun case_2() { value_1.inc() } +// TESTCASE NUMBER: 3 fun case_3() { val value_1: Int funWithAtLeastOnceCallsInPlace { @@ -53,7 +55,8 @@ fun case_3() { value_1.inc() } -fun case_6() { +// TESTCASE NUMBER: 4 +fun case_4() { var value_1: Int funWithAtLeastOnceCallsInPlace { val value_1: Int @@ -71,7 +74,8 @@ fun case_6() { value_1.dec() } -fun case_7() { +// TESTCASE NUMBER: 5 +fun case_5() { val value_1: Int funWithUnknownCallsInPlace { var value_1: Int diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/5.kt index e288cbd2f09..b8b2e1324a8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/5.kt @@ -3,20 +3,21 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 5 - DESCRIPTION: CallsInPlace contract functions with invalid lambda passing to function parameter. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 5 + * DESCRIPTION: CallsInPlace contract functions with invalid lambda passing to function parameter. */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace({ value_1 = 10 }) value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { var value_1: Int val l = { value_1 = 10 } @@ -24,6 +25,7 @@ fun case_2() { value_1.inc() } +// TESTCASE NUMBER: 3 fun case_3() { var value_1: Int val l = fun () { value_1 = 10 } @@ -31,12 +33,14 @@ fun case_3() { value_1.inc() } +// TESTCASE NUMBER: 4 fun case_4() { var value_1: Int funWithAtLeastOnceCallsInPlace(fun () { value_1 = 10 }) value_1.inc() } +// TESTCASE NUMBER: 5 fun case_5() { val value_1: Int val o = object { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/6.kt index 81e13dcbf9b..44cb6aec63d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/neg/6.kt @@ -3,22 +3,23 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 6 - DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26229 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 6 + * DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26229 */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace({ value_1 = 11 }) value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { var value_1: Int funWithAtLeastOnceCallsInPlace({ value_1 = 11 }) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/1.kt index defacd51f4e..fceb8e91a0b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/1.kt @@ -3,20 +3,21 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 1 - DESCRIPTION: val/var assignments using contract functions with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 1 + * DESCRIPTION: val/var assignments using contract functions with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace { value_1 = 10 } value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { var value_1: Int var value_2: Int @@ -26,6 +27,7 @@ fun case_2() { value_2.div(10) } +// TESTCASE NUMBER: 3 class case_3 { val value_1: Int var value_2: Int diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/2.kt index bc91f87860e..e6cc3859c59 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/2.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 2 - DESCRIPTION: Nested val/var assignments using contract functions with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 2 + * DESCRIPTION: Nested val/var assignments using contract functions with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace { @@ -28,6 +28,7 @@ fun case_1() { value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { val value_1: Int funWithAtMostOnceCallsInPlace { @@ -44,6 +45,7 @@ fun case_2() { } } +// TESTCASE NUMBER: 3 fun case_3() { var value_1: Int funWithExactlyOnceCallsInPlace { @@ -61,6 +63,7 @@ fun case_3() { value_1.inc() } +// TESTCASE NUMBER: 4 fun case_4() { var value_1: Int funWithAtMostOnceCallsInPlace { @@ -80,7 +83,8 @@ fun case_4() { } } -fun case_7() { +// TESTCASE NUMBER: 5 +fun case_5() { var value_1: Int funWithAtLeastOnceCallsInPlace { funWithAtLeastOnceCallsInPlace { @@ -97,7 +101,8 @@ fun case_7() { value_1.inc() } -fun case_8() { +// TESTCASE NUMBER: 6 +fun case_6() { var value_1: Int funWithUnknownCallsInPlace { funWithAtMostOnceCallsInPlace { @@ -120,7 +125,8 @@ fun case_8() { } } -fun case_9() { +// TESTCASE NUMBER: 7 +fun case_7() { var value_1: Int funWithAtMostOnceCallsInPlace { funWithUnknownCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/3.kt index 1e9ed2e2ac1..7a5cac06c38 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/3.kt @@ -4,14 +4,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 3 - DESCRIPTION: val/var assignments or subsequent usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 3 + * DESCRIPTION: val/var assignments or subsequent usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1(value_1: _EnumClass?) { val value_2: Int @@ -26,6 +26,7 @@ fun case_1(value_1: _EnumClass?) { value_2.inc() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) { val value_2: Int @@ -42,6 +43,7 @@ fun case_2(value_1: Any?) { } } +// TESTCASE NUMBER: 3 class case_3(value_1: Any?) { var value_2: Int @@ -60,6 +62,7 @@ class case_3(value_1: Any?) { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: _EnumClassSingle?) { var value_2: Int @@ -78,6 +81,7 @@ fun case_4(value_1: _EnumClassSingle?) { } } +// TESTCASE NUMBER: 5 fun case_5() { var value_2: Int @@ -90,6 +94,7 @@ fun case_5() { value_2++ } +// TESTCASE NUMBER: 6 fun case_6() { var value_2: Int @@ -104,6 +109,7 @@ fun case_6() { value_2++ } +// TESTCASE NUMBER: 7 fun case_7() { var value_1: Int @@ -122,6 +128,7 @@ fun case_7() { println(value_1.inc()) } +// TESTCASE NUMBER: 8 fun case_8() { var value_1: Int @@ -138,6 +145,7 @@ fun case_8() { println(value_1.inc()) } +// TESTCASE NUMBER: 9 fun case_9() { val x: Int funWithExactlyOnceCallsInPlace outer@ { @@ -152,6 +160,7 @@ fun case_9() { println(x.inc()) } +// TESTCASE NUMBER: 10 fun case_10() { val x: Int funWithExactlyOnceCallsInPlace outer@ { @@ -163,6 +172,7 @@ fun case_10() { println(x.inc()) } +// TESTCASE NUMBER: 11 fun case_11() { var x: Int funWithAtLeastOnceCallsInPlace outer@ { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/4.kt index 54bb14ab844..b9234ded667 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/4.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 4 - DESCRIPTION: CallsInPlace contract functions with name shadowing + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 4 + * DESCRIPTION: CallsInPlace contract functions with name shadowing */ +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace { @@ -19,6 +19,7 @@ fun case_1() { } } +// TESTCASE NUMBER: 2 fun case_2() { val value_1: Int funWithExactlyOnceCallsInPlace { @@ -33,6 +34,7 @@ fun case_2() { } } +// TESTCASE NUMBER: 3 fun case_3() { val value_1: Int funWithAtLeastOnceCallsInPlace { @@ -51,6 +53,7 @@ fun case_3() { value_1.inc() } +// TESTCASE NUMBER: 4 fun case_4() { val value_1: Int funWithAtMostOnceCallsInPlace { @@ -69,6 +72,7 @@ fun case_4() { value_1.inc() } +// TESTCASE NUMBER: 5 fun case_5() { val value_1: Int funWithUnknownCallsInPlace { @@ -86,6 +90,7 @@ fun case_5() { value_1.inc() } +// TESTCASE NUMBER: 6 fun case_6() { var value_1: Int funWithAtLeastOnceCallsInPlace { @@ -102,6 +107,7 @@ fun case_6() { value_1.dec() } +// TESTCASE NUMBER: 7 fun case_7() { val value_1: Int funWithAtLeastOnceCallsInPlace { @@ -114,6 +120,7 @@ fun case_7() { value_1.dec() } +// TESTCASE NUMBER: 8 fun case_8() { var value_1: Int funWithAtLeastOnceCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/5.kt index e9ff3ce965f..6b453b66fb7 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/5.kt @@ -1,13 +1,12 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 5 - DESCRIPTION: Smart initialization with correspond contract function with default value before lambda. - ISSUES: KT-26444 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 5 + * DESCRIPTION: Smart initialization with correspond contract function with default value before lambda. + * ISSUES: KT-26444 */ // FILE: contracts.kt @@ -16,15 +15,17 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(x: Double = 1.0, block: () -> Unit): Double { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return x } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int contracts.case_1 { value_1 = 10 } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/6.kt index df017f18051..2cbd3d2240c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/6.kt @@ -2,14 +2,13 @@ // !WITH_CONTRACT_FUNCTIONS /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 6 - DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26229 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 6 + * DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26229 */ // FILE: contracts.kt @@ -18,6 +17,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 3 inline fun case_3(block1: () -> Unit, block2: () -> Unit, block3: () -> Unit) { contract { callsInPlace(block1, InvocationKind.EXACTLY_ONCE) @@ -30,22 +30,25 @@ inline fun case_3(block1: () -> Unit, block2: () -> Unit, block3: () -> Unit) { block3() } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithExactlyOnceCallsInPlace({ value_1 = 11 }) value_1.inc() } +// TESTCASE NUMBER: 2 fun case_2() { var value_1: Int funWithAtLeastOnceCallsInPlace({ value_1 = 11 }) value_1.inc() } +// TESTCASE NUMBER: 3 fun case_3() { val value_1: Int var value_2: Int diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/7.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/7.kt index d2228678231..e748c359942 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/7.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/initialization/pos/7.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, initialization - NUMBER: 7 - DESCRIPTION: Check initialization when type parameter of the callsInPlace is specify explicitly. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, initialization + * NUMBER: 7 + * DESCRIPTION: Check initialization when type parameter of the callsInPlace is specify explicitly. */ // FILE: contracts.kt @@ -15,6 +14,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> T): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -22,6 +22,7 @@ inline fun case_1(block: () -> T): T { return block() } +// TESTCASE NUMBER: 2 inline fun case_2(block: () -> Int): Int { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -29,10 +30,11 @@ inline fun case_2(block: () -> Int): Int { return block() } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int case_1 { @@ -41,6 +43,7 @@ fun case_1() { println(value_1) } +// TESTCASE NUMBER: 2 fun case_2() { val value_1: Int case_2 { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/neg/1.kt index 35dfe196b46..4c08550d2ab 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/neg/1.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 1 - DESCRIPTION: Using not allowed break and continue inside lambda of contract function + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 1 + * DESCRIPTION: Using not allowed break and continue inside lambda of contract function */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean) { while (value_1) { funWithExactlyOnceCallsInPlace { @@ -27,6 +27,7 @@ fun case_1(value_1: Boolean) { } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean) { for (i in 0..10) { funWithExactlyOnceCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/1.kt index 9f0194e485b..34bb6c0250c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/1.kt @@ -4,14 +4,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 1 - DESCRIPTION: Unreachable code detection using contract function with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 1 + * DESCRIPTION: Unreachable code detection using contract function with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1() { funWithExactlyOnceCallsInPlace { throw Exception() @@ -19,6 +19,7 @@ fun case_1() { println("1") } +// TESTCASE NUMBER: 2 fun case_2() { funWithAtLeastOnceCallsInPlace { throw Exception() @@ -26,6 +27,7 @@ fun case_2() { println("1") } +// TESTCASE NUMBER: 3 fun case_3() { funWithExactlyOnceCallsInPlace { return @@ -33,6 +35,7 @@ fun case_3() { println("1") } +// TESTCASE NUMBER: 4 fun case_4() { funWithAtLeastOnceCallsInPlace { return @@ -40,6 +43,7 @@ fun case_4() { println("1") } +// TESTCASE NUMBER: 5 fun case_5(args: Array) { fun nestedFun_1() { funWithAtLeastOnceCallsInPlace { @@ -66,6 +70,7 @@ fun case_5(args: Array) { } } +// TESTCASE NUMBER: 6 fun case_6(args: Array) { args.forEach { funWithExactlyOnceCallsInPlace { @@ -91,6 +96,7 @@ fun case_6(args: Array) { } } +// TESTCASE NUMBER: 7 fun case_7() { val value_1 = funWithExactlyOnceCallsInPlace { throw Exception() @@ -100,6 +106,7 @@ fun case_7() { } +// TESTCASE NUMBER: 8 fun case_8() { println(funWithExactlyOnceCallsInPlace { return; println(1) }) return diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/2.kt index 0c455889dfc..525275e9c15 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/2.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 2 - DESCRIPTION: Check for lack of unreachable code report when 'at most once' and 'unknown' invokations in CallsInPlace effect used. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 2 + * DESCRIPTION: Check for lack of unreachable code report when 'at most once' and 'unknown' invokations in CallsInPlace effect used. */ +// TESTCASE NUMBER: 1 fun case_1() { funWithAtMostOnceCallsInPlace { throw Exception() @@ -21,6 +21,7 @@ fun case_1() { println("1") } +// TESTCASE NUMBER: 2 fun case_2() { funWithUnknownCallsInPlace { throw Exception() @@ -31,6 +32,7 @@ fun case_2() { println("1") } +// TESTCASE NUMBER: 3 fun case_3() { funWithExactlyOnceCallsInPlace { return@funWithExactlyOnceCallsInPlace @@ -53,6 +55,7 @@ fun case_3() { println("1") } +// TESTCASE NUMBER: 4 fun case_4() { funWithAtLeastOnceCallsInPlace { return@funWithAtLeastOnceCallsInPlace diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/3.kt index 3e2ece97461..bffefa7177c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/3.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 3 - DESCRIPTION: Unreachable code detection using local functions or labdas combined with contract functions with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 3 + * DESCRIPTION: Unreachable code detection using local functions or labdas combined with contract functions with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1() { funWithExactlyOnceCallsInPlace { throw Exception() @@ -18,6 +18,7 @@ fun case_1() { println("1") } +// TESTCASE NUMBER: 2 fun case_2() { funWithAtLeastOnceCallsInPlace { throw Exception() @@ -25,6 +26,7 @@ fun case_2() { println("1") } +// TESTCASE NUMBER: 3 fun case_3() { funWithExactlyOnceCallsInPlace { return @@ -32,6 +34,7 @@ fun case_3() { println("1") } +// TESTCASE NUMBER: 4 fun case_4() { funWithAtLeastOnceCallsInPlace { return @@ -39,6 +42,7 @@ fun case_4() { println("1") } +// TESTCASE NUMBER: 5 fun case_5(args: Array) { fun nestedFun_1() { funWithAtLeastOnceCallsInPlace { @@ -65,6 +69,7 @@ fun case_5(args: Array) { } } +// TESTCASE NUMBER: 6 fun case_6(args: Array) { args.forEach { funWithExactlyOnceCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/4.kt index 10cf42d0e9f..3ac06d77619 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/4.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 4 - DESCRIPTION: Unreachable code detection using nested contract functions with CallsInPlace effect + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 4 + * DESCRIPTION: Unreachable code detection using nested contract functions with CallsInPlace effect */ +// TESTCASE NUMBER: 1 fun case_1() { funWithExactlyOnceCallsInPlace { funWithExactlyOnceCallsInPlace { @@ -24,6 +24,7 @@ fun case_1() { println("3") } +// TESTCASE NUMBER: 2 fun case_2() { funWithAtLeastOnceCallsInPlace { funWithAtLeastOnceCallsInPlace label_1@ { @@ -40,6 +41,7 @@ fun case_2() { println("3") } +// TESTCASE NUMBER: 3 fun case_3() { funWithExactlyOnceCallsInPlace { funWithExactlyOnceCallsInPlace { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/5.kt index 7c129d1a41a..1eb1bf9da22 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/5.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 5 - DESCRIPTION: Unreachable code detection using contract functions with complex control flow inside + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 5 + * DESCRIPTION: Unreachable code detection using contract functions with complex control flow inside */ +// TESTCASE NUMBER: 1 fun case_1(b: Boolean?) { funWithExactlyOnceCallsInPlace { if (b == null) return @@ -30,6 +30,7 @@ fun case_1(b: Boolean?) { println(3) } +// TESTCASE NUMBER: 2 fun case_2(b: Boolean?, c: Boolean) { funWithAtLeastOnceCallsInPlace { when (b) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/6.kt index 2fac370dad4..ae04c8acb32 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/6.kt @@ -3,14 +3,14 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 6 - DESCRIPTION: Check for lack of unreachable code report when in complex control flow of contract function lambda not all branches are doing non-local return + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 6 + * DESCRIPTION: Check for lack of unreachable code report when in complex control flow of contract function lambda not all branches are doing non-local return */ +// TESTCASE NUMBER: 1 fun case_1(b: Boolean?, c: Boolean) { funWithExactlyOnceCallsInPlace { if (b == null) return @@ -38,6 +38,7 @@ fun case_1(b: Boolean?, c: Boolean) { println(3) } +// TESTCASE NUMBER: 2 fun case_2(b: Boolean?, c: Boolean) { funWithAtLeastOnceCallsInPlace { when (b) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/7.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/7.kt index 806b985134e..55e6e9d94df 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/7.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/controlFlow/unreachableCode/pos/7.kt @@ -1,13 +1,12 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, controlFlow, unreachableCode - NUMBER: 7 - DESCRIPTION: Smart initialization with correspond contract function with default value before lambda. - ISSUES: KT-26444 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, controlFlow, unreachableCode + * NUMBER: 7 + * DESCRIPTION: Smart initialization with correspond contract function with default value before lambda. + * ISSUES: KT-26444 */ // FILE: contracts.kt @@ -16,15 +15,17 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(x: Double = 1.0, block: () -> Unit): Double { contract { callsInPlace(block, InvocationKind.AT_LEAST_ONCE) } return x } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1() { contracts.case_1 { throw Exception() } println(1) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/1.kt index 9768259476c..7e98cef4df8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/1.kt @@ -3,44 +3,50 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 1 - DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract). + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 1 + * DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract). */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { funWithReturns(value_1 !is String) println(value_1.length) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?) { funWithReturnsAndInvertCondition(value_1 != null) println(value_1.inc()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?) { funWithReturns(value_1 == null) println(value_1.inc()) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?) { funWithReturnsAndInvertTypeCheck(value_1) println(value_1.length) } +// TESTCASE NUMBER: 5 fun case_5(value_1: String?) { funWithReturnsAndNullCheck(value_1) println(value_1.length) } +// TESTCASE NUMBER: 6 fun case_6(value_1: String?) { funWithReturnsAndNullCheck(value_1) println(value_1.length) } +// TESTCASE NUMBER: 7 object case_7_object { val prop_1: Int? = 10 } @@ -49,6 +55,7 @@ fun case_7() { case_7_object.prop_1.inc() } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?) { if (!funWithReturnsTrue(value_1 is String)) println(value_1.length) if (!funWithReturnsTrueAndInvertCondition(value_1 !is String)) println(value_1.length) @@ -60,6 +67,7 @@ fun case_8(value_1: Any?) { if (funWithReturnsNull(value_1 is String) != null) println(value_1.length) } +// TESTCASE NUMBER: 9 fun case_9(value_1: String?) { if (!funWithReturnsTrue(value_1 != null)) println(value_1.length) if (!funWithReturnsTrueAndInvertCondition(value_1 == null)) println(value_1.length) @@ -71,6 +79,7 @@ fun case_9(value_1: String?) { if (funWithReturnsNullAndInvertCondition(value_1 == null) != null) println(value_1.length) } +// TESTCASE NUMBER: 10 fun case_10(value_1: Any?) { if (!funWithReturnsTrueAndTypeCheck(value_1)) println(value_1.length) if (!!funWithReturnsFalseAndTypeCheck(value_1)) println(value_1.length) @@ -80,6 +89,7 @@ fun case_10(value_1: Any?) { if (!(funWithReturnsNullAndTypeCheck(value_1) == null)) println(value_1.length) } +// TESTCASE NUMBER: 11 fun case_11(value_1: Number?) { if (!funWithReturnsTrueAndNotNullCheck(value_1)) println(value_1.toByte()) if (!funWithReturnsTrueAndNullCheck(value_1)) println(value_1) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.kt index cfff5384938..15ca4b43520 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.kt @@ -2,13 +2,12 @@ // !WITH_CONTRACT_FUNCTIONS /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 10 - DESCRIPTION: Check smartcasts using double negation (returnsFalse/invert type checking/not operator). - ISSUES: KT-26176 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 10 + * DESCRIPTION: Check smartcasts using double negation (returnsFalse/invert type checking/not operator). + * ISSUES: KT-26176 */ // FILE: contracts.kt @@ -17,204 +16,222 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { contract { returns(true) implies (x !is Number) } return x !is Number } +// TESTCASE NUMBER: 2 fun case_2(x: Any?): Boolean { contract { returns(true) implies (x !is Number?) } return x !is Number? } -fun case_16_1(value_1: Any?, value_2: Any?): Boolean { +// TESTCASE NUMBER: 15 +fun case_15_1(value_1: Any?, value_2: Any?): Boolean { contract { returns(true) implies (value_1 !is String || value_2 !is Number) } return value_1 !is String || value_2 !is Number } -fun case_16_2(value_1: Any?, value_2: Any?): Boolean { +fun case_15_2(value_1: Any?, value_2: Any?): Boolean { contract { returns(false) implies (value_1 !is String || value_2 !is Number) } return !(value_1 !is String || value_2 !is Number) } -fun case_16_3(value_1: Any?, value_2: Any?): Boolean? { +fun case_15_3(value_1: Any?, value_2: Any?): Boolean? { contract { returnsNotNull() implies (value_1 !is String || value_2 !is Number) } return if (value_1 !is String || value_2 !is Number) true else null } -fun case_16_4(value_1: Any?, value_2: Any?): Boolean? { +fun case_15_4(value_1: Any?, value_2: Any?): Boolean? { contract { returns(null) implies (value_1 !is String || value_2 !is Number) } return if (value_1 !is String || value_2 !is Number) null else true } -fun case_17_1(value_1: Any?, value_2: Any?): Boolean { +// TESTCASE NUMBER: 16 +fun case_16_1(value_1: Any?, value_2: Any?): Boolean { contract { returns(true) implies (value_1 !is String || value_2 != null) } return value_1 !is String || value_2 != null } -fun case_17_2(value_1: Any?, value_2: Any?): Boolean { +fun case_16_2(value_1: Any?, value_2: Any?): Boolean { contract { returns(false) implies (value_1 !is String || value_2 != null) } return !(value_1 !is String || value_2 != null) } -fun case_17_3(value_1: Any?, value_2: Any?): Boolean? { +fun case_16_3(value_1: Any?, value_2: Any?): Boolean? { contract { returnsNotNull() implies (value_1 !is String || value_2 != null) } return if (value_1 !is String || value_2 != null) true else null } -fun case_17_4(value_1: Any?, value_2: Any?): Boolean? { +fun case_16_4(value_1: Any?, value_2: Any?): Boolean? { contract { returns(null) implies (value_1 !is String || value_2 != null) } return if (value_1 !is String || value_2 != null) null else true } -fun case_18_1(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { +// TESTCASE NUMBER: 17 +fun case_17_1(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { contract { returns(true) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } return value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null } -fun case_18_2(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { +fun case_17_2(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { contract { returns(false) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } return !(value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } -fun case_18_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? { +fun case_17_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? { contract { returnsNotNull() implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } return if (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) true else null } -fun case_18_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? { +fun case_17_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean? { contract { returns(null) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } return if (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) null else true } -fun T.case_19_1(): Boolean { - contract { returns(true) implies (this@case_19_1 !is String) } - return this@case_19_1 !is String +// TESTCASE NUMBER: 18 +fun T.case_18_1(): Boolean { + contract { returns(true) implies (this@case_18_1 !is String) } + return this@case_18_1 !is String } -fun T.case_19_2(): Boolean { - contract { returns(false) implies (this@case_19_2 is String) } - return !(this@case_19_2 is String) +fun T.case_18_2(): Boolean { + contract { returns(false) implies (this@case_18_2 is String) } + return !(this@case_18_2 is String) } -fun T.case_19_3(): Boolean? { - contract { returnsNotNull() implies (this@case_19_3 is String) } - return if (this@case_19_3 is String) true else null +fun T.case_18_3(): Boolean? { + contract { returnsNotNull() implies (this@case_18_3 is String) } + return if (this@case_18_3 is String) true else null } -fun T.case_19_4(): Boolean? { - contract { returns(null) implies (this@case_19_4 is String) } - return if (this@case_19_4 is String) null else true +fun T.case_18_4(): Boolean? { + contract { returns(null) implies (this@case_18_4 is String) } + return if (this@case_18_4 is String) null else true } -fun T.case_20_1(): Boolean { - contract { returns(true) implies (this@case_20_1 !is Int) } - return this@case_20_1 !is Int +// TESTCASE NUMBER: 19 +fun T.case_19_1(): Boolean { + contract { returns(true) implies (this@case_19_1 !is Int) } + return this@case_19_1 !is Int } -fun T.case_20_2(): Boolean { - contract { returns(false) implies (this@case_20_2 is Int) } - return !(this@case_20_2 is Int) +fun T.case_19_2(): Boolean { + contract { returns(false) implies (this@case_19_2 is Int) } + return !(this@case_19_2 is Int) } -fun T.case_20_3(): Boolean? { - contract { returnsNotNull() implies (this@case_20_3 is Int) } - return if (this@case_20_3 is Int) true else null +fun T.case_19_3(): Boolean? { + contract { returnsNotNull() implies (this@case_19_3 is Int) } + return if (this@case_19_3 is Int) true else null } -fun T.case_20_4(): Boolean? { - contract { returns(null) implies (this@case_20_4 is Int) } - return if (this@case_20_4 is Int) null else true +fun T.case_19_4(): Boolean? { + contract { returns(null) implies (this@case_19_4 is Int) } + return if (this@case_19_4 is Int) null else true } -fun String> T?.case_21_1(): Boolean { +// TESTCASE NUMBER: 20 +fun String> T?.case_20_1(): Boolean { + contract { returns(true) implies (this@case_20_1 != null) } + return this@case_20_1 != null +} +fun String> T?.case_20_2(): Boolean { + contract { returns(true) implies (this@case_20_2 == null) } + return this@case_20_2 == null +} +fun String> T?.case_20_3(): Boolean { + contract { returns(false) implies (this@case_20_3 != null) } + return !(this@case_20_3 != null) +} + +// TESTCASE NUMBER: 21 +fun T.case_21_1(): Boolean { contract { returns(true) implies (this@case_21_1 != null) } return this@case_21_1 != null } -fun String> T?.case_21_2(): Boolean { +fun T.case_21_2(): Boolean { contract { returns(true) implies (this@case_21_2 == null) } return this@case_21_2 == null } -fun String> T?.case_21_3(): Boolean { - contract { returns(false) implies (this@case_21_3 != null) } - return !(this@case_21_3 != null) +fun String> T?.case_21_5(): Boolean? { + contract { returnsNotNull() implies (this@case_21_5 != null) } + return if (this@case_21_5 != null) true else null +} +fun String> T?.case_21_7(): Boolean? { + contract { returns(null) implies (this@case_21_7 != null) } + return if (this@case_21_7 != null) null else true } -fun T.case_22_1(): Boolean { - contract { returns(true) implies (this@case_22_1 != null) } - return this@case_22_1 != null +// TESTCASE NUMBER: 22 +fun T?.case_22_1(): Boolean { + contract { returns(false) implies (this@case_22_1 == null || this@case_22_1 !is String) } + return !(this@case_22_1 == null || this@case_22_1 !is String) } -fun T.case_22_2(): Boolean { - contract { returns(true) implies (this@case_22_2 == null) } - return this@case_22_2 == null +fun T?.case_22_2(): Boolean? { + contract { returnsNotNull() implies (this@case_22_2 == null || this@case_22_2 !is String) } + return if (this@case_22_2 == null || this@case_22_2 !is String) true else null } -fun String> T?.case_22_5(): Boolean? { - contract { returnsNotNull() implies (this@case_22_5 != null) } - return if (this@case_22_5 != null) true else null -} -fun String> T?.case_22_7(): Boolean? { - contract { returns(null) implies (this@case_22_7 != null) } - return if (this@case_22_7 != null) null else true +fun T?.case_22_3(): Boolean? { + contract { returns(null) implies (this@case_22_3 == null || this@case_22_3 !is String) } + return if (this@case_22_3 == null || this@case_22_3 !is String) null else true } -fun T?.case_23_1(): Boolean { - contract { returns(false) implies (this@case_23_1 == null || this@case_23_1 !is String) } - return !(this@case_23_1 == null || this@case_23_1 !is String) +// TESTCASE NUMBER: 23 +fun T.case_23_1(): Boolean { + contract { returns(false) implies (this@case_23_1 !is Int || this@case_23_1 == null) } + return !(this@case_23_1 !is Int || this@case_23_1 == null) } -fun T?.case_23_2(): Boolean? { - contract { returnsNotNull() implies (this@case_23_2 == null || this@case_23_2 !is String) } - return if (this@case_23_2 == null || this@case_23_2 !is String) true else null +fun T.case_23_2(): Boolean? { + contract { returnsNotNull() implies (this@case_23_2 !is Int || this@case_23_2 == null) } + return if (this@case_23_2 !is Int || this@case_23_2 == null) true else null } -fun T?.case_23_3(): Boolean? { - contract { returns(null) implies (this@case_23_3 == null || this@case_23_3 !is String) } - return if (this@case_23_3 == null || this@case_23_3 !is String) null else true +fun T.case_23_3(): Boolean? { + contract { returns(null) implies (this@case_23_3 !is Int || this@case_23_3 == null) } + return if (this@case_23_3 !is Int || this@case_23_3 == null) null else true } -fun T.case_24_1(): Boolean { - contract { returns(false) implies (this@case_24_1 !is Int || this@case_24_1 == null) } - return !(this@case_24_1 !is Int || this@case_24_1 == null) +// TESTCASE NUMBER: 24 +inline fun T?.case_24_1(): Boolean { + contract { returns(false) implies (this@case_24_1 !is Number || this@case_24_1 !is Int || this@case_24_1 == null) } + return !(this@case_24_1 !is Number || this@case_24_1 !is Int || this@case_24_1 == null) } -fun T.case_24_2(): Boolean? { - contract { returnsNotNull() implies (this@case_24_2 !is Int || this@case_24_2 == null) } - return if (this@case_24_2 !is Int || this@case_24_2 == null) true else null +inline fun T?.case_24_2(): Boolean? { + contract { returnsNotNull() implies (this@case_24_2 !is Number || this@case_24_2 !is Int || this@case_24_2 == null) } + return if (this@case_24_2 !is Number || this@case_24_2 !is Int || this@case_24_2 == null) true else null } -fun T.case_24_3(): Boolean? { - contract { returns(null) implies (this@case_24_3 !is Int || this@case_24_3 == null) } - return if (this@case_24_3 !is Int || this@case_24_3 == null) null else true +inline fun T?.case_24_3(): Boolean? { + contract { returns(null) implies (this@case_24_3 !is Number || this@case_24_3 !is Int || this@case_24_3 == null) } + return if (this@case_24_3 !is Number || this@case_24_3 !is Int || this@case_24_3 == null) null else true } -inline fun T?.case_25_1(): Boolean { - contract { returns(false) implies (this@case_25_1 !is Number || this@case_25_1 !is Int || this@case_25_1 == null) } - return !(this@case_25_1 !is Number || this@case_25_1 !is Int || this@case_25_1 == null) +// TESTCASE NUMBER: 25 +fun T?.case_25_1(value_1: Int?): Boolean { + contract { returns(false) implies (this@case_25_1 == null || this@case_25_1 !is String || value_1 == null) } + return !(this@case_25_1 == null || this@case_25_1 !is String || value_1 == null) } -inline fun T?.case_25_2(): Boolean? { - contract { returnsNotNull() implies (this@case_25_2 !is Number || this@case_25_2 !is Int || this@case_25_2 == null) } - return if (this@case_25_2 !is Number || this@case_25_2 !is Int || this@case_25_2 == null) true else null +fun T?.case_25_2(value_1: Int?): Boolean? { + contract { returnsNotNull() implies (this@case_25_2 == null || this@case_25_2 !is String || value_1 == null) } + return if (this@case_25_2 == null || this@case_25_2 !is String || value_1 == null) true else null } -inline fun T?.case_25_3(): Boolean? { - contract { returns(null) implies (this@case_25_3 !is Number || this@case_25_3 !is Int || this@case_25_3 == null) } - return if (this@case_25_3 !is Number || this@case_25_3 !is Int || this@case_25_3 == null) null else true +fun T?.case_25_3(value_1: Int?): Boolean? { + contract { returns(null) implies (this@case_25_3 == null || this@case_25_3 !is String || value_1 == null) } + return if (this@case_25_3 == null || this@case_25_3 !is String || value_1 == null) null else true } -fun T?.case_26_1(value_1: Int?): Boolean { - contract { returns(false) implies (this@case_26_1 == null || this@case_26_1 !is String || value_1 == null) } - return !(this@case_26_1 == null || this@case_26_1 !is String || value_1 == null) -} -fun T?.case_26_2(value_1: Int?): Boolean? { - contract { returnsNotNull() implies (this@case_26_2 == null || this@case_26_2 !is String || value_1 == null) } - return if (this@case_26_2 == null || this@case_26_2 !is String || value_1 == null) true else null -} -fun T?.case_26_3(value_1: Int?): Boolean? { - contract { returns(null) implies (this@case_26_3 == null || this@case_26_3 !is String || value_1 == null) } - return if (this@case_26_3 == null || this@case_26_3 !is String || value_1 == null) null else true -} - -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { - if (!contracts.case_1(value_1)) println(value_1.toByte()) // no smartcast + if (!contracts.case_1(value_1)) println(value_1.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) { - if (!contracts.case_2(value_1)) println(value_1?.toByte()) // no smartcast + if (!contracts.case_2(value_1)) println(value_1?.toByte()) } +// TESTCASE NUMBER: 3 fun case_3(number: Int?) { - if (!funWithReturnsTrueAndNullCheck(number)) number.inc() // nullable receiver + if (!funWithReturnsTrueAndNullCheck(number)) number.inc() } -fun case_5(value_1: Any?) { +// TESTCASE NUMBER: 4 +fun case_4(value_1: Any?) { if (!funWithReturnsTrue(value_1 !is String)) println(value_1.length) } -fun case_6(value_1: Any?) { +// TESTCASE NUMBER: 5 +fun case_5(value_1: Any?) { if (!funWithReturnsTrueAndInvertCondition(value_1 is String)) println(value_1.length) if (funWithReturnsFalse(value_1 !is String)) println(value_1.length) if (funWithReturnsFalseAndInvertCondition(value_1 is String)) println(value_1.length) @@ -222,22 +239,26 @@ fun case_6(value_1: Any?) { if (!(funWithReturnsNullAndInvertCondition(value_1 !is String) == null)) println(value_1.length) } -fun case_7(value_1: Any?) { +// TESTCASE NUMBER: 6 +fun case_6(value_1: Any?) { if (!funWithReturnsTrue(value_1 == null)) println(value_1.length) } -fun case_8(value_1: Any?) { +// TESTCASE NUMBER: 7 +fun case_7(value_1: Any?) { if (!funWithReturnsTrueAndInvertCondition(value_1 != null)) println(value_1.length) if (funWithReturnsFalse(value_1 == null)) println(value_1.length) if (funWithReturnsFalseAndInvertCondition(value_1 != null)) println(value_1.length) } -fun case_9(value_1: Any?) { +// TESTCASE NUMBER: 8 +fun case_8(value_1: Any?) { if (!funWithReturnsTrueAndInvertTypeCheck(value_1)) println(value_1.length) if (funWithReturnsFalseAndInvertTypeCheck(value_1)) println(value_1.length) } -fun case_10(value_1: Number?) { +// TESTCASE NUMBER: 9 +fun case_9(value_1: Number?) { if (!funWithReturnsTrueAndNullCheck(value_1)) println(value_1.toByte()) if (funWithReturnsFalseAndNullCheck(value_1)) println(value_1.toByte()) if (funWithReturnsFalseAndNotNullCheck(value_1)) println(value_1) @@ -245,14 +266,16 @@ fun case_10(value_1: Number?) { if (!(funWithReturnsNullAndNullCheck(value_1) == null)) println(value_1) } -fun case_11(value_1: Any?, value_2: Any?) { +// TESTCASE NUMBER: 10 +fun case_10(value_1: Any?, value_2: Any?) { if (!funWithReturnsTrueAndInvertCondition(value_1 is String && value_2 is Number)) { println(value_1.length) println(value_2.toByte()) } } -fun case_12(value_1: Any?, value_2: Any?) { +// TESTCASE NUMBER: 11 +fun case_11(value_1: Any?, value_2: Any?) { if (!funWithReturnsTrue(value_1 !is String || value_2 !is Number)) { println(value_1.length) println(value_2.toByte()) @@ -263,7 +286,8 @@ fun case_12(value_1: Any?, value_2: Any?) { } } -fun case_13(value_1: Any?, value_2: Any?) { +// TESTCASE NUMBER: 12 +fun case_12(value_1: Any?, value_2: Any?) { if (!funWithReturnsTrue(value_1 !is String || value_2 != null)) { println(value_1.length) println(value_2?.toByte()) @@ -282,7 +306,8 @@ fun case_13(value_1: Any?, value_2: Any?) { } } -fun case_14(value_1: Any?, value_2: Any?) { +// TESTCASE NUMBER: 13 +fun case_13(value_1: Any?, value_2: Any?) { if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null)) { println(value_1.dec()) println(value_2?.toByte()) @@ -321,11 +346,12 @@ fun case_14(value_1: Any?, value_2: Any?) { } } -class case_15_class { +// TESTCASE NUMBER: 14 +class case_14_class { val prop_1: Int? = 10 - fun case_15(value_1: Any?, value_2: Number?) { - val o = case_15_class() + fun case_14(value_1: Any?, value_2: Number?) { + val o = case_14_class() if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null)) { println(value_1.dec()) println(value_2?.toByte()) @@ -349,67 +375,71 @@ class case_15_class { } } +// TESTCASE NUMBER: 15 +fun case_15(value_1: Any?, value_2: Any?) { + if (!contracts.case_15_1(value_1, value_2)) { + println(value_1.length) + println(value_2.toByte()) + } + if (contracts.case_15_2(value_1, value_2)) { + println(value_1.length) + println(value_2.toByte()) + } + if (!(contracts.case_15_3(value_1, value_2) != null)) { + println(value_1.length) + println(value_2.toByte()) + } + if (!(contracts.case_15_4(value_1, value_2) == null)) { + println(value_1.length) + println(value_2.toByte()) + } +} + +// TESTCASE NUMBER: 16 fun case_16(value_1: Any?, value_2: Any?) { if (!contracts.case_16_1(value_1, value_2)) { println(value_1.length) - println(value_2.toByte()) + println(value_2?.toByte()) } if (contracts.case_16_2(value_1, value_2)) { println(value_1.length) - println(value_2.toByte()) + println(value_2?.toByte()) } - if (!(contracts.case_16_3(value_1, value_2) != null)) { - println(value_1.length) - println(value_2.toByte()) - } - if (!(contracts.case_16_4(value_1, value_2) == null)) { - println(value_1.length) - println(value_2.toByte()) - } -} - -fun case_17(value_1: Any?, value_2: Any?) { - if (!contracts.case_17_1(value_1, value_2)) { + if (contracts.case_16_3(value_1, value_2) == null) { println(value_1.length) println(value_2?.toByte()) } - if (contracts.case_17_2(value_1, value_2)) { - println(value_1.length) - println(value_2?.toByte()) - } - if (contracts.case_17_3(value_1, value_2) == null) { - println(value_1.length) - println(value_2?.toByte()) - } - if (contracts.case_17_4(value_1, value_2) != null) { + if (contracts.case_16_4(value_1, value_2) != null) { println(value_1.length) println(value_2?.toByte()) } } -class case_18_class { +// TESTCASE NUMBER: 17 +class case_17_class { val prop_1: Int? = 10 - fun case_18(value_1: Any?, value_2: Number?) { - val o = case_18_class() - if (contracts.case_18_1(value_1, value_2, o.prop_1, this.prop_1)) { + + fun case_17(value_1: Any?, value_2: Number?) { + val o = case_17_class() + if (contracts.case_17_1(value_1, value_2, o.prop_1, this.prop_1)) { println(value_1.dec()) println(value_2?.toByte()) println(o.prop_1.plus(3)) println(this.prop_1.plus(3)) } - if (contracts.case_18_2(value_1, value_2, o.prop_1, this.prop_1)) { + if (contracts.case_17_2(value_1, value_2, o.prop_1, this.prop_1)) { println(value_1.dec()) println(value_2?.toByte()) println(o.prop_1.plus(3)) println(this.prop_1.plus(3)) } - if (contracts.case_18_3(value_1, value_2, o.prop_1, this.prop_1) == null) { + if (contracts.case_17_3(value_1, value_2, o.prop_1, this.prop_1) == null) { println(value_1.dec()) println(value_2?.toByte()) println(o.prop_1.plus(3)) println(this.prop_1.plus(3)) } - if (contracts.case_18_4(value_1, value_2, o.prop_1, this.prop_1) != null) { + if (contracts.case_17_4(value_1, value_2, o.prop_1, this.prop_1) != null) { println(value_1.dec()) println(value_2?.toByte()) println(o.prop_1.plus(3)) @@ -418,75 +448,83 @@ class case_18_class { } } -fun case_19(value_1: Any?) { - if (!value_1.case_19_1()) println(value_1.length) - if (value_1.case_19_2()) println(value_1.length) - if (value_1.case_19_3() == null) println(value_1.length) - if (value_1.case_19_4() != null) println(value_1.length) +// TESTCASE NUMBER: 18 +fun case_18(value_1: Any?) { + if (!value_1.case_18_1()) println(value_1.length) + if (value_1.case_18_2()) println(value_1.length) + if (value_1.case_18_3() == null) println(value_1.length) + if (value_1.case_18_4() != null) println(value_1.length) } -fun case_20(value_1: Number) { - when { !value_1.case_20_1() -> println(value_1.inv()) } - when { value_1.case_20_2() -> println(value_1.inv()) } - when { value_1.case_20_3() == null -> println(value_1.inv()) } - when { value_1.case_20_4() != null -> println(value_1.inv()) } +// TESTCASE NUMBER: 19 +fun case_19(value_1: Number) { + when { !value_1.case_19_1() -> println(value_1.inv()) } + when { value_1.case_19_2() -> println(value_1.inv()) } + when { value_1.case_19_3() == null -> println(value_1.inv()) } + when { value_1.case_19_4() != null -> println(value_1.inv()) } } -fun case_21(value_1: String?, value_2: String?, value_3: String?, value_4: String?) { - if (!value_1.case_21_1()) println(value_1) - if (!value_2.case_21_2()) println(value_2.length) - when (value_3.case_21_3()) { +// TESTCASE NUMBER: 20 +fun case_20(value_1: String?, value_2: String?, value_3: String?, value_4: String?) { + if (!value_1.case_20_1()) println(value_1) + if (!value_2.case_20_2()) println(value_2.length) + when (value_3.case_20_3()) { true -> println(value_4.length) false -> println(value_3) } } -fun case_22(value_1: String?) { - when { !value_1.case_22_1() -> println(value_1) } - when { !value_1.case_22_2() -> println(value_1.length) } +// TESTCASE NUMBER: 21 +fun case_21(value_1: String?) { + when { !value_1.case_21_1() -> println(value_1) } + when { !value_1.case_21_2() -> println(value_1.length) } when { - value_1.case_22_5() == null -> println(value_1.length) - value_1.case_22_5() != null -> println(value_1) + value_1.case_21_5() == null -> println(value_1.length) + value_1.case_21_5() != null -> println(value_1) } when { - value_1.case_22_7() != null -> println(value_1.length) - value_1.case_22_7() == null -> println(value_1) + value_1.case_21_7() != null -> println(value_1.length) + value_1.case_21_7() == null -> println(value_1) } } -fun case_23(value_1: Any?, value_2: Any?) { - when { value_1.case_23_1() -> println(value_1.length) } - when { value_2.case_23_2() == null -> println(value_2.length) } - when { value_2.case_23_3() != null -> println(value_2.length) } +// TESTCASE NUMBER: 22 +fun case_22(value_1: Any?, value_2: Any?) { + when { value_1.case_22_1() -> println(value_1.length) } + when { value_2.case_22_2() == null -> println(value_2.length) } + when { value_2.case_22_3() != null -> println(value_2.length) } } -fun case_24(value_1: Number?, value_2: Number?) { +// TESTCASE NUMBER: 23 +fun case_23(value_1: Number?, value_2: Number?) { + if (value_1.case_23_1()) println(value_1.inv()) + if (value_2.case_23_2() == null) println(value_2.inv()) + if (value_2.case_23_3() != null) println(value_2.inv()) +} + +// TESTCASE NUMBER: 24 +fun case_24(value_1: Any?, value_2: Any?) { if (value_1.case_24_1()) println(value_1.inv()) - if (value_2.case_24_2() == null) println(value_2.inv()) - if (value_2.case_24_3() != null) println(value_2.inv()) + if (value_2.case_24_2() != null) println(value_2.inv()) + if (value_2.case_24_3() == null) println(value_2.inv()) } -fun case_25(value_1: Any?, value_2: Any?) { - if (value_1.case_25_1()) println(value_1.inv()) - if (value_2.case_25_2() != null) println(value_2.inv()) - if (value_2.case_25_3() == null) println(value_2.inv()) -} - -fun case_26(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?) { +// TESTCASE NUMBER: 25 +fun case_25(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?) { when { - value_1.case_26_1(value_2) -> { + value_1.case_25_1(value_2) -> { println(value_1.length) println(value_2.inv()) } } when { - value_3.case_26_2(value_4) == null -> { + value_3.case_25_2(value_4) == null -> { println(value_3.length) println(value_4.inv()) } } when { - value_3.case_26_3(value_4) != null -> { + value_3.case_25_3(value_4) != null -> { println(value_3.length) println(value_4.inv()) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.txt index 38cae413c7e..f03b98da940 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.txt @@ -1,28 +1,28 @@ package public fun case_1(/*0*/ value_1: kotlin.Any?): kotlin.Unit -public fun case_10(/*0*/ value_1: kotlin.Number?): kotlin.Unit +public fun case_10(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit public fun case_11(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit public fun case_12(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit public fun case_13(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit -public fun case_14(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit +public fun case_15(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit public fun case_16(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit -public fun case_17(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit -public fun case_19(/*0*/ value_1: kotlin.Any?): kotlin.Unit +public fun case_18(/*0*/ value_1: kotlin.Any?): kotlin.Unit +public fun case_19(/*0*/ value_1: kotlin.Number): kotlin.Unit public fun case_2(/*0*/ value_1: kotlin.Any?): kotlin.Unit -public fun case_20(/*0*/ value_1: kotlin.Number): kotlin.Unit -public fun case_21(/*0*/ value_1: kotlin.String?, /*1*/ value_2: kotlin.String?, /*2*/ value_3: kotlin.String?, /*3*/ value_4: kotlin.String?): kotlin.Unit -public fun case_22(/*0*/ value_1: kotlin.String?): kotlin.Unit -public fun case_23(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit -public fun case_24(/*0*/ value_1: kotlin.Number?, /*1*/ value_2: kotlin.Number?): kotlin.Unit -public fun case_25(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit -public fun case_26(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Int?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Int?): kotlin.Unit +public fun case_20(/*0*/ value_1: kotlin.String?, /*1*/ value_2: kotlin.String?, /*2*/ value_3: kotlin.String?, /*3*/ value_4: kotlin.String?): kotlin.Unit +public fun case_21(/*0*/ value_1: kotlin.String?): kotlin.Unit +public fun case_22(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit +public fun case_23(/*0*/ value_1: kotlin.Number?, /*1*/ value_2: kotlin.Number?): kotlin.Unit +public fun case_24(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Unit +public fun case_25(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Int?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Int?): kotlin.Unit public fun case_3(/*0*/ number: kotlin.Int?): kotlin.Unit +public fun case_4(/*0*/ value_1: kotlin.Any?): kotlin.Unit public fun case_5(/*0*/ value_1: kotlin.Any?): kotlin.Unit public fun case_6(/*0*/ value_1: kotlin.Any?): kotlin.Unit public fun case_7(/*0*/ value_1: kotlin.Any?): kotlin.Unit public fun case_8(/*0*/ value_1: kotlin.Any?): kotlin.Unit -public fun case_9(/*0*/ value_1: kotlin.Any?): kotlin.Unit +public fun case_9(/*0*/ value_1: kotlin.Number?): kotlin.Unit public inline fun funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> T): T CallsInPlace(block, AT_LEAST_ONCE) @@ -131,19 +131,19 @@ public fun funWithReturnsTrueAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Bo public inline fun funWithUnknownCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit CallsInPlace(block, UNKNOWN) -public final class case_15_class { - public constructor case_15_class() +public final class case_14_class { + public constructor case_14_class() public final val prop_1: kotlin.Int? = 10 - public final fun case_15(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit + public final fun case_14(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class case_18_class { - public constructor case_18_class() +public final class case_17_class { + public constructor case_17_class() public final val prop_1: kotlin.Int? = 10 - public final fun case_18(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit + public final fun case_17(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Number?): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -153,124 +153,124 @@ package contracts { public fun case_1(/*0*/ x: kotlin.Any?): kotlin.Boolean Returns(TRUE) -> x !is Number - public fun case_16_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean + public fun case_15_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean Returns(TRUE) -> value_1 !is String || value_2 !is Number - public fun case_16_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean + public fun case_15_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean Returns(FALSE) -> value_1 !is String || value_2 !is Number - public fun case_16_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? + public fun case_15_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? Returns(NOT_NULL) -> value_1 !is String || value_2 !is Number - public fun case_16_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? + public fun case_15_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? Returns(NULL) -> value_1 !is String || value_2 !is Number - public fun case_17_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean + public fun case_16_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean Returns(TRUE) -> value_1 !is String || value_2 != null - public fun case_17_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean + public fun case_16_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean Returns(FALSE) -> value_1 !is String || value_2 != null - public fun case_17_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? + public fun case_16_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? Returns(NOT_NULL) -> value_1 !is String || value_2 != null - public fun case_17_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? + public fun case_16_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?): kotlin.Boolean? Returns(NULL) -> value_1 !is String || value_2 != null - public fun case_18_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean + public fun case_17_1(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean Returns(TRUE) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null - public fun case_18_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean + public fun case_17_2(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean Returns(FALSE) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null - public fun case_18_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean? + public fun case_17_3(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean? Returns(NOT_NULL) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null - public fun case_18_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean? + public fun case_17_4(/*0*/ value_1: kotlin.Any?, /*1*/ value_2: kotlin.Any?, /*2*/ value_3: kotlin.Any?, /*3*/ value_4: kotlin.Any?): kotlin.Boolean? Returns(NULL) -> value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null public fun case_2(/*0*/ x: kotlin.Any?): kotlin.Boolean Returns(TRUE) -> x !is Number? - public fun T.case_19_1(): kotlin.Boolean + public fun T.case_18_1(): kotlin.Boolean Returns(TRUE) -> !is String - public fun T.case_19_2(): kotlin.Boolean + public fun T.case_18_2(): kotlin.Boolean Returns(FALSE) -> is String - public fun T.case_19_3(): kotlin.Boolean? + public fun T.case_18_3(): kotlin.Boolean? Returns(NOT_NULL) -> is String - public fun T.case_19_4(): kotlin.Boolean? + public fun T.case_18_4(): kotlin.Boolean? Returns(NULL) -> is String - public fun T.case_20_1(): kotlin.Boolean + public fun T.case_19_1(): kotlin.Boolean Returns(TRUE) -> !is Int - public fun T.case_20_2(): kotlin.Boolean + public fun T.case_19_2(): kotlin.Boolean Returns(FALSE) -> is Int - public fun T.case_20_3(): kotlin.Boolean? + public fun T.case_19_3(): kotlin.Boolean? Returns(NOT_NULL) -> is Int - public fun T.case_20_4(): kotlin.Boolean? + public fun T.case_19_4(): kotlin.Boolean? Returns(NULL) -> is Int - public fun T?.case_21_1(): kotlin.Boolean + public fun T?.case_20_1(): kotlin.Boolean Returns(TRUE) -> != null - public fun T?.case_21_2(): kotlin.Boolean + public fun T?.case_20_2(): kotlin.Boolean Returns(TRUE) -> == null - public fun T?.case_21_3(): kotlin.Boolean + public fun T?.case_20_3(): kotlin.Boolean Returns(FALSE) -> != null - public fun T.case_22_1(): kotlin.Boolean + public fun T.case_21_1(): kotlin.Boolean Returns(TRUE) -> != null - public fun T.case_22_2(): kotlin.Boolean + public fun T.case_21_2(): kotlin.Boolean Returns(TRUE) -> == null - public fun T?.case_22_5(): kotlin.Boolean? + public fun T?.case_21_5(): kotlin.Boolean? Returns(NOT_NULL) -> != null - public fun T?.case_22_7(): kotlin.Boolean? + public fun T?.case_21_7(): kotlin.Boolean? Returns(NULL) -> != null - public fun T?.case_23_1(): kotlin.Boolean + public fun T?.case_22_1(): kotlin.Boolean Returns(FALSE) -> == null || !is String - public fun T?.case_23_2(): kotlin.Boolean? + public fun T?.case_22_2(): kotlin.Boolean? Returns(NOT_NULL) -> == null || !is String - public fun T?.case_23_3(): kotlin.Boolean? + public fun T?.case_22_3(): kotlin.Boolean? Returns(NULL) -> == null || !is String - public fun T.case_24_1(): kotlin.Boolean + public fun T.case_23_1(): kotlin.Boolean Returns(FALSE) -> !is Int || == null - public fun T.case_24_2(): kotlin.Boolean? + public fun T.case_23_2(): kotlin.Boolean? Returns(NOT_NULL) -> !is Int || == null - public fun T.case_24_3(): kotlin.Boolean? + public fun T.case_23_3(): kotlin.Boolean? Returns(NULL) -> !is Int || == null - public inline fun T?.case_25_1(): kotlin.Boolean + public inline fun T?.case_24_1(): kotlin.Boolean Returns(FALSE) -> !is Number || !is Int || == null - public inline fun T?.case_25_2(): kotlin.Boolean? + public inline fun T?.case_24_2(): kotlin.Boolean? Returns(NOT_NULL) -> !is Number || !is Int || == null - public inline fun T?.case_25_3(): kotlin.Boolean? + public inline fun T?.case_24_3(): kotlin.Boolean? Returns(NULL) -> !is Number || !is Int || == null - public fun T?.case_26_1(/*0*/ value_1: kotlin.Int?): kotlin.Boolean + public fun T?.case_25_1(/*0*/ value_1: kotlin.Int?): kotlin.Boolean Returns(FALSE) -> == null || !is String || value_1 == null - public fun T?.case_26_2(/*0*/ value_1: kotlin.Int?): kotlin.Boolean? + public fun T?.case_25_2(/*0*/ value_1: kotlin.Int?): kotlin.Boolean? Returns(NOT_NULL) -> == null || !is String || value_1 == null - public fun T?.case_26_3(/*0*/ value_1: kotlin.Int?): kotlin.Boolean? + public fun T?.case_25_3(/*0*/ value_1: kotlin.Int?): kotlin.Boolean? Returns(NULL) -> == null || !is String || value_1 == null } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/11.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/11.kt index 58a0f161cf4..bd095d75a81 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/11.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/11.kt @@ -2,12 +2,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 11 - DESCRIPTION: Smartcast using many of the various Returns effects on the same values. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 11 + * DESCRIPTION: Smartcast using many of the various Returns effects on the same values. */ // FILE: contracts.kt @@ -16,16 +15,17 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1_1(): Boolean { contract { returns(false) implies (this@case_1_1 != null) } return !(this@case_1_1 != null) } - fun T?.case_1_2(): Boolean? { contract { returns(null) implies (this@case_1_2 is String) } return if (this@case_1_2 is String) null else true } +// TESTCASE NUMBER: 2 fun T.case_2_1(): Boolean? { contract { returnsNotNull() implies (this@case_2_1 != null) } return if (this@case_2_1 != null) true else null @@ -35,17 +35,22 @@ fun T.case_2_2(): Boolean? { return if (this@case_2_2 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { if (!(value_1.case_1_1() || value_1.case_1_2() == null)) { println(value_1.length) } } -// DISCUSSION: maybe make unreachable code in the second condition? +/* + * TESTCASE NUMBER: 2 + * DISCUSSION: maybe make the code unreachable in the second condition? + * UNEXPECTED BEHAVIOUR + */ fun case_2(value_1: Number?) { if (value_1?.case_2_1() != null) println(value_1.toByte()) if (value_1?.case_2_2() != null) println(value_1.toByte()) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.kt index a9c4c557ee6..9f9d9bc9781 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.kt @@ -1,14 +1,13 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 12 - DESCRIPTION: Check smartcast to upper bound of the types in disjunction. - UNEXPECTED BEHAVIOUR - ISSUES: KT-1982 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 12 + * DESCRIPTION: Check smartcast to upper bound of the types in disjunction. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-1982 */ // FILE: contracts.kt @@ -17,25 +16,29 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1() { contract { returns() implies (this@case_1 is Number || this@case_1 is Int) } if (!(this@case_1 is Number || this@case_1 is Int)) throw Exception() } +// TESTCASE NUMBER: 2 inline fun T?.case_2(value_2: Number, value_3: Any?, value_4: String?) { contract { returns() implies ((this@case_2 is Number || this@case_2 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) } if (!((this is Number || this is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null)) throw Exception() } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() println(value_1.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_2(value_2, value_3, value_4) println(value_1.toByte()) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/13.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/13.kt index 2a23f9c4af1..91035813118 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/13.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/13.kt @@ -1,15 +1,12 @@ -// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect -// !WITH_CONTRACT_FUNCTIONS -// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts +// !WITH_CONTRACT_FUNCTIONS /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 13 - DESCRIPTION: Smartcast using many of the various Returns effects on the same values. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 13 + * DESCRIPTION: Smartcast using many of the various Returns effects on the same values. */ // FILE: contracts.kt @@ -18,30 +15,31 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1_1(): Boolean { contract { returns(false) implies (this@case_1_1 != null) } return !(this@case_1_1 != null) } - fun T?.case_1_2(): Boolean? { contract { returns(null) implies (this@case_1_2 is String) } return if (this@case_1_2 is String) null else true } +// TESTCASE NUMBER: 2 fun T?.case_2_1(): Boolean { contract { returns(true) implies (this@case_2_1 is Float) } return this@case_2_1 is Float } - fun T?.case_2_2(): Boolean { contract { returns(false) implies (this@case_2_2 is Double) } return !(this@case_2_2 is Double) } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { if (!(value_1.case_1_1() || value_1.case_1_2() == null)) { println(value_1.length) @@ -49,8 +47,9 @@ fun case_1(value_1: Any?) { } /* - UNEXPECTED BEHAVIOUR - ISSUES: KT-1982 + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-1982 */ fun case_2(value_1: Any?) { if (value_1.case_2_1() || !value_1.case_2_2()) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.kt new file mode 100644 index 00000000000..00207c1447b --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.kt @@ -0,0 +1,58 @@ +// !WITH_CONTRACT_FUNCTIONS +// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 14 + * DESCRIPTION: Smartcast using many of the various Returns effects on the same values. + */ + +// FILE: contracts.kt + +package contracts + +import kotlin.contracts.* + +// TESTCASE NUMBER: 1 +fun T?.case_1_1(): Boolean { + contract { returns(false) implies (this@case_1_1 != null) } + return !(this@case_1_1 != null) +} +fun T?.case_1_2(): Boolean? { + contract { returns(null) implies (this@case_1_2 is String) } + return if (this@case_1_2 is String) null else true +} + +// TESTCASE NUMBER: 2 +fun T?.case_2_1(): Boolean { + contract { returns(true) implies (this@case_2_1 is Float) } + return this@case_2_1 is Float +} +fun T?.case_2_2(): Boolean { + contract { returns(false) implies (this@case_2_2 is Double) } + return !(this@case_2_2 is Double) +} + +// FILE: main.kt + +import contracts.* + +// TESTCASE NUMBER: 1 +fun case_1(value_1: Any?) { + if (!(value_1.case_1_1() || value_1.case_1_2() == null)) { + println(value_1.length) + } +} + +/* + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-1982 + */ +fun case_2(value_1: Any?) { + if (value_1.case_2_1() || !value_1.case_2_2()) { + println(value_1.toByte()) + } +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.txt new file mode 100644 index 00000000000..f7bb2754dee --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.txt @@ -0,0 +1,126 @@ +package + +public fun case_1(/*0*/ value_1: kotlin.Any?): kotlin.Unit +public fun case_2(/*0*/ value_1: kotlin.Any?): kotlin.Unit +public inline fun funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> T): T + CallsInPlace(block, AT_LEAST_ONCE) + +public inline fun funWithAtLeastOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit + CallsInPlace(block, AT_LEAST_ONCE) + +public inline fun funWithAtMostOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit + CallsInPlace(block, AT_MOST_ONCE) + +public inline fun funWithExactlyOnceCallsInPlace(/*0*/ block: () -> T): T + CallsInPlace(block, EXACTLY_ONCE) + +public inline fun funWithExactlyOnceCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit + CallsInPlace(block, EXACTLY_ONCE) + +public fun funWithReturns(/*0*/ cond: kotlin.Boolean): kotlin.Unit + Returns(WILDCARD) -> cond + +public fun funWithReturnsAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Unit + Returns(WILDCARD) -> !cond + +public fun funWithReturnsAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit + Returns(WILDCARD) -> value_1 !is String + +public fun funWithReturnsAndNotNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit + Returns(WILDCARD) -> value_1 != null + +public fun funWithReturnsAndNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit + Returns(WILDCARD) -> value_1 == null + +public fun funWithReturnsAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Unit + Returns(WILDCARD) -> value_1 is String + +public fun funWithReturnsFalse(/*0*/ cond: kotlin.Boolean): kotlin.Boolean + Returns(FALSE) -> cond + +public fun funWithReturnsFalseAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean + Returns(FALSE) -> !cond + +public fun funWithReturnsFalseAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean + Returns(FALSE) -> value_1 !is String + +public fun funWithReturnsFalseAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean + Returns(FALSE) -> value_1 != null + +public fun funWithReturnsFalseAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean + Returns(FALSE) -> value_1 == null + +public fun funWithReturnsFalseAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean + Returns(FALSE) -> value_1 is String + +public fun funWithReturnsNotNull(/*0*/ cond: kotlin.Boolean): kotlin.Boolean? + Returns(NOT_NULL) -> cond + +public fun funWithReturnsNotNullAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean? + Returns(NOT_NULL) -> !cond + +public fun funWithReturnsNotNullAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean? + Returns(NOT_NULL) -> value_1 !is String + +public fun funWithReturnsNotNullAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean? + Returns(NOT_NULL) -> value_1 != null + +public fun funWithReturnsNotNullAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean? + Returns(NOT_NULL) -> value_1 == null + +public fun funWithReturnsNotNullAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean? + Returns(NOT_NULL) -> value_1 is String + +public fun funWithReturnsNull(/*0*/ cond: kotlin.Boolean): kotlin.Boolean? + Returns(NULL) -> cond + +public fun funWithReturnsNullAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean? + Returns(NULL) -> !cond + +public fun funWithReturnsNullAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean? + Returns(NULL) -> value_1 !is String + +public fun funWithReturnsNullAndNotNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean? + Returns(NULL) -> value_1 != null + +public fun funWithReturnsNullAndNullCheck(/*0*/ value_1: kotlin.Number?): kotlin.Boolean? + Returns(NULL) -> value_1 == null + +public fun funWithReturnsNullAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean? + Returns(NULL) -> value_1 is String + +public fun funWithReturnsTrue(/*0*/ cond: kotlin.Boolean): kotlin.Boolean + Returns(TRUE) -> cond + +public fun funWithReturnsTrueAndInvertCondition(/*0*/ cond: kotlin.Boolean): kotlin.Boolean + Returns(TRUE) -> !cond + +public fun funWithReturnsTrueAndInvertTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean + Returns(TRUE) -> value_1 !is String + +public fun funWithReturnsTrueAndNotNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean + Returns(TRUE) -> value_1 != null + +public fun funWithReturnsTrueAndNullCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean + Returns(TRUE) -> value_1 == null + +public fun funWithReturnsTrueAndTypeCheck(/*0*/ value_1: kotlin.Any?): kotlin.Boolean + Returns(TRUE) -> value_1 is String + +public inline fun funWithUnknownCallsInPlace(/*0*/ block: () -> kotlin.Unit): kotlin.Unit + CallsInPlace(block, UNKNOWN) + +package contracts { + public fun T?.case_1_1(): kotlin.Boolean + Returns(FALSE) -> != null + + public fun T?.case_1_2(): kotlin.Boolean? + Returns(NULL) -> is String + + public fun T?.case_2_1(): kotlin.Boolean + Returns(TRUE) -> is Float + + public fun T?.case_2_2(): kotlin.Boolean + Returns(FALSE) -> is Double + +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/15.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/15.kt index c7aa8f642c1..41e89f4f24f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/15.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/15.kt @@ -2,14 +2,13 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 15 - DESCRIPTION: Check smartcasts working if type checking for contract function is used - UNEXPECTED BEHAVIOUR - ISSUES: KT-27241 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 15 + * DESCRIPTION: Check smartcasts working if type checking for contract function is used + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-27241 */ // FILE: contracts.kt @@ -18,37 +17,41 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1_1(cond: Boolean): Any { contract { returns(true) implies cond } return cond } - fun case_1_2(value: Any): Boolean { contract { returns(true) implies (value is Boolean) } return value is Boolean } +// TESTCASE NUMBER: 2 fun case_2(cond: Boolean): Any { contract { returns(true) implies cond } return cond } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value: Any) { if (contracts.case_1_2(contracts.case_1_1(value is Char))) { println(value.category) } } +// TESTCASE NUMBER: 2 fun case_2(value: Any) { if (contracts.case_2(value is Char) is Boolean) { println(value.category) } } +// TESTCASE NUMBER: 3 fun case_3(value: String?) { if (!value.isNullOrEmpty() is Boolean) { value.length diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.kt index bbac3516e93..e12283a3137 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.kt @@ -3,41 +3,44 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 2 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition). + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 2 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition). */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Any?) { funWithReturns(value_1 !is String || value_2 !is Number) println(value_1.length) println(value_2.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?) { funWithReturnsAndInvertCondition(value_1 is String && value_2 is Number) println(value_1.length) println(value_2.toByte()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: Any?) { funWithReturnsAndInvertCondition(value_1 is String && value_2 == null) println(value_1.length) println(value_2?.toByte()) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Number?) { funWithReturns(value_1 !is Float? || value_1 == null || value_2 == null) println(value_1.dec()) println(value_2?.toByte()) } +// TESTCASE NUMBER: 5 class case_5_class { val prop_1: Int? = 10 - fun case_5(value_1: Any?, value_2: Number?) { val o = case_5_class() funWithReturns(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null) @@ -47,6 +50,7 @@ class case_5_class { } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Any?, value_2: Any) { if (funWithReturnsTrue(value_1 !is String || value_2 !is Number)) { println(value_1.length) @@ -66,6 +70,7 @@ fun case_6(value_1: Any?, value_2: Any) { } } +// TESTCASE NUMBER: 7 fun case_7(value_1: Any?, value_2: Any?) { if (funWithReturnsTrueAndInvertCondition(value_1 is String && value_2 is Number)) { println(value_1.length) @@ -85,6 +90,7 @@ fun case_7(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?, value_2: Any?) { if (funWithReturnsTrueAndInvertCondition(value_1 is String && value_2 == null)) { println(value_1.length) @@ -104,6 +110,7 @@ fun case_8(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 9 fun case_9(value_1: Any?, value_2: Number?) { if (funWithReturnsTrue(value_1 !is Float? || value_1 == null || value_2 == null)) { println(value_1.dec()) @@ -123,6 +130,7 @@ fun case_9(value_1: Any?, value_2: Number?) { } } +// TESTCASE NUMBER: 10 class case_10_class { val prop_1: Int? = 10 @@ -151,6 +159,7 @@ class case_10_class { } } +// TESTCASE NUMBER: 11 fun case_11(value_1: Any?, value_2: Any?, value_3: Any?) { funWithReturnsAndInvertCondition(value_1 !is String? || value_2 !is Number && value_3 !is Float) println(value_1!!.length) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.kt index 1d770a4dfc6..bfa8f3c02c8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 3 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 3 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract. */ // FILE: contracts.kt @@ -15,21 +14,25 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Any?) { contract { returns() implies (value_1 !is String || value_2 !is Number) } if (!(value_1 !is String || value_2 !is Number)) throw Exception() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?) { contract { returns() implies (value_1 !is String || value_2 != null) } if (!(value_1 !is String || value_2 != null)) throw Exception() } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?) { contract { returns() implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } if (!(value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null)) throw Exception() } +// TESTCASE NUMBER: 4 fun case_4_1(value_1: Any?, value_2: Any?): Boolean { contract { returns(true) implies (value_1 !is String || value_2 !is Number) } return value_1 !is String || value_2 !is Number @@ -47,6 +50,7 @@ fun case_4_4(value_1: Any?, value_2: Any?): Boolean? { return if (value_1 !is String || value_2 !is Number) null else true } +// TESTCASE NUMBER: 5 fun case_5_1(value_1: Any?, value_2: Any?): Boolean { contract { returns(true) implies (value_1 !is String || value_2 != null) } return value_1 !is String || value_2 != null @@ -64,6 +68,7 @@ fun case_5_4(value_1: Any?, value_2: Any?): Boolean? { return if (value_1 is String && value_2 == null) null else true } +// TESTCASE NUMBER: 6 fun case_6_1(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { contract { returns(true) implies (value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null) } return value_1 !is Float? || value_1 == null || value_2 == null || value_3 == null || value_4 == null @@ -81,24 +86,28 @@ fun case_6_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolea return if (value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Any?) { contracts.case_1(value_1, value_2) println(value_1.length) println(value_2.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?) { contracts.case_2(value_1, value_2) println(value_1.length) println(value_2?.toByte()) } +// TESTCASE NUMBER: 3 class case_3_class { val prop_1: Int? = 10 + fun case_3(value_1: Any?, value_2: Number?) { val o = case_3_class() contracts.case_3(value_1, value_2, o.prop_1, this.prop_1) @@ -108,6 +117,7 @@ class case_3_class { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Any?) { if (contracts.case_4_1(value_1, value_2)) { println(value_1.length) @@ -127,6 +137,7 @@ fun case_4(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: Any?) { if (contracts.case_5_1(value_1, value_2)) { println(value_1.length) @@ -146,8 +157,10 @@ fun case_5(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 6 class case_6_class { val prop_1: Int? = 10 + fun case_6(value_1: Any?, value_2: Number?) { val o = case_6_class() if (contracts.case_6_1(value_1, value_2, o.prop_1, this.prop_1)) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/4.kt index 1e09e99625a..4e1480b4436 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/4.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 4 - DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 4 + * DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract. */ // FILE: contracts.kt @@ -15,16 +14,19 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T.case_1() { contract { returns() implies (this@case_1 !is String) } if (!(this@case_1 !is String)) throw Exception() } +// TESTCASE NUMBER: 2 fun T.case_2() { contract { returns() implies (this@case_2 !is Int) } if (!(this@case_2 !is Int)) throw Exception() } +// TESTCASE NUMBER: 3 fun String> T?.case_3_1() { contract { returns() implies (this@case_3_1 == null) } if (!(this@case_3_1 == null)) throw Exception() @@ -34,6 +36,7 @@ fun String> T?.case_3_2() { if (!(this@case_3_2 != null)) throw Exception() } +// TESTCASE NUMBER: 4 fun T.case_4_1() { contract { returns() implies (this@case_4_1 == null) } if (!(this@case_4_1 == null)) throw Exception() @@ -43,6 +46,7 @@ fun T.case_4_2() { if (!(this@case_4_2 != null)) throw Exception() } +// TESTCASE NUMBER: 5 fun T.case_5_1(): Boolean { contract { returns(true) implies (this@case_5_1 !is String) } return this@case_5_1 !is String @@ -60,6 +64,7 @@ fun T.case_5_4(): Boolean? { return if (this@case_5_4 !is String) null else true } +// TESTCASE NUMBER: 6 fun T.case_6_1(): Boolean { contract { returns(true) implies (this@case_6_1 !is Int) } return this@case_6_1 !is Int @@ -77,6 +82,7 @@ fun T.case_6_4(): Boolean? { return if (this@case_6_4 !is Int) null else true } +// TESTCASE NUMBER: 7 fun String> T?.case_7_1(): Boolean { contract { returns(true) implies (this@case_7_1 == null) } return this@case_7_1 == null @@ -94,6 +100,7 @@ fun String> T?.case_7_4(): Boolean? { return if (this@case_7_4 != null) null else true } +// TESTCASE NUMBER: 8 fun T.case_8_1(): Boolean { contract { returns(true) implies (this@case_8_1 == null) } return this@case_8_1 == null @@ -111,16 +118,19 @@ fun T.case_8_4(): Boolean? { return if (this@case_8_4 != null) null else true } +// TESTCASE NUMBER: 9 fun T.case_9(): Boolean? { contract { returnsNotNull() implies (this@case_9 != null) } return if (this@case_9 != null) true else null } +// TESTCASE NUMBER: 10 fun T.case_10(): Boolean? { contract { returnsNotNull() implies (this@case_10 == null) } return if (this@case_10 == null) true else null } +// TESTCASE NUMBER: 11 fun T.case_11_1(): Boolean? { contract { returns(null) implies (this@case_11_1 != null) } return if (this@case_11_1 != null) null else true @@ -130,20 +140,23 @@ fun T.case_11_2(): Boolean? { return if (this@case_11_2 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() println(value_1.length) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number) { value_1.case_2() println(value_1.inv()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: String?, value_2: String?) { value_1.case_3_1() println(value_1.length) @@ -151,6 +164,7 @@ fun case_3(value_1: String?, value_2: String?) { println(value_2) } +// TESTCASE NUMBER: 4 fun case_4(value_1: String?, value_2: String?) { value_1.case_4_1() println(value_1.length) @@ -158,6 +172,7 @@ fun case_4(value_1: String?, value_2: String?) { println(value_2) } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?) { if (value_1.case_5_1()) println(value_1.length) if (!value_1.case_5_2()) println(value_1.length) @@ -165,6 +180,7 @@ fun case_5(value_1: Any?) { if (value_1.case_5_4() == null) println(value_1.length) } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number) { when { value_1.case_6_1() -> println(value_1.inv()) } when { !value_1.case_6_2() -> println(value_1.inv()) } @@ -172,6 +188,7 @@ fun case_6(value_1: Number) { when { value_1.case_6_4() != null -> println(value_1.inv()) } } +// TESTCASE NUMBER: 7 fun case_7(value_1: String?, value_2: String?) { if (value_1.case_7_1()) println(value_1.length) if (value_2.case_7_2()) println(value_2) @@ -179,6 +196,7 @@ fun case_7(value_1: String?, value_2: String?) { if (value_2.case_7_3() == null) println(value_2) } +// TESTCASE NUMBER: 8 fun case_8(value_1: String?, value_2: String?) { when { value_1.case_8_1() -> println(value_1.length) } when { value_2.case_8_2() -> println(value_2) } @@ -186,10 +204,12 @@ fun case_8(value_1: String?, value_2: String?) { when { value_2.case_8_3() == null -> println(value_2) } } +// TESTCASE NUMBER: 9 fun case_9(value_1: Number?) { if (value_1?.case_9() == null) println(value_1.toByte()) } +// TESTCASE NUMBER: 10 fun case_10(value_1: Number?) { if (value_1?.case_10() == null) { println(value_1.toByte()) @@ -199,7 +219,8 @@ fun case_10(value_1: Number?) { } /* - ISSUES: KT-26382 + * TESTCASE NUMBER: 11 + * ISSUES: KT-26382 */ fun case_11(value_1: Number?, value_2: Number?) { if (value_1?.case_11_1() == null) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/5.kt index 4472d309c94..88aa37721bb 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/5.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 5 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 5 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract. */ // FILE: contracts.kt @@ -15,21 +14,25 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1() { contract { returns() implies (this@case_1 == null || this@case_1 !is String) } if (!(this@case_1 == null || this@case_1 !is String)) throw Exception() } +// TESTCASE NUMBER: 2 fun T.case_2() { contract { returns() implies (this@case_2 !is Int || this@case_2 == null) } if (!(this@case_2 !is Int || this@case_2 == null)) throw Exception() } +// TESTCASE NUMBER: 3 inline fun T?.case_3() { contract { returns() implies (this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null) } if (!(this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null)) throw Exception() } +// TESTCASE NUMBER: 4 fun T?.case_4_1(): Boolean { contract { returns(true) implies (this@case_4_1 == null || this@case_4_1 !is String) } return this@case_4_1 == null || this@case_4_1 !is String @@ -47,6 +50,7 @@ fun T?.case_4_4(): Boolean? { return if (this@case_4_4 == null || this@case_4_4 !is String) null else true } +// TESTCASE NUMBER: 5 fun T.case_5_1(): Boolean { contract { returns(true) implies (this@case_5_1 !is Int || this@case_5_1 == null) } return this@case_5_1 !is Int || this@case_5_1 == null @@ -64,6 +68,7 @@ fun T.case_5_4(): Boolean? { return if (this@case_5_4 !is Int || this@case_5_4 == null) null else true } +// TESTCASE NUMBER: 6 inline fun T?.case_6_1(): Boolean { contract { returns(true) implies (this@case_6_1 !is Number || this@case_6_1 !is Int || this@case_6_1 == null) } return this@case_6_1 !is Number || this@case_6_1 !is Int || this@case_6_1 == null @@ -81,25 +86,29 @@ inline fun T?.case_6_4(): Boolean? { return if (this@case_6_4 is Number && this@case_6_4 is Int && this@case_6_4 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() println(value_1.length) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number?) { value_1.case_2() println(value_1.inv()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?) { value_1.case_3() println(value_1.inv()) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Any?, value_3: Any?) { when { value_1.case_4_1() -> println(value_1.length) } when { !value_2.case_4_2() -> println(value_2.length) } @@ -107,6 +116,7 @@ fun case_4(value_1: Any?, value_2: Any?, value_3: Any?) { when { value_3.case_4_4() == null -> println(value_3.length) } } +// TESTCASE NUMBER: 5 fun case_5(value_1: Number?, value_2: Number?, value_3: Number?) { if (value_1.case_5_1()) println(value_1.inv()) if (!value_2.case_5_2()) println(value_2.inv()) @@ -114,6 +124,7 @@ fun case_5(value_1: Number?, value_2: Number?, value_3: Number?) { if (value_3.case_5_4() == null) println(value_3.inv()) } +// TESTCASE NUMBER: 6 fun case_6(value_1: Any?, value_2: Any?, value_3: Any?) { if (value_1.case_6_1()) println(value_1.inv()) if (!value_2.case_6_2()) println(value_2.inv()) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/6.kt index a998d156850..b13a62a8809 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/6.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 6 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 6 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract. */ // FILE: contracts.kt @@ -15,26 +14,31 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1(value_1: Int?) { contract { returns() implies (this@case_1 == null || this@case_1 !is String || value_1 == null) } if (!(this@case_1 == null || this@case_1 !is String || value_1 == null)) throw Exception() } +// TESTCASE NUMBER: 2 fun T.case_2(value_2: Any?) { contract { returns() implies (this@case_2 !is Int || this@case_2 == null || value_2 !is Number || value_2 == null) } if (!(this@case_2 !is Int || this@case_2 == null || value_2 !is Number || value_2 == null)) throw Exception() } +// TESTCASE NUMBER: 3 fun T?.case_3(value_2: Any?) { contract { returns() implies (this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null || value_2 == null) } if (!(this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null || value_2 == null)) throw Exception() } +// TESTCASE NUMBER: 4 inline fun T?.case_4(value_2: Number, value_3: Any?, value_4: String?) { contract { returns() implies ((this@case_4 !is Number && this@case_4 !is Int) || value_2 !is Int || value_3 == null || value_3 !is Number || value_4 == null) } if (!((this@case_4 !is Number && this@case_4 !is Int) || value_2 !is Int || value_3 == null || value_3 !is Number || value_4 == null)) throw Exception() } +// TESTCASE NUMBER: 5 fun T?.case_5_1(value_1: Int?): Boolean { contract { returns(true) implies (this@case_5_1 == null || this@case_5_1 !is String || value_1 == null) } return this@case_5_1 == null || this@case_5_1 !is String || value_1 == null @@ -52,6 +56,7 @@ fun T?.case_5_4(value_1: Int?): Boolean? { return if (this@case_5_4 == null || this@case_5_4 !is String || value_1 == null) null else true } +// TESTCASE NUMBER: 6 fun T.case_6_1(value_2: Any?): Boolean { contract { returns(true) implies (this@case_6_1 !is Int || this@case_6_1 == null || value_2 !is Number || value_2 == null) } return this@case_6_1 !is Int || this@case_6_1 == null || value_2 !is Number || value_2 == null @@ -69,6 +74,7 @@ fun T.case_6_4(value_2: Any?): Boolean? { return if (this@case_6_4 !is Int || this@case_6_4 == null || value_2 !is Number || value_2 == null) null else true } +// TESTCASE NUMBER: 7 fun T?.case_7_1(value_2: Any?): Boolean { contract { returns(true) implies (this@case_7_1 !is Number || this@case_7_1 !is Int || this@case_7_1 == null || value_2 == null) } return this@case_7_1 !is Number || this@case_7_1 !is Int || this@case_7_1 == null || value_2 == null @@ -86,6 +92,7 @@ fun T?.case_7_4(value_2: Any?): Boolean? { return if (this@case_7_4 !is Number || this@case_7_4 !is Int || this@case_7_4 == null || value_2 == null) null else true } +// TESTCASE NUMBER: 8 inline fun T?.case_8_1(value_2: Number, value_3: Any?, value_4: String?): Boolean { contract { returns(true) implies ((this@case_8_1 !is Number && this@case_8_1 !is Int) || value_2 !is Int || value_3 == null || value_3 !is Number || value_4 == null) } return (this@case_8_1 !is Number && this@case_8_1 !is Int) || value_2 !is Int || value_3 == null || value_3 !is Number || value_4 == null @@ -103,28 +110,32 @@ inline fun T?.case_8_4(value_2: Number, value_3: Any?, value_ return if ((this@case_8_4 is Number || this@case_8_4 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Int?) { value_1.case_1(value_2) println(value_1.length) println(value_2.inv()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number?, value_2: Any?) { value_1.case_2(value_2) println(value_1.inv()) println(value_2.toByte()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: String?) { value_1.case_3(value_2) println(value_1.inv()) println(value_2.length) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_4(value_2, value_3, value_4) println(value_2.inv()) @@ -132,6 +143,7 @@ fun case_4(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { println(value_4.length) } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?, value_5: Any?, value_6: Int?) { when { value_1.case_5_1(value_2) -> { @@ -153,6 +165,7 @@ fun case_5(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?, value_5: } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number?, value_2: Any?, value_3: Number?, value_4: Any?, value_5: Number?, value_6: Any?) { if (value_1.case_6_1(value_2)) { println(value_1.inv()) @@ -172,6 +185,7 @@ fun case_6(value_1: Number?, value_2: Any?, value_3: Number?, value_4: Any?, val } } +// TESTCASE NUMBER: 7 fun case_7(value_1: Any?, value_2: String?, value_3: Any?, value_4: String?, value_5: Any?, value_6: String?) { if (value_1.case_7_1(value_2)) { println(value_1.inv()) @@ -191,6 +205,7 @@ fun case_7(value_1: Any?, value_2: String?, value_3: Any?, value_4: String?, val } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_2.inv()) } when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_3.toByte()) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/7.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/7.kt index beaa6cb6ec7..da8347ea28f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/7.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/7.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 7 - DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 7 + * DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls. */ // FILE: contracts.kt @@ -15,6 +14,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1_1(value_1: Int?) { contract { returns() implies (value_1 == null) } if (!(value_1 == null)) throw Exception() @@ -24,6 +24,7 @@ fun case_1_2(value_1: Int?) { if (!(value_1 != null)) throw Exception() } +// TESTCASE NUMBER: 2 fun case_2_1(value_1: Number?) { contract { returns() implies (value_1 !is Float) } if (!(value_1 !is Float)) throw Exception() @@ -33,6 +34,7 @@ fun case_2_2(value_1: Number?) { if (!(value_1 !is Int)) throw Exception() } +// TESTCASE NUMBER: 3 fun case_3_1(value_1: Any?) { contract { returns() implies (value_1 !is String) } if (!(value_1 !is String)) throw Exception() @@ -42,6 +44,7 @@ fun case_3_2(value_1: Any?) { if (!(value_1 is String)) throw Exception() } +// TESTCASE NUMBER: 4 fun case_4_1(value_1: Any?) { contract { returns() implies (value_1 !is Number?) } if (!(value_1 !is Number?)) throw Exception() @@ -55,6 +58,7 @@ fun case_4_3(value_1: Number) { if (!(value_1 !is Int)) throw Exception() } +// TESTCASE NUMBER: 5 fun case_5_1(value_1: Int?): Boolean { contract { returns(true) implies (value_1 == null) } return value_1 == null @@ -88,6 +92,7 @@ fun case_5_8(value_1: Int?): Boolean? { return if (value_1 != null) null else true } +// TESTCASE NUMBER: 6 fun case_6_1(value_1: Number?): Boolean { contract { returns(true) implies (value_1 !is Float) } return value_1 !is Float @@ -121,6 +126,7 @@ fun case_6_8(value_1: Number?): Boolean? { return if (value_1 !is Int) null else true } +// TESTCASE NUMBER: 7 fun case_7_1(value_1: Any?): Boolean { contract { returns(true) implies (value_1 !is String) } return value_1 !is String @@ -154,6 +160,7 @@ fun case_7_8(value_1: Any?): Boolean? { return if (value_1 is String) null else true } +// TESTCASE NUMBER: 8 fun case_8_1(value_1: Any?): Boolean { contract { returns(true) implies (value_1 !is Number?) } return value_1 !is Number? @@ -203,10 +210,11 @@ fun case_8_12(value_1: Number): Boolean? { return if (value_1 !is Int) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { case_1_1(value_1) value_1.inv() @@ -216,6 +224,7 @@ fun case_1(value_1: Int?) { value_1.inv() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number?) { case_2_1(value_1) value_1.toByte() @@ -223,6 +232,7 @@ fun case_2(value_1: Number?) { value_1.inv() } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?) { case_3_1(value_1) value_1.length @@ -230,6 +240,7 @@ fun case_3(value_1: Any?) { value_1.length } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?) { case_4_1(value_1) value_1?.toByte() @@ -239,6 +250,7 @@ fun case_4(value_1: Any?) { value_1.inv() } +// TESTCASE NUMBER: 5 fun case_5(value_1: Int?) { if (case_5_1(value_1)) { value_1.inv() @@ -274,6 +286,7 @@ fun case_5(value_1: Int?) { } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number?) { when { case_6_1(value_1) -> { @@ -301,6 +314,7 @@ fun case_6(value_1: Number?) { } } +// TESTCASE NUMBER: 7 fun case_7(value_1: Any?) { if (case_7_1(value_1)) { value_1.length @@ -320,6 +334,7 @@ fun case_7(value_1: Any?) { } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?) { if (case_8_1(value_1)) { value_1?.toByte() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/8.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/8.kt index ecc2729d328..6b253097a6c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/8.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/8.kt @@ -2,12 +2,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 8 - DESCRIPTION: Smartcasts using some Returns effects. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 8 + * DESCRIPTION: Smartcasts using some Returns effects. */ // FILE: contracts.kt @@ -16,6 +15,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 3 fun T?.case_3(value_1: Int?, value_2: Boolean): Boolean { contract { returns(true) implies (value_1 != null) @@ -26,6 +26,7 @@ fun T?.case_3(value_1: Int?, value_2: Boolean): Boolean { return value_1 == null } +// TESTCASE NUMBER: 4 fun case_4(value_1: Number, block: (() -> Unit)?): Boolean? { contract { returns(true) implies (block != null) @@ -36,6 +37,7 @@ fun case_4(value_1: Number, block: (() -> Unit)?): Boolean? { return value_1 == null } +// TESTCASE NUMBER: 5 fun String?.case_5(value_1: Number?): Boolean? { contract { returns(true) implies (value_1 == null) @@ -46,6 +48,7 @@ fun String?.case_5(value_1: Number?): Boolean? { return value_1 == null } +// TESTCASE NUMBER: 6 fun T?.case_6(value_1: Number, value_2: String?): Boolean? { contract { returns(true) implies (this@case_6 == null) @@ -57,10 +60,11 @@ fun T?.case_6(value_1: Number, value_2: String?): Boolean? { return value_1 == null } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { funWithReturns(value_1 !is Number?) println(value_1?.toByte()) @@ -70,6 +74,7 @@ fun case_1(value_1: Any?) { } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) { if (!funWithReturnsFalse(value_1 !is Number?)) { println(value_1?.toByte()) @@ -79,6 +84,7 @@ fun case_2(value_1: Any?) { } } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?, value_2: Any?) { if (!value_1.case_3(value_1, value_2 is Number?)) { println(value_2?.toByte()) @@ -90,6 +96,7 @@ fun case_3(value_1: Int?, value_2: Any?) { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Number, value_2: (() -> Unit)?) { if (contracts.case_4(value_1, value_2) == true) { value_1.inv() @@ -100,6 +107,7 @@ fun case_4(value_1: Number, value_2: (() -> Unit)?) { } } +// TESTCASE NUMBER: 5 fun case_5(value_1: Number?, value_2: String?) { when (value_2.case_5(value_1)) { true -> { @@ -113,6 +121,7 @@ fun case_5(value_1: Number?, value_2: String?) { } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number, value_2: String?, value_3: Any?) { when (value_3.case_6(value_1, value_2)) { true -> { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/9.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/9.kt index 4b3818f7c80..72caab06cf5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/9.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/9.kt @@ -3,30 +3,33 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 9 - DESCRIPTION: Check the lack of smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'unknown' or 'at most once' CallsInPlace effects. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 9 + * DESCRIPTION: Check the lack of smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'unknown' or 'at most once' CallsInPlace effects. */ +// TESTCASE NUMBER: 1 fun case_1(arg: Int?) { funWithAtMostOnceCallsInPlace { arg!! } arg.inc() } +// TESTCASE NUMBER: 2 fun case_2(arg: Int?) { funWithUnknownCallsInPlace { arg!! } arg.inc() } +// TESTCASE NUMBER: 3 fun case_3() { val value_1: Boolean? funWithAtMostOnceCallsInPlace { value_1 = false } value_1.not() } +// TESTCASE NUMBER: 4 fun case_4() { val value_1: Boolean? funWithUnknownCallsInPlace { value_1 = true } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/1.kt index 377c3cbf2a9..f96fb22aca1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/1.kt @@ -3,44 +3,50 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 1 - DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract). + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 1 + * DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract). */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { funWithReturns(value_1 is String) println(value_1.length) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?) { funWithReturns(value_1 != null) println(value_1.inc()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?) { funWithReturns(value_1 == null) println(value_1) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?) { funWithReturnsAndTypeCheck(value_1) println(value_1.length) } +// TESTCASE NUMBER: 5 fun case_5(value_1: String?) { funWithReturnsAndNotNullCheck(value_1) println(value_1.length) } +// TESTCASE NUMBER: 6 fun case_6(value_1: String?) { funWithReturnsAndNullCheck(value_1) println(value_1) } +// TESTCASE NUMBER: 7 object case_7_object { val prop_1: Int? = 10 } @@ -49,6 +55,7 @@ fun case_7() { case_7_object.prop_1.inc() } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?) { if (funWithReturnsTrue(value_1 is String)) println(value_1.length) if (funWithReturnsTrueAndInvertCondition(value_1 !is String)) println(value_1.length) @@ -58,6 +65,7 @@ fun case_8(value_1: Any?) { if (!(funWithReturnsNotNull(value_1 is String) == null)) println(value_1.length) } +// TESTCASE NUMBER: 9 fun case_9(value_1: String?) { if (funWithReturnsTrue(value_1 != null)) println(value_1.length) if (funWithReturnsTrueAndInvertCondition(value_1 == null)) println(value_1.length) @@ -68,6 +76,7 @@ fun case_9(value_1: String?) { if (!(funWithReturnsNotNullAndInvertCondition(value_1 == null) == null)) println(value_1.length) } +// TESTCASE NUMBER: 10 fun case_10(value_1: Any?) { if (funWithReturnsTrueAndTypeCheck(value_1)) println(value_1.length) if (!funWithReturnsFalseAndTypeCheck(value_1)) println(value_1.length) @@ -75,6 +84,7 @@ fun case_10(value_1: Any?) { if (!(funWithReturnsNotNullAndTypeCheck(value_1) == null)) println(value_1.length) } +// TESTCASE NUMBER: 11 fun case_11(value_1: Number?, value_2: Int?) { if (funWithReturnsTrueAndNotNullCheck(value_1)) println(value_1.toByte()) if (funWithReturnsTrueAndNullCheck(value_1)) println(value_1) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/10.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/10.kt index 7f4d363fff0..6f65215ca2e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/10.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/10.kt @@ -3,13 +3,12 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 10 - DESCRIPTION: Smartcasts with correspond contract function with default value in last parameter. - ISSUES: KT-26444 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 10 + * DESCRIPTION: Smartcasts with correspond contract function with default value in last parameter. + * ISSUES: KT-26444 */ // FILE: contracts.kt @@ -18,26 +17,30 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?, value_2: Int? = 10): Boolean { contract { returns(true) implies (value_1 != null) } return value_1 != null } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int? = 10, value_2: Int? = 10, value_3: Int? = 10): Boolean { contract { returns(true) implies (value_2 != null) } return value_1 != null } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { if (contracts.case_1(value_1)) { value_1.inc() } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?) { if (contracts.case_2(10, value_1)) { value_1.inc() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.kt index 8512d3fc7a7..cef80fef6fa 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.kt @@ -2,13 +2,12 @@ // !WITH_CONTRACT_FUNCTIONS /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 11 - DESCRIPTION: Check smartcasts with passing same fields of instances of the same class in contract function with conjunction not-null condition. - ISSUES: KT-26300 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 11 + * DESCRIPTION: Check smartcasts with passing same fields of instances of the same class in contract function with conjunction not-null condition. + * ISSUES: KT-26300 */ // FILE: contracts.kt @@ -17,20 +16,23 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?) { contract { returns() implies (value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null) } if (!(value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null)) throw Exception() } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { contract { returns(true) implies (value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null) } return value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 class case_1 { val prop_1: Int? = 10 fun case_1(value_1: Any?, value_2: Number?) { @@ -41,6 +43,7 @@ class case_1 { } } +// TESTCASE NUMBER: 2 class case_2 { val prop_1: Int? = 10 fun case_2(value_1: Any?, value_2: Number?) { @@ -52,6 +55,7 @@ class case_2 { } } +// TESTCASE NUMBER: 3 class case_3 { val prop_1: Int? = 10 fun case_3(value_1: Any?, value_2: Number?) { @@ -62,6 +66,7 @@ class case_3 { } } +// TESTCASE NUMBER: 4 class case_4 { val prop_1: Int? = 10 fun case_4(value_1: Any?, value_2: Number?) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/12.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/12.kt index de2a8d98394..9f51862ae78 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/12.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/12.kt @@ -3,32 +3,35 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 12 - DESCRIPTION: Smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'exactly once' or 'at least once' CallsInPlace effects. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26148 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 12 + * DESCRIPTION: Smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'exactly once' or 'at least once' CallsInPlace effects. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26148 */ +// TESTCASE NUMBER: 1 fun case_1(arg: Int?) { funWithExactlyOnceCallsInPlace { arg!! } arg.inc() } +// TESTCASE NUMBER: 2 fun case_2(arg: Int?) { funWithAtLeastOnceCallsInPlace { arg!! } arg.inc() } +// TESTCASE NUMBER: 3 fun case_3() { val value_1: Boolean? funWithExactlyOnceCallsInPlace { value_1 = false } value_1.not() } +// TESTCASE NUMBER: 4 fun case_4() { val value_1: Boolean? funWithAtLeastOnceCallsInPlace { value_1 = true } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.kt index db72f94eacd..38f7cd989de 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.kt @@ -1,14 +1,13 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 13 - DESCRIPTION: Check smartcast to upper bound of the types in disjunction. - UNEXPECTED BEHAVIOUR - ISSUES: KT-1982 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 13 + * DESCRIPTION: Check smartcast to upper bound of the types in disjunction. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-1982 */ // FILE: contracts.kt @@ -17,25 +16,29 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1() { contract { returns() implies (this@case_1 is Number || this@case_1 is Int) } if (!(this@case_1 is Number || this@case_1 is Int)) throw Exception() } +// TESTCASE NUMBER: 2 inline fun T?.case_2(value_2: Number, value_3: Any?, value_4: String?) { contract { returns() implies ((this@case_2 is Number || this@case_2 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) } if (!((this is Number || this is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null)) throw Exception() } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() println(value_1.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_2(value_2, value_3, value_4) println(value_1.toByte()) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/14.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/14.kt index 9e5e252841e..a677b2b7d73 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/14.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/14.kt @@ -1,14 +1,13 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 14 - DESCRIPTION: Check smartcast with non-null assertion for a contract function. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26856 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 14 + * DESCRIPTION: Check smartcast with non-null assertion for a contract function. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26856 */ // FILE: contracts.kt @@ -17,6 +16,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?): Boolean? { contract { returns(true) implies (value_1 != null) @@ -25,6 +25,7 @@ fun case_1(value_1: Int?): Boolean? { return value_1 != null } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?): Boolean { contract { returns(false) implies (value_1 != null) @@ -33,6 +34,7 @@ fun case_2(value_1: Int?): Boolean { return value_1 != null } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?): Boolean? { contract { returnsNotNull() implies (value_1 != null) @@ -41,6 +43,7 @@ fun case_3(value_1: Int?): Boolean? { return value_1 != null } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?): Boolean { contract { returnsNotNull() implies (value_1 is Number) @@ -49,28 +52,32 @@ fun case_4(value_1: Any?): Boolean { return value_1 is Number } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { if (contracts.case_1(value_1)!!) { value_1.inv() } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?) { if (!contracts.case_2(value_1)!!) { value_1.inv() } } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?) { if (contracts.case_3(value_1)!!) { value_1.inv() } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?) { if (contracts.case_4(value_1) != null) { value_1.toByte() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/2.kt index b109b7653e3..d25e5a5df58 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/2.kt @@ -3,38 +3,42 @@ // SKIP_TXT /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 2 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition). + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 2 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition). */ +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Any?) { funWithReturns(value_1 is String && value_2 is Number) println(value_1.length) println(value_2.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?) { funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number) println(value_1.length) println(value_2.toByte()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: Any?) { funWithReturnsAndInvertCondition(value_1 !is String || value_2 != null) println(value_1.length) println(value_2?.toByte()) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Number?) { funWithReturns(value_1 is Float? && value_1 != null && value_2 != null) println(value_1.dec()) println(value_2?.toByte()) } +// TESTCASE NUMBER: 5 class case_5_class { val prop_1: Int? = 10 @@ -47,6 +51,7 @@ class case_5_class { } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Any?, value_2: Any) { if (funWithReturnsTrue(value_1 is String && value_2 is Number)) { println(value_1.length) @@ -66,6 +71,7 @@ fun case_6(value_1: Any?, value_2: Any) { } } +// TESTCASE NUMBER: 7 fun case_7(value_1: Any?, value_2: Any?) { if (funWithReturnsTrueAndInvertCondition(value_1 !is String || value_2 !is Number)) { println(value_1.length) @@ -85,6 +91,7 @@ fun case_7(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?, value_2: Any?) { if (funWithReturnsTrueAndInvertCondition(value_1 !is String || value_2 != null)) { println(value_1.length) @@ -104,6 +111,7 @@ fun case_8(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 9 fun case_9(value_1: Any?, value_2: Number?) { if (funWithReturnsTrue(value_1 is Float? && value_1 != null && value_2 != null)) { println(value_1.dec()) @@ -123,6 +131,7 @@ fun case_9(value_1: Any?, value_2: Number?) { } } +// TESTCASE NUMBER: 10 class case_10_class { val prop_1: Int? = 10 @@ -152,11 +161,11 @@ class case_10_class { } /* - CASE DESCRIPTION: check resolve reference when is used not null assertion and safe call operators - UNEXPECTED BEHAVIOUR - ISSUES: KT-26747 + * TESTCASE NUMBER: 11 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26747 */ -fun case_12(value_1: Any?, value_2: Any?, value_3: Any?) { +fun case_11(value_1: Any?, value_2: Any?, value_3: Any?) { funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number || value_3 !is Any?) println(value_1!!.length) println(value_2?.toByte()) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.kt index 03214eca15b..51c444cc97c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 3 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 3 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract. */ // FILE: contracts.kt @@ -15,21 +14,25 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Any?) { contract { returns() implies (value_1 is String && value_2 is Number) } if (!(value_1 is String && value_2 is Number)) throw Exception() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?) { contract { returns() implies (value_1 is String && value_2 == null) } if (!(value_1 is String && value_2 == null)) throw Exception() } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?) { contract { returns() implies (value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null) } if (!(value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null)) throw Exception() } +// TESTCASE NUMBER: 4 fun case_4_1(value_1: Any?, value_2: Any?): Boolean { contract { returns(true) implies (value_1 is String && value_2 is Number) } return value_1 is String && value_2 is Number @@ -47,6 +50,7 @@ fun case_4_4(value_1: Any?, value_2: Any?): Boolean? { return if (value_1 is String && value_2 is Number) null else true } +// TESTCASE NUMBER: 5 fun case_5_1(value_1: Any?, value_2: Any?): Boolean { contract { returns(true) implies (value_1 is String && value_2 == null) } return value_1 is String && value_2 == null @@ -64,6 +68,7 @@ fun case_5_4(value_1: Any?, value_2: Any?): Boolean? { return if (value_1 is String && value_2 == null) null else true } +// TESTCASE NUMBER: 6 fun case_6_1(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolean { contract { returns(true) implies (value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null) } return value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null @@ -81,22 +86,25 @@ fun case_6_4(value_1: Any?, value_2: Any?, value_3: Any?, value_4: Any?): Boolea return if (value_1 is Float? && value_1 != null && value_2 != null && value_3 != null && value_4 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Any?) { contracts.case_1(value_1, value_2) println(value_1.length) println(value_2.toByte()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?) { contracts.case_2(value_1, value_2) println(value_1.length) println(value_2?.toByte()) } +// TESTCASE NUMBER: 3 class case_3_class { val prop_1: Int? = 10 fun case_3(value_1: Any?, value_2: Number?) { @@ -108,6 +116,7 @@ class case_3_class { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Any?) { if (contracts.case_4_1(value_1, value_2)) { println(value_1.length) @@ -127,6 +136,7 @@ fun case_4(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: Any?) { if (contracts.case_5_1(value_1, value_2)) { println(value_1.length) @@ -146,6 +156,7 @@ fun case_5(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 6 class case_6_class { val prop_1: Int? = 10 fun case_6(value_1: Any?, value_2: Number?) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/4.kt index 570d9ed37c5..43123407801 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/4.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 4 - DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 4 + * DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract. */ // FILE: contracts.kt @@ -15,16 +14,19 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T.case_1() { contract { returns() implies (this@case_1 is String) } if (!(this@case_1 is String)) throw Exception() } +// TESTCASE NUMBER: 2 fun T.case_2() { contract { returns() implies (this@case_2 is Int) } if (!(this@case_2 is Int)) throw Exception() } +// TESTCASE NUMBER: 3 fun String> T?.case_3_1() { contract { returns() implies (this@case_3_1 != null) } if (!(this@case_3_1 != null)) throw Exception() @@ -34,6 +36,7 @@ fun String> T?.case_3_2() { if (!(this@case_3_2 == null)) throw Exception() } +// TESTCASE NUMBER: 4 fun T.case_4_1() { contract { returns() implies (this@case_4_1 != null) } if (!(this@case_4_1 != null)) throw Exception() @@ -43,6 +46,7 @@ fun T.case_4_2() { if (!(this@case_4_2 == null)) throw Exception() } +// TESTCASE NUMBER: 5 fun T.case_5_1(): Boolean { contract { returns(true) implies (this@case_5_1 is String) } return this@case_5_1 is String @@ -60,6 +64,7 @@ fun T.case_5_4(): Boolean? { return if (this@case_5_4 is String) null else true } +// TESTCASE NUMBER: 6 fun T.case_6_1(): Boolean { contract { returns(true) implies (this@case_6_1 is Int) } return this@case_6_1 is Int @@ -77,6 +82,7 @@ fun T.case_6_4(): Boolean? { return if (this@case_6_4 is Int) null else true } +// TESTCASE NUMBER: 7 fun String> T?.case_7_1(): Boolean { contract { returns(true) implies (this@case_7_1 != null) } return this@case_7_1 != null @@ -122,6 +128,7 @@ fun String> T?.case_7_11(): Boolean? { return if (this@case_7_11 == null) null else true } +// TESTCASE NUMBER: 8 fun T.case_8_1(): Boolean { contract { returns(true) implies (this@case_8_1 != null) } return this@case_8_1 != null @@ -139,30 +146,33 @@ fun T.case_8_4(): Boolean? { return if (this@case_8_4 == null) null else true } +// TESTCASE NUMBER: 9 fun T?.case_9_1(): Boolean { contract { returns(true) implies (this@case_9_1 is Float) } return this@case_9_1 is Float } - fun T?.case_9_2(): Boolean { contract { returns(false) implies (this@case_9_2 is Double) } return !(this@case_9_2 is Double) } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() println(value_1.length) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number) { value_1.case_2() println(value_1.inv()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: String?, value_2: String?) { value_1.case_3_1() println(value_1.length) @@ -170,6 +180,7 @@ fun case_3(value_1: String?, value_2: String?) { println(value_2) } +// TESTCASE NUMBER: 4 fun case_4(value_1: String?, value_2: String?) { value_1.case_4_1() println(value_1.length) @@ -177,6 +188,7 @@ fun case_4(value_1: String?, value_2: String?) { println(value_2) } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?) { if (value_1.case_5_1()) println(value_1.length) if (!value_1.case_5_2()) println(value_1.length) @@ -184,6 +196,7 @@ fun case_5(value_1: Any?) { if (value_1.case_5_4() == null) println(value_1.length) } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number) { when { value_1.case_6_1() -> println(value_1.inv()) } when { !value_1.case_6_2() -> println(value_1.inv()) } @@ -191,6 +204,7 @@ fun case_6(value_1: Number) { when { value_1.case_6_4() == null -> println(value_1.inv()) } } +// TESTCASE NUMBER: 7 fun case_7(value_1: String?) { if (value_1.case_7_1()) println(value_1.length) if (value_1.case_7_2()) println(value_1) @@ -222,6 +236,7 @@ fun case_7(value_1: String?) { } } +// TESTCASE NUMBER: 8 fun case_8(value_1: String?, value_2: String?) { when { value_1.case_8_1() -> println(value_1.length) } when { value_2.case_8_2() -> println(value_2) } @@ -230,9 +245,9 @@ fun case_8(value_1: String?, value_2: String?) { } /* - CASE DESCRIPTION: check the infererence of the Number super type - UNEXPECTED BEHAVIOUR - ISSUES: KT-1982 + * TESTCASE NUMBER: 9 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-1982 */ fun case_9(value_1: Any?) { if (value_1.case_9_1() || !value_1.case_9_2()) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.kt index 3781a9eb9da..23f2ec4128d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 5 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 5 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract. */ // FILE: contracts.kt @@ -15,21 +14,25 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1() { contract { returns() implies (this@case_1 != null && this@case_1 is String) } if (!(this@case_1 != null && this@case_1 is String)) throw Exception() } +// TESTCASE NUMBER: 2 fun T.case_2() { contract { returns() implies (this@case_2 is Int && this@case_2 != null) } if (!(this@case_2 is Int && this@case_2 != null)) throw Exception() } +// TESTCASE NUMBER: 3 inline fun T?.case_3() { contract { returns() implies (this@case_3 is Number && this@case_3 is Int && this@case_3 != null) } if (!(this@case_3 is Number && this@case_3 is Int && this@case_3 != null)) throw Exception() } +// TESTCASE NUMBER: 4 fun T?.case_4_1(): Boolean { contract { returns(true) implies (this@case_4_1 != null && this@case_4_1 is String) } return this@case_4_1 != null && this@case_4_1 is String @@ -47,6 +50,7 @@ fun T?.case_4_4(): Boolean? { return if (this@case_4_4 != null && this@case_4_4 is String) null else true } +// TESTCASE NUMBER: 5 fun T.case_5_1(): Boolean { contract { returns(true) implies (this@case_5_1 is Int && this@case_5_1 != null) } return this@case_5_1 is Int && this@case_5_1 != null @@ -64,6 +68,7 @@ fun T.case_5_4(): Boolean? { return if (this@case_5_4 is Int && this@case_5_4 != null) null else true } +// TESTCASE NUMBER: 6 inline fun T?.case_6_1(): Boolean { contract { returns(true) implies (this@case_6_1 is Number && this@case_6_1 is Int && this@case_6_1 != null) } return this@case_6_1 is Number && this@case_6_1 is Int && this@case_6_1 != null @@ -81,25 +86,29 @@ inline fun T?.case_6_4(): Boolean? { return if (this@case_6_4 is Number && this@case_6_4 is Int && this@case_6_4 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() println(value_1.length) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number?) { value_1.case_2() println(value_1.inv()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?) { value_1.case_3() println(value_1.inv()) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Any?, value_3: Any?) { when { value_1.case_4_1() -> println(value_1.length) } when { !value_2.case_4_2() -> println(value_2.length) } @@ -107,6 +116,7 @@ fun case_4(value_1: Any?, value_2: Any?, value_3: Any?) { when { value_3.case_4_4() == null -> println(value_3.length) } } +// TESTCASE NUMBER: 5 fun case_5(value_1: Number?, value_2: Number?, value_3: Number?) { if (value_1.case_5_1()) println(value_1.inv()) if (!value_2.case_5_2()) println(value_2.inv()) @@ -114,6 +124,7 @@ fun case_5(value_1: Number?, value_2: Number?, value_3: Number?) { if (value_3.case_5_4() == null) println(value_3.inv()) } +// TESTCASE NUMBER: 6 fun case_6(value_1: Any?, value_2: Any?, value_3: Any?) { if (value_1.case_6_1()) println(value_1.inv()) if (!value_2.case_6_2()) println(value_2.inv()) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.kt index 7d8e72bcb5f..8faec4a2700 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 6 - DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 6 + * DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract. */ // FILE: contracts.kt @@ -15,26 +14,31 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T?.case_1(value_1: Int?) { contract { returns() implies (this@case_1 != null && this@case_1 is String && value_1 != null) } if (!(this@case_1 != null && this@case_1 is String && value_1 != null)) throw Exception() } +// TESTCASE NUMBER: 2 fun T.case_2(value_2: Any?) { contract { returns() implies (this@case_2 is Int && this@case_2 != null && value_2 is Number && value_2 != null) } if (!(this@case_2 is Int && this@case_2 != null && value_2 is Number && value_2 != null)) throw Exception() } +// TESTCASE NUMBER: 3 fun T?.case_3(value_2: Any?) { contract { returns() implies (this@case_3 is Number && this@case_3 is Int && this@case_3 != null && value_2 != null) } if (!(this@case_3 is Number && this@case_3 is Int && this@case_3 != null && value_2 != null)) throw Exception() } +// TESTCASE NUMBER: 4 inline fun T?.case_4(value_2: Number, value_3: Any?, value_4: String?) { contract { returns() implies ((this@case_4 is Number || this@case_4 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) } if (!((this@case_4 is Number || this@case_4 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null)) throw Exception() } +// TESTCASE NUMBER: 5 fun T?.case_5_1(value_1: Int?): Boolean { contract { returns(true) implies (this@case_5_1 != null && this@case_5_1 is String && value_1 != null) } return this@case_5_1 != null && this@case_5_1 is String && value_1 != null @@ -52,6 +56,7 @@ fun T?.case_5_4(value_1: Int?): Boolean? { return if (this@case_5_4 != null && this@case_5_4 is String && value_1 != null) null else true } +// TESTCASE NUMBER: 6 fun T.case_6_1(value_2: Any?): Boolean { contract { returns(true) implies (this@case_6_1 is Int && this@case_6_1 != null && value_2 is Number && value_2 != null) } return this@case_6_1 is Int && this@case_6_1 != null && value_2 is Number && value_2 != null @@ -69,6 +74,7 @@ fun T.case_6_4(value_2: Any?): Boolean? { return if (this@case_6_4 is Int && this@case_6_4 != null && value_2 is Number && value_2 != null) null else true } +// TESTCASE NUMBER: 7 fun T?.case_7_1(value_2: Any?): Boolean { contract { returns(true) implies (this@case_7_1 is Number && this@case_7_1 is Int && this@case_7_1 != null && value_2 != null) } return this@case_7_1 is Number && this@case_7_1 is Int && this@case_7_1 != null && value_2 != null @@ -86,6 +92,7 @@ fun T?.case_7_4(value_2: Any?): Boolean? { return if (this@case_7_4 is Number && this@case_7_4 is Int && this@case_7_4 != null && value_2 != null) null else true } +// TESTCASE NUMBER: 8 inline fun T?.case_8_1(value_2: Number, value_3: Any?, value_4: String?): Boolean { contract { returns(true) implies ((this@case_8_1 is Number || this@case_8_1 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) } return (this@case_8_1 is Number || this@case_8_1 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null @@ -103,28 +110,32 @@ inline fun T?.case_8_4(value_2: Number, value_3: Any?, value_ return if ((this@case_8_4 is Number || this@case_8_4 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Int?) { value_1.case_1(value_2) println(value_1.length) println(value_2.inv()) } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number?, value_2: Any?) { value_1.case_2(value_2) println(value_1.inv()) println(value_2.toByte()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: String?) { value_1.case_3(value_2) println(value_1.inv()) println(value_2.length) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_4(value_2, value_3, value_4) println(value_2.inv()) @@ -132,6 +143,7 @@ fun case_4(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { println(value_4.length) } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?, value_5: Any?, value_6: Int?) { when { value_1.case_5_1(value_2) -> { @@ -159,6 +171,7 @@ fun case_5(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?, value_5: } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number?, value_2: Any?, value_3: Number?, value_4: Any?, value_5: Number?, value_6: Any?) { if (value_1.case_6_1(value_2)) { println(value_1.inv()) @@ -178,6 +191,7 @@ fun case_6(value_1: Number?, value_2: Any?, value_3: Number?, value_4: Any?, val } } +// TESTCASE NUMBER: 7 fun case_7(value_1: Any?, value_2: String?, value_3: Any?, value_4: String?, value_5: Any?, value_6: String?) { if (value_1.case_7_1(value_2)) { println(value_1.inv()) @@ -197,6 +211,7 @@ fun case_7(value_1: Any?, value_2: String?, value_3: Any?, value_4: String?, val } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?, value_5: Any?, value_6: Number, value_7: Any?, value_8: String?) { when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_2.inv()) } when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_3.toByte()) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/7.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/7.kt index 9347b15df8f..f3f19441c70 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/7.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/7.kt @@ -1,12 +1,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 7 - DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 7 + * DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls. */ // FILE: contracts.kt @@ -15,6 +14,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1_1(value_1: Int?) { contract { returns() implies (value_1 != null) } if (!(value_1 != null)) throw Exception() @@ -24,6 +24,7 @@ fun case_1_2(value_1: Int?) { if (!(value_1 == null)) throw Exception() } +// TESTCASE NUMBER: 2 fun case_2_1(value_1: Number?) { contract { returns() implies (value_1 is Float) } if (!(value_1 is Float)) throw Exception() @@ -33,6 +34,7 @@ fun case_2_2(value_1: Number?) { if (!(value_1 is Int)) throw Exception() } +// TESTCASE NUMBER: 3 fun case_3_1(value_1: Any?) { contract { returns() implies (value_1 is String) } if (!(value_1 is String)) throw Exception() @@ -42,6 +44,7 @@ fun case_3_2(value_1: Any?) { if (!(value_1 !is String)) throw Exception() } +// TESTCASE NUMBER: 4 fun case_4_1(value_1: Any?) { contract { returns() implies (value_1 is Number?) } if (!(value_1 is Number?)) throw Exception() @@ -55,6 +58,7 @@ fun case_4_3(value_1: Number) { if (!(value_1 is Int)) throw Exception() } +// TESTCASE NUMBER: 5 fun case_5_1(value_1: Int?): Boolean { contract { returns(true) implies (value_1 != null) } return value_1 != null @@ -88,6 +92,7 @@ fun case_5_8(value_1: Int?): Boolean? { return if (value_1 == null) null else true } +// TESTCASE NUMBER: 6 fun case_6_1(value_1: Number?): Boolean { contract { returns(true) implies (value_1 is Float) } return value_1 is Float @@ -121,6 +126,7 @@ fun case_6_8(value_1: Number?): Boolean? { return if (value_1 is Int) null else true } +// TESTCASE NUMBER: 7 fun case_7_1(value_1: Any?): Boolean { contract { returns(true) implies (value_1 is String) } return value_1 is String @@ -154,6 +160,7 @@ fun case_7_8(value_1: Any?): Boolean? { return if (value_1 !is String) null else true } +// TESTCASE NUMBER: 8 fun case_8_1(value_1: Any?): Boolean { contract { returns(true) implies (value_1 is Number?) } return value_1 is Number? @@ -203,10 +210,11 @@ fun case_8_12(value_1: Number): Boolean? { return if (value_1 is Int) null else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { case_1_1(value_1) value_1.inv() @@ -216,6 +224,7 @@ fun case_1(value_1: Int?) { value_1.inv() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Number?) { case_2_1(value_1) value_1.toByte() @@ -223,6 +232,7 @@ fun case_2(value_1: Number?) { value_1.inv() } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?) { case_3_1(value_1) value_1.length @@ -230,6 +240,7 @@ fun case_3(value_1: Any?) { value_1.length } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?) { case_4_1(value_1) value_1?.toByte() @@ -239,6 +250,7 @@ fun case_4(value_1: Any?) { value_1.inv() } +// TESTCASE NUMBER: 5 fun case_5(value_1: Int?, value_2: Int?) { if (case_5_1(value_1)) { value_1.inv() @@ -270,6 +282,7 @@ fun case_5(value_1: Int?, value_2: Int?) { } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Number?, value_2: Number?) { when { case_6_1(value_1) -> { @@ -297,6 +310,7 @@ fun case_6(value_1: Number?, value_2: Number?) { } } +// TESTCASE NUMBER: 7 fun case_7(value_1: Any?, value_2: Any?) { if (case_7_1(value_1)) { value_1.length @@ -316,6 +330,7 @@ fun case_7(value_1: Any?, value_2: Any?) { } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?, value_2: Any?) { if (case_8_1(value_1)) { value_1?.toByte() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/8.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/8.kt index 384db4a65a5..4efcbdf4e77 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/8.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/8.kt @@ -2,12 +2,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 8 - DESCRIPTION: Smartcasts using some Returns effects. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 8 + * DESCRIPTION: Smartcasts using some Returns effects. */ // FILE: contracts.kt @@ -16,6 +15,7 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 3 fun T?.case_3(value_1: Int?, value_2: Boolean): Boolean { contract { returns(true) implies (value_1 == null) @@ -26,6 +26,7 @@ fun T?.case_3(value_1: Int?, value_2: Boolean): Boolean { return value_1 == null } +// TESTCASE NUMBER: 4 fun case_4(value_1: Number, block: (() -> Unit)?): Boolean? { contract { returns(true) implies (value_1 is Int) @@ -36,6 +37,7 @@ fun case_4(value_1: Number, block: (() -> Unit)?): Boolean? { return value_1 == null } +// TESTCASE NUMBER: 5 fun String?.case_5(value_1: Number?): Boolean? { contract { returns(true) implies (value_1 != null) @@ -46,6 +48,7 @@ fun String?.case_5(value_1: Number?): Boolean? { return value_1 == null } +// TESTCASE NUMBER: 6 fun T?.case_6(value_1: Number, value_2: String?): Boolean? { contract { returns(true) implies (this@case_6 != null) @@ -57,10 +60,11 @@ fun T?.case_6(value_1: Number, value_2: String?): Boolean? { return value_1 == null } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { funWithReturns(value_1 is Number?) println(value_1?.toByte()) @@ -70,6 +74,7 @@ fun case_1(value_1: Any?) { } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) { if (!funWithReturnsFalse(value_1 is Number?)) { println(value_1?.toByte()) @@ -79,6 +84,7 @@ fun case_2(value_1: Any?) { } } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?, value_2: Any?) { if (!value_1.case_3(value_1, value_2 is Number?)) { println(value_2?.toByte()) @@ -90,6 +96,7 @@ fun case_3(value_1: Int?, value_2: Any?) { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Number, value_2: (() -> Unit)?) { if (contracts.case_4(value_1, value_2) == true) { value_1.inv() @@ -101,9 +108,9 @@ fun case_4(value_1: Number, value_2: (() -> Unit)?) { } /* - CASE DESCRIPTION: check the conclusion that not-null conditions corresponds to the contract with not null effect - UNEXPECTED BEHAVIOUR: unsafe calls - ISSUES: KT-26612 + * TESTCASE NUMBER: 5 + * UNEXPECTED BEHAVIOUR: unsafe calls + * ISSUES: KT-26612 */ fun case_5(value_1: Number?, value_2: String?) { when (value_2.case_5(value_1)) { @@ -119,9 +126,9 @@ fun case_5(value_1: Number?, value_2: String?) { } /* - CASE DESCRIPTION: check the conclusion that not-null conditions corresponds to the contract with not null effect (with null branch) - UNEXPECTED BEHAVIOUR: unsafe calls - ISSUES: KT-26612 + * TESTCASE NUMBER: 6 + * UNEXPECTED BEHAVIOUR: unsafe calls + * ISSUES: KT-26612 */ fun case_6(value_1: Number, value_2: String?, value_3: Any?) { when (value_3.case_6(value_1, value_2)) { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/9.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/9.kt index 2fa39d5f809..18bc90b3c37 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/9.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/9.kt @@ -3,12 +3,11 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: analysis, smartcasts - NUMBER: 9 - DESCRIPTION: Smartcast using complex condition with some contract functions (Returns effect). + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, analysis, smartcasts + * NUMBER: 9 + * DESCRIPTION: Smartcast using complex condition with some contract functions (Returns effect). */ // FILE: contracts.kt @@ -17,88 +16,97 @@ package contracts import kotlin.contracts.* +// TESTCASE NUMBER: 4 fun T?.case_4(): Boolean { contract { returns(true) implies (this@case_4 != null) } return this@case_4 != null } - fun T?.case_4_1(): Boolean { contract { returns(false) implies (this@case_4_1 != null) } return !(this@case_4_1 != null) } - fun T?.case_4_2(): Boolean? { contract { returns(null) implies (this@case_4_2 is String) } return if (this@case_4_2 is String) null else true } +// TESTCASE NUMBER: 11 fun T?.case_11_1(): Boolean { contract { returns(false) implies (this@case_11_1 != null) } return !(this@case_11_1 != null) } - fun T?.case_11_2(): Boolean? { contract { returns(null) implies (this@case_11_2 is String) } return if (this@case_11_2 is String) null else true } +// TESTCASE NUMBER: 12 fun T?.case_12(): Boolean { contract { returns(false) implies (this@case_12 is String) } return if (this@case_12 is String) false else true } -// FILE: usages.kt +// FILE: main.kt import contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { if (funWithReturnsTrue(value_1 is String) && funWithReturnsTrueAndNotNullCheck(value_1)) { println(value_1.length) } } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?) { if (!funWithReturnsFalse(value_1 is String) && !funWithReturnsTrueAndNullCheck(value_1)) { println(value_1.length) } } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?) { if (funWithReturnsNull(value_1 is String?) == null && funWithReturnsTrue(value_1 != null)) { println(value_1.length) } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Any?) { if (!value_1.case_4_1() && value_1.case_4_2() == null) { println(value_1.length) } } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: Boolean) { if (!funWithReturnsFalse(value_1 is String) && value_2) { println(value_1.length) } } +// TESTCASE NUMBER: 6 fun case_6(value_1: Any?, value_2: Boolean?) { if (funWithReturnsNull(value_1 is String) == null && value_2 != null && value_2) { println(value_1.length) } } +// TESTCASE NUMBER: 7 fun case_7(value_1: String?) { if (funWithReturnsTrueAndNotNullCheck(value_1) && true) { println(value_1.length) } } +// TESTCASE NUMBER: 8 fun case_8(value_1: Any?) { if (funWithReturnsTrueAndNullCheck(value_1) && false) { println(value_1) } } +// TESTCASE NUMBER: 9 fun case_9(value_1: Any?) { if (funWithReturnsFalse(value_1 is String) || funWithReturnsFalse(value_1 is Int)) { @@ -108,6 +116,7 @@ fun case_9(value_1: Any?) { } } +// TESTCASE NUMBER: 10 fun case_10(value_1: Any?) { if (funWithReturnsFalse(value_1 is String) || getBoolean()) { @@ -116,12 +125,14 @@ fun case_10(value_1: Any?) { } } +// TESTCASE NUMBER: 11 fun case_11(value_1: Any?) { if (!(value_1.case_11_1() || value_1.case_11_2() != null)) { println(value_1.length) } } +// TESTCASE NUMBER: 12 fun case_12(value_1: Any?) { if (!value_1.case_12() || !value_1.case_12()) { println(value_1.length) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.kt index 6300756a605..a29b895fd3b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.kt @@ -2,22 +2,23 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 1 - DESCRIPTION: Contract isn't first statement. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 1 + * DESCRIPTION: Contract isn't first statement. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { val value_1 = 1 contract { } return block() } +// TESTCASE NUMBER: 2 inline fun case_2(block: () -> Unit) { 10 - 1 contract { @@ -26,6 +27,7 @@ inline fun case_2(block: () -> Unit) { return block() } +// TESTCASE NUMBER: 3 inline fun case_3(block: () -> Unit) { throw Exception() contract { @@ -34,10 +36,77 @@ inline fun case_3(block: () -> Unit) { return block() } -// это в негативные, +/* + * TESTCASE NUMBER: 4 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 + */ inline fun case_4(block: () -> Unit) { .0009 return contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } } + +/* + * TESTCASE NUMBER: 5 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 + */ +fun case_5(value_1: Int?) { + println("!") + contract { + returns(true) implies (value_1 != null) + } as ContractBuilder +} + +/* + * TESTCASE NUMBER: 6 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 + */ +fun case_6(value_1: Int?) { + 100 + 10 + throw Exception(contract { + returns(true) implies (value_1 != null) + }.toString()) +} + +/* + * TESTCASE NUMBER: 7 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 + */ +fun case_7(value_1: Int?) { + for (i in 0..10) { + println(i) + } + return contract { + returns(true) implies (value_1 != null) + } +} + +/* + * TESTCASE NUMBER: 8 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 + */ +fun case_8(value_1: Int?) { + val f = 10 - 20 + val g = contract { + returns(true) implies (value_1 != null) + } +} + +/* + * TESTCASE NUMBER: 9 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 + */ +fun case_9(number: Int?): Boolean { + val value_1 = number != null + contract { + returns(false) implies (value_1) + } as ContractBuilder + return number == null +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.txt index af31e695912..1faf89ca38b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.txt @@ -4,3 +4,8 @@ public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit public inline fun case_3(/*0*/ block: () -> kotlin.Unit): kotlin.Unit public inline fun case_4(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public fun case_5(/*0*/ value_1: kotlin.Int?): kotlin.Unit +public fun case_6(/*0*/ value_1: kotlin.Int?): kotlin.Unit +public fun case_7(/*0*/ value_1: kotlin.Int?): kotlin.Unit +public fun case_8(/*0*/ value_1: kotlin.Int?): kotlin.Unit +public fun case_9(/*0*/ number: kotlin.Int?): kotlin.Boolean diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/10.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/10.kt index cc52f7418b2..4549291612b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/10.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/10.kt @@ -1,17 +1,17 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 10 - DESCRIPTION: Contract with label after 'contract' keyword. - ISSUES: KT-26153 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 10 + * DESCRIPTION: Contract with label after 'contract' keyword. + * ISSUES: KT-26153 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract test@ { callsInPlace(block, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.kt index 538c6dd110f..2db339ed105 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.kt @@ -1,27 +1,38 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 11 - DESCRIPTION: Functions with contracts and external contract builder. - ISSUES: KT-26186 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 11 + * DESCRIPTION: Functions with contracts and external contract builder. + * ISSUES: KT-26186 */ +// FILE: builder.kt + +package builder + import kotlin.contracts.* -internal inline fun contractBuilder(block: () -> Unit): ContractBuilder.() -> Unit = { +// TESTCASE NUMBER: 1, 2 +inline fun contractBuilder(block: () -> Unit): ContractBuilder.() -> Unit = { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } -internal inline fun case_1(block: () -> Unit) { +// FILE: main.kt + +import builder.* +import kotlin.contracts.* + +// TESTCASE NUMBER: 1 +inline fun case_1(block: () -> Unit) { contract(contractBuilder(block)) return block() } -internal inline fun case_2(block: () -> Unit) { +// TESTCASE NUMBER: 2 +inline fun case_2(block: () -> Unit) { contract(builder = contractBuilder(block)) return block() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.txt index 20c7cc6c019..2dd87a6ba22 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/11.txt @@ -1,5 +1,8 @@ package -internal inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun contractBuilder(/*0*/ block: () -> kotlin.Unit): kotlin.contracts.ContractBuilder.() -> kotlin.Unit +public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit + +package builder { + public inline fun contractBuilder(/*0*/ block: () -> kotlin.Unit): kotlin.contracts.ContractBuilder.() -> kotlin.Unit +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.kt index aed2217d80c..ed5b3d0a60b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.kt @@ -1,34 +1,46 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 12 - DESCRIPTION: Functions with contracts and external effect builder. - ISSUES: KT-26186 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 12 + * DESCRIPTION: Functions with contracts and external effect builder. + * ISSUES: KT-26186 */ +// FILE: builder.kt + +package builder + import kotlin.contracts.* -internal inline fun ContractBuilder.callsInPlaceEffectBuilder(block: () -> Unit) = +// TESTCASE NUMBER: 1, 2, 3 +inline fun ContractBuilder.callsInPlaceEffectBuilder(block: () -> Unit) = callsInPlace(block, InvocationKind.EXACTLY_ONCE) -internal fun ContractBuilder.returnsEffectBuilder(value_1: Int?) = +fun ContractBuilder.returnsEffectBuilder(value_1: Int?) = returns(true) implies (value_1 != null) -internal inline fun case_1(block: () -> Unit) { +// FILE: main.kt + +import builder.* +import kotlin.contracts.* + +// TESTCASE NUMBER: 1 +inline fun case_1(block: () -> Unit) { contract(builder = { callsInPlaceEffectBuilder(block) }) return block() } -internal inline fun case_2(block: () -> Unit) { +// TESTCASE NUMBER: 2 +inline fun case_2(block: () -> Unit) { contract { callsInPlaceEffectBuilder(block) } return block() } -internal inline fun case_3(value_1: Int?, block: () -> Unit) { +// TESTCASE NUMBER: 3 +inline fun case_3(value_1: Int?, block: () -> Unit) { contract({ returnsEffectBuilder(value_1); callsInPlaceEffectBuilder(block) }) return block() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.txt index c1b20218243..7a3bdce0707 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.txt @@ -1,7 +1,10 @@ package -internal inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun case_3(/*0*/ value_1: kotlin.Int?, /*1*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun kotlin.contracts.ContractBuilder.callsInPlaceEffectBuilder(/*0*/ block: () -> kotlin.Unit): kotlin.contracts.CallsInPlace -internal fun kotlin.contracts.ContractBuilder.returnsEffectBuilder(/*0*/ value_1: kotlin.Int?): kotlin.contracts.ConditionalEffect +public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public inline fun case_2(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public inline fun case_3(/*0*/ value_1: kotlin.Int?, /*1*/ block: () -> kotlin.Unit): kotlin.Unit + +package builder { + public inline fun kotlin.contracts.ContractBuilder.callsInPlaceEffectBuilder(/*0*/ block: () -> kotlin.Unit): kotlin.contracts.CallsInPlace + public fun kotlin.contracts.ContractBuilder.returnsEffectBuilder(/*0*/ value_1: kotlin.Int?): kotlin.contracts.ConditionalEffect +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.kt index 6739455fa12..a094203f893 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.kt @@ -2,17 +2,17 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 13 - DESCRIPTION: Contract function with CallsInPlace effect with not allowed implies. - ISSUES: KT-26409 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 13 + * DESCRIPTION: Contract function with CallsInPlace effect with not allowed implies. + * ISSUES: KT-26409 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Any?, block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) implies (value_1 != null) } if (value_1 != null) block() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.kt index 3b41c7355a0..360bd49bf88 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.kt @@ -3,26 +3,28 @@ // !WITH_FUNCTIONS /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 14 - DESCRIPTION: Contract is first statement in control flow terms, but not in tokens order terms. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26153 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 14 + * DESCRIPTION: Contract is first statement in control flow terms, but not in tokens order terms. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26153 */ import kotlin.contracts.* -internal inline fun case_1(block: () -> Unit) { +// TESTCASE NUMBER: 1 +inline fun case_1(block: () -> Unit) { return contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } } +// TESTCASE NUMBER: 2 fun case_2() = contract { } +// TESTCASE NUMBER: 3 inline fun case_3(block: () -> Unit) { val value_1 = contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -30,6 +32,7 @@ inline fun case_3(block: () -> Unit) { block() } +// TESTCASE NUMBER: 4 inline fun case_4(block: () -> Unit) { (contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -37,6 +40,7 @@ inline fun case_4(block: () -> Unit) { return block() } +// TESTCASE NUMBER: 5 inline fun case_5(block: () -> Unit) { test@ contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -44,12 +48,14 @@ inline fun case_5(block: () -> Unit) { return block() } +// TESTCASE NUMBER: 6 inline fun case_6(block: () -> Unit) { throw Exception(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }.toString()) } +// TESTCASE NUMBER: 7 inline fun case_7(block: () -> Unit) { _funWithAnyArg(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.txt index cfffa64eac8..12ffd99098b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/14.txt @@ -2,7 +2,7 @@ package public fun _funWithAnyArg(/*0*/ value_1: kotlin.Any): kotlin.Int public fun _funWithoutArgs(): kotlin.Int -internal inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public inline fun case_1(/*0*/ block: () -> kotlin.Unit): kotlin.Unit public fun case_2(): kotlin.Unit public inline fun case_3(/*0*/ block: () -> kotlin.Unit): kotlin.Unit public inline fun case_4(/*0*/ block: () -> kotlin.Unit): kotlin.Unit diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/15.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/15.kt index 2f411e8f671..2acc33e7200 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/15.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/15.kt @@ -2,23 +2,24 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 15 - DESCRIPTION: contracts with not allowed conditions with boolean constants or boolean constant expressions in implies. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26491 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 15 + * DESCRIPTION: contracts with not allowed conditions with boolean constants or boolean constant expressions in implies. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26491 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(): Boolean { contract { returns(true) implies true } return true } +// TESTCASE NUMBER: 2 fun case_2(): Boolean { contract { returns(true) implies (true || false) } return true || false diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.kt index 21ecfc3a163..7ba38570cd3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.kt @@ -2,18 +2,18 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 16 - DESCRIPTION: Contract isn't in the first position. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26191 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 16 + * DESCRIPTION: Contract isn't in the first position. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26191 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Int?) { println("!") contract { @@ -21,6 +21,7 @@ fun case_1(value_1: Int?) { } as ContractBuilder } +// TESTCASE NUMBER: 2 fun case_2(value_1: Int?) { 100 + 10 throw Exception(contract { @@ -28,6 +29,7 @@ fun case_2(value_1: Int?) { }.toString()) } +// TESTCASE NUMBER: 3 fun case_3(value_1: Int?) { for (i in 0..10) { println(i) @@ -37,6 +39,7 @@ fun case_3(value_1: Int?) { } } +// TESTCASE NUMBER: 4 fun case_4(value_1: Int?) { val f = 10 - 20 val g = contract { @@ -44,6 +47,7 @@ fun case_4(value_1: Int?) { } } +// TESTCASE NUMBER: 5 fun case_5(number: Int?): Boolean { val value_1 = number != null contract { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.kt index 1abd9949559..8e1cb58e5cf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.kt @@ -2,28 +2,30 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 17 - DESCRIPTION: contracts with Nothing expressions in implies. - DISCUSSION - ISSUES: KT-25948 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 17 + * DESCRIPTION: contracts with Nothing expressions in implies. + * DISCUSSION + * ISSUES: KT-25948 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(): Boolean { contract { returns(null) implies throw Exception() } return true } +// TESTCASE NUMBER: 2 fun case_2(): Boolean { contract { returns(null) implies return return return false } return true } +// TESTCASE NUMBER: 3 fun case_3(): Boolean { contract { returns(null) implies return return return false && throw throw throw throw Exception() } return true diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/19.kt similarity index 52% rename from compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/4.kt rename to compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/19.kt index 9772039f847..e65f1eb0bf8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/19.kt @@ -2,24 +2,25 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 4 - DESCRIPTION: contracts with not allowed conditions with boolean constants or constant expressions in implies. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26491 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 19 + * DESCRIPTION: contracts with not allowed conditions with boolean constants or constant expressions in implies. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26491 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(): Boolean { contract { returns(true) implies true } return true } +// TESTCASE NUMBER: 2 fun case_2(): Boolean { contract { returns(true) implies (true || false) } return true || false -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/4.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/19.txt similarity index 100% rename from compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/4.txt rename to compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/19.txt diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.kt index c72cda9deca..8bb678e638e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.kt @@ -2,31 +2,34 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 2 - DESCRIPTION: contracts with not allowed simple conditions in implies + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 2 + * DESCRIPTION: contracts with not allowed simple conditions in implies */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean): Boolean { contract { returns(true) implies (value_1 == true) } return value_1 == true } +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean): Boolean? { contract { returnsNotNull() implies (value_1 != false) } return if (value_1 != false) true else null } +// TESTCASE NUMBER: 3 fun case_3(value_1: String): Boolean { contract { returns(false) implies (value_1 != "") } return !(value_1 != "") } +// TESTCASE NUMBER: 4 fun case_4(value_1: Int): Boolean? { contract { returns(null) implies (value_1 == 0) } return if (value_1 == 0) null else true diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.kt index a38199b3295..659b17e6068 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.kt @@ -2,41 +2,46 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 3 - DESCRIPTION: contracts with not allowed complex conditions in implies. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 3 + * DESCRIPTION: contracts with not allowed complex conditions in implies. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean?): Boolean { contract { returns(true) implies (value_1 != null && value_1 == false) } return value_1 != null && value_1 == false } +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean, value_2: Boolean): Boolean? { contract { returnsNotNull() implies (value_1 != false || value_2) } return if (value_1 != false || value_2) true else null } +// TESTCASE NUMBER: 3 fun case_3(value_1: String?, value_2: Boolean): Boolean { contract { returns(false) implies (value_1 != null && value_2 != true) } return !(value_1 != null && value_2 != true) } +// TESTCASE NUMBER: 4 fun case_4(value_1: Nothing?, value_2: Boolean?): Boolean? { contract { returns(null) implies (value_1 == null || value_2 != null || value_2 == false) } return if (value_1 == null || value_2 != null || value_2 == false) null else true } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: String?): Boolean? { contract { returns(null) implies (value_1 != null && value_2 != null || value_2 == ".") } return if (value_1 != null && value_2 != null || value_2 == ".") null else true } +// TESTCASE NUMBER: 6 fun case_6(value_1: Boolean, value_2: Int?): Boolean? { contract { returns(null) implies (value_2 == null && value_1 || value_2 == 0) } return if (value_2 == null && value_1 || value_2 == 0) null else true diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.kt index 387b4d998b1..c260f66cb35 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.kt @@ -2,26 +2,28 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 4 - DESCRIPTION: contracts with not allowed conditions with constants in implies. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 4 + * DESCRIPTION: contracts with not allowed conditions with constants in implies. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(): Boolean? { contract { returnsNotNull() implies (null) } return true } +// TESTCASE NUMBER: 2 fun case_2(): Boolean { contract { returns(false) implies 0.000001 } return true } +// TESTCASE NUMBER: 3 fun case_3(): Boolean? { contract { returns(null) implies "" } return null diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.kt index 08ae43c6d1e..55425c12898 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.kt @@ -2,45 +2,50 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 5 - DESCRIPTION: contracts with not allowed expressions in implies. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 5 + * DESCRIPTION: contracts with not allowed expressions in implies. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(): Boolean { contract { returns(true) implies (-10) } return true } +// TESTCASE NUMBER: 2 fun case_2(): Boolean { contract { returnsNotNull() implies (return return return true) } return true } +// TESTCASE NUMBER: 3 fun case_3(): Boolean { contract { returns(false) implies ("..." + "$value_1") } return true } /* - UNEXPECTED BEHAVIOUR - ISSUES: KT-26386 + * TESTCASE NUMBER: 4 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26386 */ -//fun case_4(): Boolean? { -// contract { returns(null) implies case_4() } -// return null -//} +fun case_4(): Boolean? { + contract { returns(null) implies case_4() } + return null +} +// TESTCASE NUMBER: 5 fun case_5(): Boolean? { contract { returns(null) implies listOf(0) } return null } +// TESTCASE NUMBER: 6 fun case_6(value_1: Boolean): Boolean? { contract { returns(null) implies contract { returns(null) implies (!value_1) } } return null diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.kt index 9ad066e2d96..d00af514b6e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.kt @@ -3,16 +3,16 @@ // !WITH_BASIC_TYPES /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 6 - DESCRIPTION: contracts with not function parameters in implies. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 6 + * DESCRIPTION: contracts with not function parameters in implies. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 object case_1 { val value_1 = getBoolean() const val value_2 = true @@ -22,7 +22,6 @@ object case_1 { contract { returnsNotNull() implies (value_1) } return if (value_1) true else null } - fun case_1_2(): Boolean? { contract { returns(null) implies (value_2) } return if (value_2) null else true @@ -34,6 +33,7 @@ object case_1 { } } +// TESTCASE NUMBER: 2 class case_2(value_5: Boolean, val value_1: Boolean) { val value_2 = getBoolean() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.kt index c525c31f5e1..97855708140 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.kt @@ -3,20 +3,20 @@ // !WITH_BASIC_TYPES /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 7 - DESCRIPTION: Contract function with 'this' labeled by not current extensible object - ISSUES: KT-26149 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 7 + * DESCRIPTION: Contract function with 'this' labeled by not current extensible object + * ISSUES: KT-26149 */ import kotlin.contracts.* -fun T?.case_3() { - fun K?.case_3_1(): Boolean { - contract { returns(true) implies (this@case_3 != null) } - return this@case_3 != null +// TESTCASE NUMBER: 1 +fun T?.case_1() { + fun K?.case_1_1(): Boolean { + contract { returns(true) implies (this@case_1 != null) } + return this@case_1 != null } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.txt index a4a7449bc0f..e41314319cb 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/7.txt @@ -13,7 +13,7 @@ public fun getNothing(): kotlin.Nothing public fun getShort(/*0*/ arg: kotlin.Any = ...): kotlin.Short public fun getString(/*0*/ arg: kotlin.Any = ...): kotlin.String public fun getUnit(): () -> kotlin.Unit -public fun T?.case_3(): kotlin.Unit +public fun T?.case_1(): kotlin.Unit public final class _BasicTypesProvider { public constructor _BasicTypesProvider() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/8.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/8.kt index ccdc6a9b0f4..a4f8de78057 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/8.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/8.kt @@ -2,27 +2,29 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 8 - DESCRIPTION: Not allowed empty contract. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 8 + * DESCRIPTION: Not allowed empty contract. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { } return block() } +// TESTCASE NUMBER: 2 inline fun case_2(block: () -> Unit) { contract({ }) return block() } +// TESTCASE NUMBER: 3 inline fun case_3(block: () -> Unit) { contract(builder = { }) return block() -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/9.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/9.kt index 317b53669f5..ac3720ce2b6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/9.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/9.kt @@ -2,18 +2,18 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 9 - DESCRIPTION: Function with contract as returned expression. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 9 + * DESCRIPTION: Function with contract as returned expression. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) = { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/1.kt index 616f36dd31c..a909d2748a6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/1.kt @@ -1,21 +1,22 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 1 - DESCRIPTION: Functions with simple contracts. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 1 + * DESCRIPTION: Functions with simple contracts. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } +// TESTCASE NUMBER: 2 inline fun case_2(value_1: Int?, block: () -> Unit): Boolean { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -25,6 +26,7 @@ inline fun case_2(value_1: Int?, block: () -> Unit): Boolean { return value_1 != null } +// TESTCASE NUMBER: 3 inline fun T?.case_3(value_1: Int?, value_2: Boolean, value_3: Int?, block: () -> Unit): Boolean? { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/2.kt index 5b8409217f8..088eba97bd5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/2.kt @@ -1,21 +1,22 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 2 - DESCRIPTION: Functions with contract and builder lambda in parentheses. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, common + * NUMBER: 2 + * DESCRIPTION: Functions with contract and builder lambda in parentheses. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) return block() } +// TESTCASE NUMBER: 2 inline fun case_2(block: () -> Unit) { contract(builder = { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) return block() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.kt deleted file mode 100644 index 95415a47842..00000000000 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.kt +++ /dev/null @@ -1,53 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts - -/* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, common - NUMBER: 3 - DESCRIPTION: Contract isn't in the first position. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26191 - */ - -import kotlin.contracts.* - -fun case_1(value_1: Int?) { - println("!") - contract { - returns(true) implies (value_1 != null) - } as ContractBuilder -} - -fun case_2(value_1: Int?) { - 100 + 10 - throw Exception(contract { - returns(true) implies (value_1 != null) - }.toString()) -} - -fun case_3(value_1: Int?) { - for (i in 0..10) { - println(i) - } - return contract { - returns(true) implies (value_1 != null) - } -} - -fun case_4(value_1: Int?) { - val f = 10 - 20 - val g = contract { - returns(true) implies (value_1 != null) - } -} - -fun case_5(number: Int?): Boolean { - val value_1 = number != null - contract { - returns(false) implies (value_1) - } as ContractBuilder - return number == null -} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.txt deleted file mode 100644 index 49234c3e061..00000000000 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.txt +++ /dev/null @@ -1,7 +0,0 @@ -package - -public fun case_1(/*0*/ value_1: kotlin.Int?): kotlin.Unit -public fun case_2(/*0*/ value_1: kotlin.Int?): kotlin.Unit -public fun case_3(/*0*/ value_1: kotlin.Int?): kotlin.Unit -public fun case_4(/*0*/ value_1: kotlin.Int?): kotlin.Unit -public fun case_5(/*0*/ number: kotlin.Int?): kotlin.Boolean diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.kt index ea9cacc5528..ded75c81845 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.kt @@ -1,39 +1,43 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, callsInPlace - NUMBER: 1 - DESCRIPTION: contract functions with CallsInPlace with dynamic InvocationKind. - ISSUES: KT-26152 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, callsInPlace + * NUMBER: 1 + * DESCRIPTION: contract functions with CallsInPlace with dynamic InvocationKind. + * ISSUES: KT-26152 */ import kotlin.contracts.* -internal val invocationKind: InvocationKind = InvocationKind.EXACTLY_ONCE +// TESTCASE NUMBER: 1, 2, 3, 4 +val invocationKind: InvocationKind = InvocationKind.EXACTLY_ONCE -internal object SampleObject { +object SampleObject { val invocationKind = InvocationKind.EXACTLY_ONCE } -internal inline fun case_1(invocationKind: InvocationKind, block: () -> Unit) { +// TESTCASE NUMBER: 1 +inline fun case_1(invocationKind: InvocationKind, block: () -> Unit) { contract { callsInPlace(block, invocationKind) } return block() } +// TESTCASE NUMBER: 2 inline fun case_2(invocationKind: T, block: () -> Unit) { contract { callsInPlace(block, invocationKind) } return block() } -internal inline fun case_3(block: () -> Unit) { +// TESTCASE NUMBER: 3 +inline fun case_3(block: () -> Unit) { contract { callsInPlace(block, invocationKind) } return block() } -internal inline fun case_4(block: () -> Unit) { +// TESTCASE NUMBER: 4 +inline fun case_4(block: () -> Unit) { contract { callsInPlace(block, SampleObject.invocationKind) } return block() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.txt index bb7f825e378..05bce8c8828 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.txt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/1.txt @@ -1,12 +1,12 @@ package -internal val invocationKind: kotlin.contracts.InvocationKind -internal inline fun case_1(/*0*/ invocationKind: kotlin.contracts.InvocationKind, /*1*/ block: () -> kotlin.Unit): kotlin.Unit +public val invocationKind: kotlin.contracts.InvocationKind +public inline fun case_1(/*0*/ invocationKind: kotlin.contracts.InvocationKind, /*1*/ block: () -> kotlin.Unit): kotlin.Unit public inline fun case_2(/*0*/ invocationKind: T, /*1*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun case_3(/*0*/ block: () -> kotlin.Unit): kotlin.Unit -internal inline fun case_4(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public inline fun case_3(/*0*/ block: () -> kotlin.Unit): kotlin.Unit +public inline fun case_4(/*0*/ block: () -> kotlin.Unit): kotlin.Unit -internal object SampleObject { +public object SampleObject { private constructor SampleObject() public final val invocationKind: kotlin.contracts.InvocationKind public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/2.kt index 8b12cea9f4b..f17f6c41db4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/neg/2.kt @@ -1,18 +1,18 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, callsInPlace - NUMBER: 2 - DESCRIPTION: functions with contract and duplicate CallsInPlace. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26150 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, callsInPlace + * NUMBER: 2 + * DESCRIPTION: functions with contract and duplicate CallsInPlace. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26150 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) @@ -21,6 +21,7 @@ inline fun case_1(block: () -> Unit) { return block() } +// TESTCASE NUMBER: 2 inline fun case_2(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/1.kt index bff9ed94539..59940d046c9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/1.kt @@ -1,31 +1,34 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, callsInPlace - NUMBER: 1 - DESCRIPTION: contract functions with CallsInPlace effects with different invocation kinds. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, callsInPlace + * NUMBER: 1 + * DESCRIPTION: contract functions with CallsInPlace effects with different invocation kinds. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } +// TESTCASE NUMBER: 2 inline fun case_2(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) } return block() } +// TESTCASE NUMBER: 3 inline fun case_3(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.AT_LEAST_ONCE) } return block() } +// TESTCASE NUMBER: 4 inline fun case_4(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.UNKNOWN) } return block() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/2.kt index 9286c91af29..b93291fcbc8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/2.kt @@ -2,19 +2,19 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, callsInPlace - NUMBER: 2 - DESCRIPTION: Contract with 'this' in first parameter of CallsInPlace. - DISCUSSION - UNEXPECTED BEHAVIOUR - ISSUES: KT-26294 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, callsInPlace + * NUMBER: 2 + * DESCRIPTION: Contract with 'this' in first parameter of CallsInPlace. + * DISCUSSION + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26294 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun > T.case_1(block: () -> Unit) { contract { callsInPlace(this@case_1, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/3.kt index a34a88559f8..7b6e6347ebb 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/callsInPlace/pos/3.kt @@ -2,18 +2,18 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, callsInPlace - NUMBER: 3 - DESCRIPTION: Contract with 'this' in first parameter of CallsInPlace. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26294 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, callsInPlace + * NUMBER: 3 + * DESCRIPTION: Contract with 'this' in first parameter of CallsInPlace. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26294 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun > T.case_1(block: () -> Unit) { contract { callsInPlace(this@case_1, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.kt index 2aa9d23f618..95fad98e591 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.kt @@ -2,17 +2,17 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, common - NUMBER: 1 - DESCRIPTION: Indirect effect functions call. - ISSUES: KT-26175 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, common + * NUMBER: 1 + * DESCRIPTION: Indirect effect functions call. + * ISSUES: KT-26175 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }() @@ -20,6 +20,7 @@ inline fun case_1(block: () -> Unit) { return block() } +// TESTCASE NUMBER: 2 fun case_2(x: Any?): Boolean { contract { returns(true).apply { implies (x is Number) } // 'Returns' as result @@ -27,6 +28,7 @@ fun case_2(x: Any?): Boolean { return x is Number } +// TESTCASE NUMBER: 3 fun case_3(x: Any?): Boolean { contract { returns(true).also { it implies (x is Number) } // 'Returns' as result @@ -34,6 +36,7 @@ fun case_3(x: Any?): Boolean { return x is Number } +// TESTCASE NUMBER: 4 fun case_4(x: Any?): Boolean { contract { returns(true).let { it implies (x is Number) } // 'ConditionalEffect' as result @@ -41,6 +44,7 @@ fun case_4(x: Any?): Boolean { return x is Number } +// TESTCASE NUMBER: 5 fun case_5(x: Any?): Boolean { contract { returns(true).run { implies (x is Number) } // 'ConditionalEffect' as result @@ -48,6 +52,7 @@ fun case_5(x: Any?): Boolean { return x is Number } +// TESTCASE NUMBER: 6 fun case_6(x: Any?): Boolean { contract { returns(true).takeIf { it implies (x is Number); false } // null, must be unrecognized effect diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.kt index 2dd85f8926e..238b5e47285 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.kt @@ -1,32 +1,35 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 1 - DESCRIPTION: Using equality with expressions in implies. - ISSUES: KT-26178 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 1 + * DESCRIPTION: Using equality with expressions in implies. + * ISSUES: KT-26178 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { contract { returns(true) implies (x == -.15f) } return x !is Number } +// TESTCASE NUMBER: 2 fun case_2(x: Any?): Boolean { contract { returns(true) implies (x == "..." + ".") } return x !is Number } +// TESTCASE NUMBER: 3 fun case_3(x: Int, y: Int): Boolean { contract { returns(true) implies (x > y) } return x > y } +// TESTCASE NUMBER: 4 fun case_4(x: Any?, y: Any?): Boolean { contract { returns(true) implies (x == y.toString()) } return x !is Number diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.kt index bc9beefcfbd..f2c7d78f693 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.kt @@ -1,16 +1,16 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 2 - DESCRIPTION: Using equality with not labeled 'this' in implies. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 2 + * DESCRIPTION: Using equality with not labeled 'this' in implies. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun Any?.case_1(): Boolean { contract { returns(true) implies (this != null) @@ -18,6 +18,7 @@ fun Any?.case_1(): Boolean { return this != null } +// TESTCASE NUMBER: 2 fun Any?.case_2(): Boolean { contract { returnsNotNull() implies (this is Number?) @@ -25,6 +26,7 @@ fun Any?.case_2(): Boolean { return this is Number? } +// TESTCASE NUMBER: 3 fun T?.case_3(): Boolean { contract { returnsNotNull() implies (this != null) @@ -32,6 +34,7 @@ fun T?.case_3(): Boolean { return this != null } +// TESTCASE NUMBER: 4 inline fun T.case_4(): Boolean { contract { returns(null) implies (this is Int) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.kt index ec19ffcee86..7549be2e9cf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.kt @@ -2,17 +2,17 @@ // !WITH_OBJECTS /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 3 - DESCRIPTION: Using reference equality in implies. - ISSUES: KT-26177 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 3 + * DESCRIPTION: Using reference equality in implies. + * ISSUES: KT-26177 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { contract { returns(true) implies (x === _EmptyObject) // should be not allowed diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.kt index 1ce50418a0b..b30ca3f49db 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.kt @@ -1,27 +1,29 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 4 - DESCRIPTION: Using equality with literals in implies. - ISSUES: KT-26178 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 4 + * DESCRIPTION: Using equality with literals in implies. + * ISSUES: KT-26178 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { contract { returns(true) implies (x == .15f) } return x == .15f } +// TESTCASE NUMBER: 2 fun case_2(x: Any?) { contract { returns() implies (x == "...") } if (x != "...") throw Exception() } +// TESTCASE NUMBER: 3 fun case_3(x: Any?): Boolean { contract { returns(true) implies (x == '-') } return x == '-' diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.kt index 26747de81e7..88cb905a8d5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.kt @@ -1,17 +1,17 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 5 - DESCRIPTION: Contract on the extension function with Boolean upper bound (Boolean or Nothing) or smartcast to Boolean. - DISCUSSION + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 5 + * DESCRIPTION: Contract on the extension function with Boolean upper bound (Boolean or Nothing) or smartcast to Boolean. + * DISCUSSION */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun Boolean>T.case_1(): Boolean? { contract { returns(null) implies (!this@case_1) } return if (!this) null else true diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.kt index 3659f48f560..c6fe07e0d66 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.kt @@ -1,46 +1,52 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 6 - DESCRIPTION: Contract on the extension function with smartcast to Boolean. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 6 + * DESCRIPTION: Contract on the extension function with smartcast to Boolean. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun Boolean?.case_1(): Boolean { contract { returns(true) implies (this@case_1 != null && this@case_1) } return this != null && this } +// TESTCASE NUMBER: 2 fun Boolean>T?.case_2(): Boolean { contract { returns(true) implies (this@case_2 != null && this@case_2 !is Nothing && this@case_2) } return this != null && this !is Nothing && this } +// TESTCASE NUMBER: 3 fun T?.case_3() { contract { returns() implies (this@case_3 == null || this@case_3 is Boolean? && !this@case_3) } if (!(this == null || this is Boolean? && !this)) throw Exception() } +// TESTCASE NUMBER: 4 fun case_4(value_1: Boolean?): Boolean { contract { returns(true) implies (value_1 != null && !value_1) } return value_1 != null && !value_1 } +// TESTCASE NUMBER: 5 fun Boolean.case_5(value_1: Any?): Boolean? { contract { returnsNotNull() implies (value_1 is Boolean? && value_1 != null && value_1) } return if (value_1 is Boolean? && value_1 != null && value_1) true else null } +// TESTCASE NUMBER: 6 fun Boolean?.case_6(): Boolean? { contract { returnsNotNull() implies (this@case_6 != null && this@case_6) } return if (this@case_6 != null && this@case_6) true else null } +// TESTCASE NUMBER: 7 fun T.case_7(value_1: Any?): Boolean? { contract { returnsNotNull() implies (value_1 is Boolean? && value_1 != null && value_1 && this@case_7 != null && this@case_7) } return if (value_1 is Boolean? && value_1 != null && value_1 && this@case_7 != null && this@case_7) true else null diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/7.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/7.kt index fc3d5bb70be..5ce6451c0a4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/7.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/7.kt @@ -1,32 +1,35 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 7 - DESCRIPTION: Returns effect with type checking with generic parameter - ISSUES: KT-26296 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 7 + * DESCRIPTION: Returns effect with type checking with generic parameter + * ISSUES: KT-26296 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun T.case_1() { contract { returns() implies (this@case_1 is T) } if (!(this@case_1 is T)) throw Exception() } +// TESTCASE NUMBER: 2 fun String> T?.case_2(value_1: K?) { contract { returns() implies (this@case_2 is T && value_1 is K) } if (!(this@case_2 is T && value_1 is K)) throw Exception() } +// TESTCASE NUMBER: 3 inline fun T?.case_3(value_1: Any?) { contract { returns() implies (value_1 is T) } if (!(value_1 is T)) throw Exception() } +// TESTCASE NUMBER: 4 inline fun K?.case_4(value_1: Any?) { contract { returns() implies (this@case_4 !is T || value_1 is T) } if (!(this@case_4 !is T || value_1 is T)) throw Exception() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/1.kt index 2546a800bfe..84d013385d5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/1.kt @@ -3,71 +3,82 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 1 - DESCRIPTION: Returns effect with simple conditions. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 1 + * DESCRIPTION: Returns effect with simple conditions. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(value_1: Boolean) { contract { returns() implies (value_1) } if (!value_1) throw Exception() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Boolean): Boolean { contract { returns(false) implies (!value_1) } return value_1 } +// TESTCASE NUMBER: 3 fun Boolean.case_3() { contract { returns() implies (!this@case_3) } if (this@case_3) throw Exception() } +// TESTCASE NUMBER: 5 fun case_5(value_1: Any?) { contract { returns() implies (value_1 is String) } if (value_1 !is String) throw Exception() } +// TESTCASE NUMBER: 6 fun case_6(value_1: Any?) { contract { returns() implies (value_1 !is String?) } if (value_1 is String?) throw Exception() } +// TESTCASE NUMBER: 7 fun Any?.case_7() { contract { returns() implies (this@case_7 is Number) } if (this !is Number) throw Exception() } +// TESTCASE NUMBER: 8 fun T?.case_8() { contract { returns() implies (this@case_8 !is _ClassLevel3?) } if (this is _ClassLevel3?) throw Exception() } +// TESTCASE NUMBER: 9 fun T.case_9(): Boolean? { contract { returns(null) implies (this@case_9 is Byte?) } return if (this is Byte?) null else true } +// TESTCASE NUMBER: 10 fun case_10(value_1: Any?) { contract { returns() implies (value_1 == null) } if (value_1 != null) throw Exception() } +// TESTCASE NUMBER: 11 fun case_11(value_1: Any?): Boolean? { contract { returns(null) implies (value_1 != null) } return if (value_1 != null) null else true } +// TESTCASE NUMBER: 12 fun Char.case_12() { contract { returns() implies (this@case_12 == null) } if (this@case_12 != null) throw Exception() } +// TESTCASE NUMBER: 13 fun T?.case_13() { contract { returns() implies (this@case_13 == null) } if (this != null) throw Exception() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/2.kt index 3658d7a9cf0..656a26582af 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/2.kt @@ -3,31 +3,34 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 2 - DESCRIPTION: Returns effect with complex conditions (using conjunction and disjuntion). + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 2 + * DESCRIPTION: Returns effect with complex conditions (using conjunction and disjuntion). */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1(cond1: Boolean, cond2: Boolean, cond3: Boolean) { contract { returns() implies (cond1 && !cond2 || cond3) } if (!(cond1 && !cond2 || cond3)) throw Exception() } +// TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Any?, value_3: Any?) { contract { returns() implies (value_1 is String? || value_2 !is Int && value_3 !is Nothing?) } if (!(value_1 is String? || value_2 !is Int && value_3 !is Nothing?)) throw Exception() } +// TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: Any?, value_3: Any?) { contract { returns() implies (value_1 == null || value_2 != null && value_3 == null) } if (!(value_1 == null || value_2 != null && value_3 == null)) throw Exception() } +// TESTCASE NUMBER: 4 fun T.case_4(): Boolean { contract { returns(false) implies (this@case_4 is Char || this@case_4 == null) } return !(this is Char || this == null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/3.kt index aa2e89582ca..086402c08d6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/pos/3.kt @@ -1,26 +1,28 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractBuilder, effects, returns - NUMBER: 3 - DESCRIPTION: Returns effect with conditions on receiver. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractBuilder, effects, returns + * NUMBER: 3 + * DESCRIPTION: Returns effect with conditions on receiver. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun Any?.case_1(): Boolean { contract { returns(false) implies (this@case_1 != null) } return this == null } +// TESTCASE NUMBER: 2 fun T?.case_2(value_1: Any?, value_2: Any?) { contract { returns() implies (this@case_2 is String? || value_1 !is Int && value_2 !is Nothing?) } if (!(this@case_2 is String? || value_1 !is Int && value_2 !is Nothing?)) throw Exception() } +// TESTCASE NUMBER: 3 inline fun T.case_3(value_1: Any?) { contract { returns() implies (value_1 == null || this@case_3 != null && this@case_3 is Int) } if (!(value_1 == null || this@case_3 != null && this@case_3 is Int)) throw Exception() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/1.kt index b23398ddc61..4b1a66893b9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/1.kt @@ -1,16 +1,16 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractFunction - NUMBER: 1 - DESCRIPTION: Check that recursion isn't allowed in contract functions with CallsInPlace effect. + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractFunction + * NUMBER: 1 + * DESCRIPTION: Check that recursion isn't allowed in contract functions with CallsInPlace effect. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.kt index a4c4c2ec8ca..ae66ba32458 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.kt @@ -2,17 +2,17 @@ // !WITH_CLASSES /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractFunction - NUMBER: 2 - DESCRIPTION: Check report about use contracts in literal functions, lambdas or not top-level functions. - ISSUES: KT-26149 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractFunction + * NUMBER: 2 + * DESCRIPTION: Check report about use contracts in literal functions, lambdas or not top-level functions. + * ISSUES: KT-26149 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1() { val fun_1 = fun(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } @@ -23,6 +23,7 @@ fun case_1() { println("1") } +// TESTCASE NUMBER: 2 fun case_2() { val lambda_1 = { block: () -> Unit -> contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } @@ -33,6 +34,7 @@ fun case_2() { println("1") } +// TESTCASE NUMBER: 3 object case_3 { fun case_3(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } @@ -40,8 +42,12 @@ object case_3 { } } -// ISSUES: KT-26244 +/* + * TESTCASE NUMBER: 4 + * ISSUES: KT-26244 + */ class case_4 : _ClassLevel3() { + fun T.case_4_1(): Boolean { contract { returns(false) implies (this@case_4 !is _ClassLevel1) } return this == null @@ -74,7 +80,10 @@ class case_4 : _ClassLevel3() { fun case_4_5() = _ClassLevel3().case_4_5_wrap() } -// ISSUES: KT-26244 +/* + * TESTCASE NUMBER: 5 + * ISSUES: KT-26244 + */ class case_5 : _ClassLevel5() { inner class case_5_1 { fun K.case_5_1_1() { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/3.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/3.kt index 88a79945d2e..3d209ff09be 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/3.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/3.kt @@ -1,23 +1,24 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractFunction - NUMBER: 3 - DESCRIPTION: Check that fun with contract and CallsInPlace effect is an inline function. - UNEXPECTED BEHAVIOUR - ISSUES: KT-26126 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractFunction + * NUMBER: 3 + * DESCRIPTION: Check that fun with contract and CallsInPlace effect is an inline function. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-26126 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun funWithContractExactlyOnce(block: () -> Unit) { // report about not-inline function is expected contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } +// TESTCASE NUMBER: 1 fun case_1() { val value_1: Int funWithContractExactlyOnce { value_1 = 10 } // back-end exception diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/4.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/4.kt index a1f75430e7a..67dcb230b51 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/4.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/4.kt @@ -2,18 +2,18 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) - - SECTION: contracts - CATEGORIES: declarations, contractFunction - NUMBER: 4 - DESCRIPTION: Check that fun with contract and CallsInPlace effect is an inline function. - UNEXPECTED BEHAVIOUR - ISSUES: KT-27090 + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: contracts, declarations, contractFunction + * NUMBER: 4 + * DESCRIPTION: Check that fun with contract and CallsInPlace effect is an inline function. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-27090 */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 val Boolean.case_1: () -> Unit get() { contract { @@ -22,6 +22,7 @@ val Boolean.case_1: () -> Unit return {} } +// TESTCASE NUMBER: 2 val (() -> Unit).case_2: () -> Unit get() { contract { @@ -30,6 +31,7 @@ val (() -> Unit).case_2: () -> Unit return {} } +// TESTCASE NUMBER: 3 var Boolean.case_3: () -> Unit get() { return {} @@ -40,6 +42,7 @@ var Boolean.case_3: () -> Unit } } +// TESTCASE NUMBER: 4 var (() -> Unit).case_4: () -> Unit get() { return {} @@ -50,6 +53,7 @@ var (() -> Unit).case_4: () -> Unit } } +// TESTCASE NUMBER: 5 val Boolean.case_5: () -> Unit get() { contract { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/1.kt index 00b6d08032f..083052c562c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/1.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/1.kt @@ -1,32 +1,35 @@ // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts /* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractFunction - NUMBER: 1 - DESCRIPTION: Contract function usage before declaration it + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) + * + * SECTIONS: contracts, declarations, contractFunction + * NUMBER: 1 + * DESCRIPTION: Use a contract function before the declaration it. */ import kotlin.contracts.* +// TESTCASE NUMBER: 1 fun case_1_1(x: Any?) { if (case_1_2(x)) { x.length } } +// TESTCASE NUMBER: 2 fun case_2_1(x: Number?) { case_2_2(x) println(x.toByte()) } +// TESTCASE NUMBER: 1 fun case_1_2(x: Any?): Boolean { contract { returns(true) implies (x is String) } return x is String } +// TESTCASE NUMBER: 2 fun case_2_2(x: Any?) { contract { returns() implies(x != null) } if (x == null) throw Exception() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.kt deleted file mode 100644 index c2c6dc4051a..00000000000 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.kt +++ /dev/null @@ -1,35 +0,0 @@ -// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts - -/* - KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) - - SECTION: contracts - CATEGORIES: declarations, contractFunction - NUMBER: 2 - DESCRIPTION: Contract function usage before declaration it - */ - -import kotlin.contracts.* - -fun case_1_1(x: Any?) { - if (case_1_2(x)) { - x.length - } -} - -fun case_2_1(x: Number?) { - case_2_2(x) - println(x.toByte()) -} - -fun case_1_2(x: Any?): Boolean { - contract { returns(true) implies (x is String) } - return x is String -} - -fun case_2_2(x: Any?) { - contract { returns() implies(x != null) } - if (x == null) throw Exception() -} - - diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.txt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.txt deleted file mode 100644 index 365216337a8..00000000000 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.txt +++ /dev/null @@ -1,10 +0,0 @@ -package - -public fun case_1_1(/*0*/ x: kotlin.Any?): kotlin.Unit -public fun case_1_2(/*0*/ x: kotlin.Any?): kotlin.Boolean - Returns(TRUE) -> x is String - -public fun case_2_1(/*0*/ x: kotlin.Number?): kotlin.Unit -public fun case_2_2(/*0*/ x: kotlin.Any?): kotlin.Unit - Returns(WILDCARD) -> x != null - diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.1.kt index 4bbcc3beb81..c980bf094d2 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.1.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 1 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the class. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 1 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the class. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class true {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.10.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.10.kt index 1460398b1de..2d11f986c46 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.10.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.10.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 10 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the companionObject. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 10 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the companionObject. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.11.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.11.kt index bc671e821da..8ff4d5e7eb6 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.11.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.11.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 11 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the function. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 11 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the function. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun true() {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.12.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.12.kt index 9ddd926b551..69772b6ab56 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.12.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.12.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 12 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the setter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 12 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the setter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.13.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.13.kt index bdbd3ab4714..3be49f58816 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.13.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.13.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 13 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the simpleUserType. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 13 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the simpleUserType. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1(a: true) {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.14.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.14.kt index 0d7882ed85b..6dcfa36993a 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.14.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.14.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 14 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the typeParameter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 14 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the typeParameter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.15.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.15.kt index 60eaf4fd93e..68087107e2a 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.15.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.15.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 15 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the parameter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 15 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the parameter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1(true: Int) {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.16.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.16.kt index d960b5948b5..7af8e7bb377 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.16.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.16.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 16 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the fileAnnotationComplex. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 16 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the fileAnnotationComplex. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @file:[JvmName.true()] diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.17.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.17.kt index d8ba0aa2216..43b643532d7 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.17.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.17.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 17 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the object. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 17 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the object. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ object A : true {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.18.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.18.kt index 746545a23e4..f08d1e4b7b1 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.18.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.18.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 18 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the typeAlias. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 18 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the typeAlias. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ typealias true = Boolean diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.19.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.19.kt index b7daa3723a3..9c27d27df72 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.19.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.19.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 19 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the import. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 19 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the import. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ import org.jetbrains.true.* diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.2.kt index e7406d2de8e..1a7e6a03021 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.2.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 2 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the labelReference. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 2 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the labelReference. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.20.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.20.kt index e4beaec53b7..45711e3b84f 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.20.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.20.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 20 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the infixFunctionCall. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 20 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the infixFunctionCall. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.21.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.21.kt index 67225667ace..69e86d3cdec 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.21.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.21.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 21 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the catchBlock. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 21 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the catchBlock. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.22.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.22.kt index 33b45021969..224507e9a91 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.22.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.22.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 22 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the labelDefinition. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 22 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the labelDefinition. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.23.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.23.kt index 059b1b9aecf..16126d4a8a5 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.23.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.23.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 23 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the atomicExpression. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 23 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the atomicExpression. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ val true = 10 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.24.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.24.kt index 52f866a1799..9157d323e5e 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.24.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.24.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 24 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the variableDeclarationEntry. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 24 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the variableDeclarationEntry. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.25.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.25.kt index b8aa7912eb9..21df7b99cf9 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.25.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.25.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 25 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the valueArgument. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 25 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the valueArgument. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.26.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.26.kt index 353183f4aaf..535c0dbf1a0 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.26.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.26.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 26 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the callableReference. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 26 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the callableReference. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun case_1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.3.kt index 7bd51cd3a57..264711149ab 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.3.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 3 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the typeConstraint. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 3 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the typeConstraint. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.4.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.4.kt index 45ee09bec91..148de84019a 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.4.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.4.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 4 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the fileAnnotationSimple. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 4 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the fileAnnotationSimple. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @file:true diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.5.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.5.kt index c2c68526c6d..39a550ce212 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.5.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.5.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 5 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the packageComplex. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 5 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the packageComplex. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.true diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.6.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.6.kt index 74bd7cf90f5..f40578a668f 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.6.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.6.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 6 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the packageSimple. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 6 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the packageSimple. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package true diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.7.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.7.kt index 360e48f460c..a20e1e4212e 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.7.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.7.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 7 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the enumEntry. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 7 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the enumEntry. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ enum class A(x1: Any?) { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.8.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.8.kt index b5e4f90da8f..8272718e802 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.8.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.8.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 8 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the stringTemplateElement. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 8 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the stringTemplateElement. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.9.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.9.kt index d7601fd1fa3..67cbaa76bc1 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.9.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/neg/2.9.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 9 - DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the unescapedAnnotation. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 9 + * DESCRIPTION: The use of Boolean literals as the identifier (without backtick) in the unescapedAnnotation. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt index b14c5eb38bc..149080475be 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 1 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 1 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class `true` {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt index 926ac7bb42c..44aaa5ba2ae 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.10.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 10 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the companionObject. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 10 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the companionObject. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt index 7fb3af32d75..ebf87832a0e 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.11.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 11 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the function. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 11 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the function. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun `true`() {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt index 81a93a7338a..9d5383dc6e0 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.12.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 12 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the setter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 12 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the setter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt index 096fd4ade1c..f32f92fc714 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.13.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 13 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the simpleUserType. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 13 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the simpleUserType. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1(a: `true`) {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt index 52784c0da7b..f76e4d7a30a 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.14.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 14 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeParameter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 14 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeParameter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun <`true`> f1() {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt index f9a999dffd6..4f8f27746a3 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.15.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 15 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the parameter. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 15 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the parameter. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1(`true`: Int) {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt index fe1a054ade5..50388d19749 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.16.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 16 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationComplex. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 16 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationComplex. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @file:[JvmName.`true`<`false`>()] diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt index 4f5528661d5..2930bed4176 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.17.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 17 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the object. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 17 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the object. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ object A : `true` {} diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt index ece301506c2..6313834f84c 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.18.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 18 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeAlias. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 18 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeAlias. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ typealias `true` = Boolean diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt index 2733220fcd7..1724505804b 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.19.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 19 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the import. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 19 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the import. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ import org.jetbrains.`true`.* diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt index fd5533690a7..3ef73946cad 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.2.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 2 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelReference. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 2 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelReference. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt index 94816d161d1..955e8c6c7fb 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.20.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 20 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the infixFunctionCall. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 20 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the infixFunctionCall. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt index c6fa2da398d..2590366cd93 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.21.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 21 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the catchBlock. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 21 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the catchBlock. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt index f517d2b63a8..da273490bfa 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.22.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 22 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelDefinition. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 22 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelDefinition. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt index 4a2bf99d3ff..4993c12bd5c 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.23.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 23 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the atomicExpression. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 23 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the atomicExpression. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ val `true` = 10 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt index bb2d5004d5c..cbf7e11bf1f 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.24.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 24 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the variableDeclarationEntry. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 24 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the variableDeclarationEntry. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt index 0584faff89c..98561d0e856 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.25.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 25 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the valueArgument. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 25 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the valueArgument. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt index cb6e3cc48bf..274633cf294 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.26.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 26 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the callableReference. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 26 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the callableReference. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun case_1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt index 449abac53fb..4789ecf5978 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.3.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 3 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeConstraint. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 3 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeConstraint. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A <`true`, `false`> diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt index 4dac03f773e..6c57466310e 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.4.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 4 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationSimple. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 4 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationSimple. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ @file:`true` diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt index 3252d7994d7..46fc6cb9600 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.5.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 5 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageComplex. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 5 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageComplex. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package org.jetbrains.`true` diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt index f87db622a3a..ef51e3f7729 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.6.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 6 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageSimple. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 6 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageSimple. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ package `true` diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt index a91ee870eed..632446f757b 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.7.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 7 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the enumEntry. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 7 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the enumEntry. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ enum class A(x1: Any?) { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt index 2c951106dd0..b0f04ed3b58 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.8.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 8 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the stringTemplateElement. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 8 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the stringTemplateElement. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ fun f1() { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt index 4cc3c6bb923..8516c9344b1 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.9.kt @@ -1,12 +1,12 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, boolean-literals - PARAGRAPH: 1 - SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. - NUMBER: 9 - DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the unescapedAnnotation. - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. + * NUMBER: 9 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the unescapedAnnotation. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ class A { diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt index 4271ed4d2ba..aed367f0c01 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 1 - DESCRIPTION: Binary integer literals with invalid or double prefixes. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 1 + * DESCRIPTION: Binary integer literals with invalid or double prefixes. */ val value = 00b000111001 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.2.kt index 1daad0cea7a..a2172c85c50 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 2 - DESCRIPTION: Binary integer literals with not allowed symbols. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 2 + * DESCRIPTION: Binary integer literals with not allowed symbols. */ val value = 0b101L001 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt index 05ca6131ebf..e5d2d410c48 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/neg/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 1 - DESCRIPTION: Binary integer literals with underscore breaking the prefix (in it). + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 1 + * DESCRIPTION: Binary integer literals with underscore breaking the prefix (in it). */ val value = 0_b1_1_0_1_0_1 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt index f6f43322755..4f1b3e574d9 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 1 - DESCRIPTION: Binary integer literals with valid digit symbols. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 1 + * DESCRIPTION: Binary integer literals with valid digit symbols. */ val value = 0b0000111110000 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.2.kt index bb16ad2fb1c..d83f6cf56e1 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 2 - DESCRIPTION: Binary integer literals with invalid [2-9] digit symbols. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 2 + * DESCRIPTION: Binary integer literals with invalid [2-9] digit symbols. */ val value = 0B000123412 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.3.kt index ca6334ecc68..b514ed19bc8 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/1.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. - NUMBER: 3 - DESCRIPTION: Binary integer literals with prefix only (without digit symbols). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. + * NUMBER: 3 + * DESCRIPTION: Binary integer literals with prefix only (without digit symbols). */ val value = 0b diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt index fc9c706b6b3..9431dadac08 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Binary integer literals with underscore symbols in the valid positions. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Binary integer literals with underscore symbols in valid places. */ val value = 0b0_00_01_11_11_00_00 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.2.kt index 67de81185c1..5b733ba3b86 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 2 - DESCRIPTION: Binary integer literals with underscore symbols after binary prefix. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 2 + * DESCRIPTION: Binary integer literals with underscore symbols after binary prefix. */ val value = 0b_000111010001111 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.3.kt index 5456ca870e8..5a8b059931d 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 3 - DESCRIPTION: Binary integer literals with underscore symbol after the last digit. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 3 + * DESCRIPTION: Binary integer literals with underscore symbol after the last digit. */ val value = 0b0_1_0_1_0_1_____ diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.4.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.4.kt index 4351813e346..951fb68c376 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.4.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/binary-integer-literals/p-1/pos/2.4.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, binary-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 4 - DESCRIPTION: Binary integer literals with underscore symbol before the first digit (it's considered as identifiers). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, binary-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 4 + * DESCRIPTION: Binary integer literals with underscore symbol before the first digit (it's considered as identifiers). */ val value = _____0b0_1_0_1_0_0 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/1.1.kt index 593b246aac8..f6b29060181 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/neg/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with not all decimal digit symbols + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with not all decimal digit symbols */ val value = 1234567890b diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt index dca9fe53427..79c63c3144a 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. - NUMBER: 1 - DESCRIPTION: Sequences with decimal digit symbols. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Sequences with decimal digit symbols. */ val value = 1234567890 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt index 86ef2f8c2a7..2ad4c4220d3 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Integers with underscore symbols in the valid positions. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Integers with underscore symbols in the valid places. */ val value = 1234_5678_90 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.2.kt index f46d2e8e386..038726e07cb 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 2 - DESCRIPTION: Integers with underscore symbol in the last position. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 2 + * DESCRIPTION: Integers with underscore symbol in the last position. */ val value = 1_ diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.3.kt index f95bb9653cc..7270181d41d 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-1/pos/2.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 3 - DESCRIPTION: Integers with underscore symbols before the first digit (it's considered as identifiers). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 3 + * DESCRIPTION: Integers with underscore symbols before the first digit (it's considered as identifiers). */ val value = _5678_90 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.1.kt index a47f4400b53..e423c08b5d1 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 2 - SENTENCE: [1] Even more so, any decimal literal starting with digit 0 and containing more than 1 digit is not a valid decimal literal. - NUMBER: 1 - DESCRIPTION: Integer literals with 0 in the first position and it contains more than 1 digit. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 2 + * SENTENCE: [1] Even more so, any decimal literal starting with digit 0 and containing more than 1 digit is not a valid decimal literal. + * NUMBER: 1 + * DESCRIPTION: Integer literals with 0 in the first position and it contains more than 1 digit. */ val value = 00 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.2.kt index 718ec2bdf93..80719d4955f 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/decimal-integer-literals/p-2/neg/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, decimal-integer-literals - PARAGRAPH: 2 - SENTENCE: [1] Even more so, any decimal literal starting with digit 0 and containing more than 1 digit is not a valid decimal literal. - NUMBER: 2 - DESCRIPTION: Integer literals with 0 in the first position and it contains more than 1 digit separated by underscore. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, decimal-integer-literals + * PARAGRAPH: 2 + * SENTENCE: [1] Even more so, any decimal literal starting with digit 0 and containing more than 1 digit is not a valid decimal literal. + * NUMBER: 2 + * DESCRIPTION: Integer literals with 0 in the first position and it contains more than 1 digit separated by underscore. */ val value = 0_0 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt index 94be6ab4f69..8eaba3d111e 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. - NUMBER: 1 - DESCRIPTION: Hexadecimal integer literals with invalid or double prefixes. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Hexadecimal integer literals with invalid or double prefixes. */ val value = 00x876543 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.2.kt index e0830492102..5dcbad4f939 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. - NUMBER: 2 - DESCRIPTION: Hexadecimal integer literals with not allowed symbols. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. + * NUMBER: 2 + * DESCRIPTION: Hexadecimal integer literals with not allowed symbols. */ val value = 0x876L543 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt index 375bd1d032b..0a86e75cf02 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/neg/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Hexadecimal integer literals with underscore breaking the prefix (in it). + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Hexadecimal integer literals with underscore breaking the prefix (in it). */ val value = 0_x3_4_5_6_7_8 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt index d0240f772a2..406424a9507 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. - NUMBER: 1 - DESCRIPTION: Hexadecimal integer literals with valid symbols. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. + * NUMBER: 1 + * DESCRIPTION: Hexadecimal integer literals with valid symbols. */ val value = 0x1234567890 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.2.kt index dc8fd496cf8..36bfa1358f9 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. - NUMBER: 2 - DESCRIPTION: Hexadecimal integer literals with prefix only (without digit symbols). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal. + * NUMBER: 2 + * DESCRIPTION: Hexadecimal integer literals with prefix only (without digit symbols). */ val value = 0x diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt index 66da3abe663..e98fd079b0b 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 1 - DESCRIPTION: Hexadecimal integer literals with underscore symbols in the valid positions. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 1 + * DESCRIPTION: Hexadecimal integer literals with underscore symbols in valid places. */ val value = 0x1_234C67890 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.2.kt index ff00e1dcac5..5d9aff086dc 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 2 - DESCRIPTION: Hexadecimal integer literals with underscore symbols after hexadecimal prefix. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 2 + * DESCRIPTION: Hexadecimal integer literals with underscore symbols after hexadecimal prefix. */ val value = 0x_a2b45f789e diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.3.kt index 2f5597caaa2..adf2c6d32df 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 3 - DESCRIPTION: Hexadecimal integer literals with underscore symbol after the last digit. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 3 + * DESCRIPTION: Hexadecimal integer literals with underscore symbol after the last digit. */ val value = 0x3_c_c_c_7_8_____ diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.4.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.4.kt index dffa1bbf086..5f7972f3790 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.4.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/hexadecimal-integer-literals/p-1/pos/2.4.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals - PARAGRAPH: 1 - SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. - NUMBER: 4 - DESCRIPTION: Hexadecimal integer literals with underscore symbol before the first digit (it's considered as identifiers). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one. + * NUMBER: 4 + * DESCRIPTION: Hexadecimal integer literals with underscore symbol before the first digit (it's considered as identifiers). */ val value = _____0x3_4_5_6_7_8 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt index 8d70f969001..be91c76ca9f 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 1 - DESCRIPTION: Various integer literals with a long literal mark doublicate. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 1 + * DESCRIPTION: Various integer literals with a long literal mark doublicate. */ val value = 1234567890lL diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt index f6616e3fb9b..bd2a2790b85 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 2 - DESCRIPTION: Various integer literals with a long literal mark in not allowed positions. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 2 + * DESCRIPTION: Various integer literals with a long literal mark in not allowed places. */ val value = 0x0123456L789abcdef diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt index 1a17bfe213f..5c276c01dca 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 3 - DESCRIPTION: Various integer literals with underscores after a long literal mark. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 3 + * DESCRIPTION: Various integer literals with underscores after a long literal mark. */ val value = 1000l___ diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.4.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.4.kt index 9a4d6c58736..98eeefffbf4 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.4.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/neg/1.4.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (NEGATIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 4 - DESCRIPTION: The long literal mark after not integer literals. + * KOTLIN PSI SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 4 + * DESCRIPTION: The long literal mark after not integer literals. */ val value = 'a'l diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt index 274c33350d2..862cb8810f2 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.1.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 1 - DESCRIPTION: Decimal integer literals suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 1 + * DESCRIPTION: Decimal integer literals suffixed by the long literal mark. */ val value = 1234567890L diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.10.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.10.kt index 47062e255e6..7bb2c7531e4 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.10.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.10.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 10 - DESCRIPTION: Long literal mark in not allowed positions (it's considered as identifiers). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 10 + * DESCRIPTION: Long literal mark in not allowed places (it's considered as identifiers). */ val value = l1234 diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt index fdc30450432..e6803ca156e 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.2.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 2 - DESCRIPTION: Decimal integer literals with underscores suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 2 + * DESCRIPTION: Decimal integer literals with underscores suffixed by the long literal mark. */ val value = 1234_5678_90L diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt index 7ef86ec0a02..3e35edc5121 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.3.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 3 - DESCRIPTION: Hexadecimal integer literals suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 3 + * DESCRIPTION: Hexadecimal integer literals suffixed by the long literal mark. */ val value = 0x1234567890L diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.4.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.4.kt index 6e9b7738b32..eadc364f67b 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.4.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.4.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 4 - DESCRIPTION: Hexadecimal prefix only suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 4 + * DESCRIPTION: Hexadecimal prefix only suffixed by the long literal mark. */ val value = 0xL diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.5.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.5.kt index 587ad70ee60..12383b37392 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.5.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.5.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 5 - DESCRIPTION: Hexadecimal integer literals with underscores suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 5 + * DESCRIPTION: Hexadecimal integer literals with underscores suffixed by the long literal mark. */ val value = 0x1_234C67890L diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.6.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.6.kt index cf912b10b23..fe6ce0c9b71 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.6.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.6.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 6 - DESCRIPTION: Binary integer literals suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 6 + * DESCRIPTION: Binary integer literals suffixed by the long literal mark. */ val value = 0b0000111110000L diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.7.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.7.kt index 6bbb199c6d7..1eab3df8119 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.7.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.7.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 7 - DESCRIPTION: Binary prefix only suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 7 + * DESCRIPTION: Binary prefix only suffixed by the long literal mark. */ val value = 0bL diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.8.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.8.kt index 1cd917c4858..174dcf8ae42 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.8.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.8.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 8 - DESCRIPTION: Binary integer literals with underscores suffixed by the long literal mark. + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 8 + * DESCRIPTION: Binary integer literals with underscores suffixed by the long literal mark. */ val value = 0b0_00_01_11_11_00_00L diff --git a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.9.kt b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.9.kt index 79672d8651e..75aa8e2b3d2 100644 --- a/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.9.kt +++ b/compiler/tests-spec/testData/psi/linked/constant-literals/integer-literals/long-integer-literals/p-1/pos/1.9.kt @@ -1,11 +1,11 @@ /* - KOTLIN PSI SPEC TEST (POSITIVE) - - SECTIONS: constant-literals, integer-literals, long-integer-literals - PARAGRAPH: 1 - SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). - NUMBER: 9 - DESCRIPTION: Various integer literals with long literal mark in not allowed lower case (but valid in opinion the parser). + * KOTLIN PSI SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, integer-literals, long-integer-literals + * PARAGRAPH: 1 + * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). + * NUMBER: 9 + * DESCRIPTION: Various integer literals with long literal mark in not allowed lower case (but valid in opinion the parser). */ val value = 1234567890l diff --git a/compiler/tests-spec/testData/psi/templates/_layout/linkedTestsLayout.kt b/compiler/tests-spec/testData/psi/templates/_layout/linkedTestsLayout.kt index f5b3e2f0b71..8a4b08b550b 100644 --- a/compiler/tests-spec/testData/psi/templates/_layout/linkedTestsLayout.kt +++ b/compiler/tests-spec/testData/psi/templates/_layout/linkedTestsLayout.kt @@ -1,10 +1,10 @@ /* - KOTLIN PSI SPEC TEST () - - SECTIONS: - PARAGRAPH: - SENTENCE: [] - NUMBER: - DESCRIPTION: - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN PSI SPEC TEST () + * + * SECTIONS: + * PARAGRAPH: + * SENTENCE: [] + * NUMBER: + * DESCRIPTION: + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ \ No newline at end of file diff --git a/compiler/tests-spec/testData/psi/templates/_layout/notLinkedTestsLayout.kt b/compiler/tests-spec/testData/psi/templates/_layout/notLinkedTestsLayout.kt index f235766b200..9e23176d2d0 100644 --- a/compiler/tests-spec/testData/psi/templates/_layout/notLinkedTestsLayout.kt +++ b/compiler/tests-spec/testData/psi/templates/_layout/notLinkedTestsLayout.kt @@ -1,9 +1,9 @@ /* - KOTLIN NOT LINKED PSI SPEC TEST () - - SECTION: - CATEGORIES: - NUMBER: - DESCRIPTION: - NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! + * KOTLIN NOT LINKED PSI SPEC TEST () + * + * SECTION: + * CATEGORIES: + * NUMBER: + * DESCRIPTION: + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! */ \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTestSpec.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTestSpec.kt index 2b85bd120f4..7928940bfbf 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTestSpec.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTestSpec.kt @@ -9,10 +9,16 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.spec.models.AbstractSpecTest +import org.jetbrains.kotlin.spec.SpecTestLinkedType +import org.jetbrains.kotlin.spec.parsers.CommonParser +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.ls import org.jetbrains.kotlin.spec.validators.* import org.jetbrains.kotlin.test.* +import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments import org.junit.Assert import java.io.File +import java.util.regex.Pattern abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() { companion object { @@ -35,18 +41,22 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() { private const val MODULE_PATH = "compiler/tests-spec" private const val DIAGNOSTICS_TESTDATA_PATH = "$MODULE_PATH/testData/diagnostics" private const val HELPERS_PATH = "$DIAGNOSTICS_TESTDATA_PATH/helpers" + private val exceptionPattern = + Pattern.compile("""Exception while analyzing expression at \((?\d+),(?\d+)\) in /(?.*?)$""") } - private lateinit var testValidator: AbstractSpecTestValidator + lateinit var specTest: AbstractSpecTest + lateinit var testLinkedType: SpecTestLinkedType + private var skipDescriptors = true private fun checkDirective(directive: String, testFiles: List) = testFiles.any { it.directives.contains(directive) } - private fun enableDescriptorsGenerationIfNeeded(testDataFile: File) { + private fun enableDescriptorsGenerationIfNeeded(testFilePath: String) { skipDescriptors = withoutDescriptorsTestGroups.any { val testGroupAbsolutePath = File("$DIAGNOSTICS_TESTDATA_PATH/$it").absolutePath - testDataFile.absolutePath.startsWith(testGroupAbsolutePath) + testFilePath.startsWith(testGroupAbsolutePath) } } @@ -70,19 +80,37 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() { } override fun analyzeAndCheck(testDataFile: File, files: List) { - enableDescriptorsGenerationIfNeeded(testDataFile) + val testFilePath = testDataFile.canonicalPath - testValidator = AbstractSpecTestValidator.getInstanceByType(testDataFile) + enableDescriptorsGenerationIfNeeded(testFilePath) - try { - testValidator.parseTestInfo() - } catch (e: SpecTestValidationException) { - Assert.fail(e.description) + CommonParser.parseSpecTest(testFilePath, files.associate { Pair(it.ktFile!!.name, it.clearText) }).apply { + specTest = first + testLinkedType = second } - testValidator.printTestInfo() + println(specTest) - super.analyzeAndCheck(testDataFile, files) + try { + super.analyzeAndCheck(testDataFile, files) + } catch (e: KotlinExceptionWithAttachments) { + val matches = exceptionPattern.matcher(e.message) + + if (!matches.find()) + Assert.fail(SpecTestValidationFailedReason.UNKNOWN_FRONTEND_EXCEPTION.description) + + val lineNumber = matches.group("lineNumber").toInt() + val symbolNumber = matches.group("symbolNumber").toInt() + val filename = matches.group("filename") + val fileContent = files.find { it.ktFile?.name == filename }!!.clearText + val exceptionPosition = + fileContent.lines().subList(0, lineNumber).joinToString("\n").length + symbolNumber + val testCases = specTest.cases.byRanges[filename] + val isExpectedException = testCases!!.floorEntry(exceptionPosition).value.all { it.value.unexpectedBehavior } + + if (!isExpectedException) + Assert.fail() + } } override fun performAdditionalChecksAfterDiagnostics( @@ -93,11 +121,16 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() { moduleBindings: Map, languageVersionSettingsByModule: Map ) { - if (testValidator.testInfo.unexpectedBehavior!!) return + val diagnosticValidator = try { + DiagnosticTestTypeValidator(testFiles, testDataFile, specTest) + } catch (e: SpecTestValidationException) { + Assert.fail(e.description) + return + } - val diagnosticValidator = DiagnosticTestTypeValidator(testFiles) try { - testValidator.validateTestType(computedTestType = diagnosticValidator.computeTestType()) + diagnosticValidator.validatePathConsistency(testLinkedType) + diagnosticValidator.validateTestType() } catch (e: SpecTestValidationException) { Assert.fail(e.description) } finally { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java index 8de922017c6..68a8dabd0e4 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java @@ -1226,6 +1226,11 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/13.kt"); } + @TestMetadata("14.kt") + public void test14() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/14.kt"); + } + @TestMetadata("15.kt") public void test15() throws Exception { runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/15.kt"); @@ -1450,6 +1455,11 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.kt"); } + @TestMetadata("19.kt") + public void test19() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/19.kt"); + } + @TestMetadata("2.kt") public void test2() throws Exception { runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.kt"); @@ -1513,16 +1523,6 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/2.kt"); } - @TestMetadata("3.kt") - public void test3() throws Exception { - runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/3.kt"); - } - - @TestMetadata("4.kt") - public void test4() throws Exception { - runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos/4.kt"); - } - public void testAllFilesPresentInPos() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @@ -1785,11 +1785,6 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/1.kt"); } - @TestMetadata("2.kt") - public void test2() throws Exception { - runTest("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos/2.kt"); - } - public void testAllFilesPresentInPos() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt index a7fcd918fe3..6b202b94ea4 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTestSpec.kt @@ -5,13 +5,12 @@ package org.jetbrains.kotlin.codegen +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.spec.parsers.CommonParser +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.packagePattern import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH -import java.io.File -import org.jetbrains.kotlin.spec.validators.AbstractSpecTestValidator -import org.jetbrains.kotlin.spec.validators.SpecTestValidationException import org.jetbrains.kotlin.test.InTextDirectivesUtils -import org.junit.Assert -import java.util.regex.Pattern +import java.io.File abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { companion object { @@ -24,15 +23,13 @@ abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { private val helperDirectives = mapOf( "REFLECT" to "reflect.kt" ) - private val packagePattern = - Pattern.compile("""(?:^|${AbstractSpecTestValidator.lineSeparator})package (?.*?)(?:;|${AbstractSpecTestValidator.lineSeparator})""") } private fun addPackageDirectiveToHelperFile(helperContent: String, packageName: String?) = helperContent.replace(HELPERS_PACKAGE_VARIABLE, if (packageName == null) "" else "package $packageName") private fun includeHelpers(wholeFile: File, files: MutableList) { - val fileContent = wholeFile.readText() + val fileContent = FileUtil.loadFile(wholeFile, true) val helpersSpecified = InTextDirectivesUtils.findListWithPrefixes(fileContent, HELPERS_DIRECTIVE) val packageName = packagePattern.matcher(fileContent).let { if (it.find()) it.group("packageName") else null @@ -40,7 +37,7 @@ abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { helpersSpecified.forEach { if (helperDirectives.contains(it)) { - val helperContent = File("$HELPERS_PATH/${helperDirectives[it]}").readText() + val helperContent = FileUtil.loadFile(File("$HELPERS_PATH/${helperDirectives[it]}"), true) files.add( TestFile(helperDirectives[it]!!, addPackageDirectiveToHelperFile(helperContent, packageName)) ) @@ -49,15 +46,12 @@ abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { } override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { - val testValidator = AbstractSpecTestValidator.getInstanceByType(wholeFile) + val (specTest, _) = CommonParser.parseSpecTest( + wholeFile.canonicalPath, + mapOf("main.kt" to FileUtil.loadFile(wholeFile, true)) + ) - try { - testValidator.parseTestInfo() - } catch (e: SpecTestValidationException) { - Assert.fail(e.description) - } - - testValidator.printTestInfo() + println(specTest) includeHelpers(wholeFile, files) diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/AbstractParsingTestSpec.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/AbstractParsingTestSpec.kt index 657e8d643b2..87f9d6ef0db 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/AbstractParsingTestSpec.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/AbstractParsingTestSpec.kt @@ -5,29 +5,28 @@ package org.jetbrains.kotlin.parsing +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.spec.parsers.CommonParser import org.jetbrains.kotlin.spec.validators.* import org.junit.Assert +import java.io.File abstract class AbstractParsingTestSpec : AbstractParsingTest() { - private lateinit var testValidator: AbstractSpecTestValidator - override fun doParsingTest(filePath: String) { - testValidator = AbstractSpecTestValidator.getInstanceByType(filePath) + val (specTest, testLinkedType) = CommonParser.parseSpecTest( + filePath, + mapOf("main.kt" to FileUtil.loadFile(File(filePath), true)) + ) + + println(specTest) + + super.doParsingTest(filePath, CommonParser::testInfoFilter) + + val psiTestValidator = ParsingTestTypeValidator(myFile, File(filePath), specTest) try { - testValidator.parseTestInfo() - } catch (e: SpecTestValidationException) { - Assert.fail(e.description) - } - - testValidator.printTestInfo() - - super.doParsingTest(filePath, testValidator::testInfoFilter) - - if (testValidator.testInfo.unexpectedBehavior!!) return - - try { - testValidator.validateTestType(computedTestType = ParsingTestTypeValidator.computeTestType(myFile)) + psiTestValidator.validatePathConsistency(testLinkedType) + psiTestValidator.validateTestType() } catch (e: SpecTestValidationException) { Assert.fail(e.description) } diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/ParsingTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/ParsingTestSpecGenerated.java index cbd43da4ff7..dc582e1c224 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/ParsingTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/parsing/ParsingTestSpecGenerated.java @@ -228,6 +228,16 @@ public class ParsingTestSpecGenerated extends AbstractParsingTestSpec { KotlinTestUtils.runTest(this::doParsingTest, TargetBackend.ANY, testDataFilePath); } + @TestMetadata("1.1.kt") + public void test1_1() throws Exception { + runTest("compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/1.1.kt"); + } + + @TestMetadata("1.2.kt") + public void test1_2() throws Exception { + runTest("compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/1.2.kt"); + } + @TestMetadata("2.1.kt") public void test2_1() throws Exception { runTest("compiler/tests-spec/testData/psi/linked/constant-literals/boolean-literals/p-1/pos/2.1.kt"); diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/Common.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/Common.kt new file mode 100644 index 00000000000..4d979d51d08 --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/Common.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec + +import org.jetbrains.kotlin.spec.models.LinkedSpecTestFileInfoElementType +import org.jetbrains.kotlin.spec.models.NotLinkedSpecTestFileInfoElementType +import org.jetbrains.kotlin.spec.parsers.BasePatterns +import org.jetbrains.kotlin.spec.parsers.LinkedSpecTestPatterns +import org.jetbrains.kotlin.spec.parsers.NotLinkedSpecTestPatterns +import org.jetbrains.kotlin.spec.parsers.CommonParser.withSpaces +import java.util.* +import java.util.regex.Matcher +import java.util.regex.Pattern + +typealias TestFiles = Map +typealias TestCasesByNumbers = MutableMap +typealias TestCasesByFiles = MutableMap +typealias TestCasesByRanges = MutableMap> + +enum class TestType(val type: String) { + POSITIVE("pos"), + NEGATIVE("neg"); + + companion object { + private val map = values().associateBy(TestType::type) + val joinedValues = values().joinToString("|").withSpaces() + + fun fromValue(type: String) = map[type] + } +} + +enum class TestArea(val testDataPath: String) { + PSI("psi"), + DIAGNOSTICS("diagnostics"), + CODEGEN_BOX("codegen/box"); + + companion object { + val joinedValues = values().joinToString("|").withSpaces() + } +} + +enum class SpecTestLinkedType( + val testDataPath: String, + val patterns: Lazy, + val infoElements: Lazy> +) { + LINKED( + "linked", + lazy { LinkedSpecTestPatterns }, + lazy { LinkedSpecTestFileInfoElementType.values() } + ), + NOT_LINKED( + "notLinked", + lazy { NotLinkedSpecTestPatterns }, + lazy { NotLinkedSpecTestFileInfoElementType.values() } + ) +} + +interface SpecTestInfoElementType { + val valuePattern: Pattern? + val required: Boolean +} + +data class SpecTestInfoElementContent( + val content: String, + val additionalMatcher: Matcher? = null +) + +data class SpecTestCase( + var code: String, + var ranges: MutableList, + var unexpectedBehavior: Boolean, + val issues: MutableList? +) + +data class SpecTestCasesSet( + val byFiles: TestCasesByFiles, + val byRanges: TestCasesByRanges, + val byNumbers: TestCasesByNumbers +) \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/Feature.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/Feature.kt similarity index 93% rename from compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/Feature.kt rename to compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/Feature.kt index 973096b330a..549a6f3c73b 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/Feature.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/Feature.kt @@ -3,7 +3,7 @@ * that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.spec.generators.featureinteraction +package org.jetbrains.kotlin.spec.generators.templates enum class Feature(val config: FeatureTemplatesConfig) { IDENTIFIERS( diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/FeatureInteractionTestDataGenerator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/FeatureInteractionTestDataGenerator.kt similarity index 98% rename from compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/FeatureInteractionTestDataGenerator.kt rename to compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/FeatureInteractionTestDataGenerator.kt index 3f8781a9b5d..6061d39c47b 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/FeatureInteractionTestDataGenerator.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/FeatureInteractionTestDataGenerator.kt @@ -3,7 +3,7 @@ * that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.spec.generators.featureinteraction +package org.jetbrains.kotlin.spec.generators.templates import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH import java.io.File diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/FeatureTemplatesConfig.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/FeatureTemplatesConfig.kt similarity index 93% rename from compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/FeatureTemplatesConfig.kt rename to compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/FeatureTemplatesConfig.kt index cfd4734bc46..f1c3262434c 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/FeatureTemplatesConfig.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/FeatureTemplatesConfig.kt @@ -3,10 +3,10 @@ * that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.spec.generators.featureinteraction +package org.jetbrains.kotlin.spec.generators.templates +import org.jetbrains.kotlin.spec.TestArea import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH -import org.jetbrains.kotlin.spec.validators.TestArea import java.io.File enum class FeatureTemplatesType { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/GenerationConfig.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/GenerationConfig.kt similarity index 95% rename from compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/GenerationConfig.kt rename to compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/GenerationConfig.kt index 5f2462ac0a0..2458ddea9ed 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/GenerationConfig.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/GenerationConfig.kt @@ -3,11 +3,11 @@ * that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.spec.generators.featureinteraction +package org.jetbrains.kotlin.spec.generators.templates -import org.jetbrains.kotlin.spec.validators.SpecTestLinkedType -import org.jetbrains.kotlin.spec.validators.TestArea -import org.jetbrains.kotlin.spec.validators.TestType +import org.jetbrains.kotlin.spec.SpecTestLinkedType +import org.jetbrains.kotlin.spec.TestArea +import org.jetbrains.kotlin.spec.TestType enum class SubstitutionTag(val passType: SubstitutionPassType = SubstitutionPassType.FIRST) { DIRECTIVES, diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/GenerationUtils.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/GenerationUtils.kt similarity index 92% rename from compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/GenerationUtils.kt rename to compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/GenerationUtils.kt index 981bf90097d..75c2e5c4466 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/GenerationUtils.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/GenerationUtils.kt @@ -3,7 +3,7 @@ * that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.spec.generators.featureinteraction +package org.jetbrains.kotlin.spec.generators.templates import org.jetbrains.kotlin.spec.tasks.generateTests diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/TemplateSubstitutionTransformers.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/TemplateSubstitutionTransformers.kt similarity index 86% rename from compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/TemplateSubstitutionTransformers.kt rename to compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/TemplateSubstitutionTransformers.kt index 6ffe3086f39..8e0106c4eed 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/featureinteraction/TemplateSubstitutionTransformers.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/generators/templates/TemplateSubstitutionTransformers.kt @@ -3,7 +3,7 @@ * that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.spec.generators.featureinteraction +package org.jetbrains.kotlin.spec.generators.templates enum class TemplateValidationTransformerType { TRIM_BACKTICKS diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/AbstractSpecTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/AbstractSpecTest.kt new file mode 100644 index 00000000000..5938d92b6f2 --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/AbstractSpecTest.kt @@ -0,0 +1,79 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.models + +import org.jetbrains.kotlin.spec.* +import org.jetbrains.kotlin.spec.parsers.CommonPatterns +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.issuesPattern +import org.jetbrains.kotlin.spec.parsers.TestCasePatterns.testCaseNumberPattern +import java.util.regex.Matcher +import java.util.regex.Pattern + +typealias SpecTestInfoElements = Map + +enum class CommonInfoElementType( + override val valuePattern: Pattern? = null, + override val required: Boolean = false +) : SpecTestInfoElementType { + UNEXPECTED_BEHAVIOUR, + ISSUES(valuePattern = issuesPattern), + DISCUSSION, + NOTE +} + +enum class CommonSpecTestFileInfoElementType( + override val valuePattern: Pattern? = null, + override val required: Boolean = false +) : SpecTestInfoElementType { + SECTIONS(valuePattern = CommonPatterns.sectionsInFilePattern, required = true), + NUMBER(required = true), + DESCRIPTION(required = true) +} + +enum class SpecTestCaseInfoElementType( + override val valuePattern: Pattern? = null, + override val required: Boolean = false +) : SpecTestInfoElementType { + TESTCASE_NUMBER(valuePattern = testCaseNumberPattern, required = true) +} + +abstract class AbstractSpecTest( + val testArea: TestArea, + val testType: TestType, + val sections: List, + val testNumber: Int, + val description: String, + val cases: SpecTestCasesSet, + val unexpectedBehavior: Boolean, + val issues: Set +) { + companion object { + private fun issuesToString(issues: Set) = issues.joinToString(", ") { CommonPatterns.ISSUE_TRACKER + it } + } + + abstract fun checkPathConsistency(pathMatcher: Matcher): Boolean + + protected fun getIssuesText(): String? { + val testCaseIssues = cases.byNumbers.flatMap { it.value.issues!! } + + return if (issues.isNotEmpty() || testCaseIssues.isNotEmpty()) { + "LINKED ISSUES: ${issuesToString(issues + testCaseIssues)}" + } else null + } + + protected fun getUnexpectedBehaviourText(): String? { + val separatedTestCasesUnexpectedBehaviorNumber = cases.byNumbers.count { it.value.unexpectedBehavior } + val testCasesUnexpectedBehaviorNumber = when { + unexpectedBehavior -> cases.byNumbers.size + separatedTestCasesUnexpectedBehaviorNumber != 0 -> separatedTestCasesUnexpectedBehaviorNumber + else -> 0 + } + + return if (testCasesUnexpectedBehaviorNumber != 0) { + "!!! HAS UNEXPECTED BEHAVIOUR (in $testCasesUnexpectedBehaviorNumber cases) !!!" + } else null + } +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/LinkedSpecTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/LinkedSpecTest.kt new file mode 100644 index 00000000000..acf0d4d28be --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/LinkedSpecTest.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.models + +import org.jetbrains.kotlin.spec.SpecTestCasesSet +import org.jetbrains.kotlin.spec.SpecTestInfoElementType +import org.jetbrains.kotlin.spec.TestArea +import org.jetbrains.kotlin.spec.TestType +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.ls +import org.jetbrains.kotlin.spec.parsers.CommonParser.withUnderscores +import org.jetbrains.kotlin.spec.parsers.CommonParser.splitByPathSeparator +import org.jetbrains.kotlin.spec.parsers.CommonParser.withSpaces +import org.jetbrains.kotlin.spec.parsers.LinkedSpecTestPatterns.sentencePattern +import java.util.regex.Matcher +import java.util.regex.Pattern + +enum class LinkedSpecTestFileInfoElementType( + override val valuePattern: Pattern? = null, + override val required: Boolean = false +) : SpecTestInfoElementType { + PARAGRAPH(required = true), + SENTENCE(valuePattern = sentencePattern, required = true) +} + +class LinkedSpecTest( + testArea: TestArea, + testType: TestType, + sections: List, + val paragraphNumber: Int, + val sentenceNumber: Int, + private val sentence: String, + testNumber: Int, + description: String, + cases: SpecTestCasesSet, + unexpectedBehavior: Boolean, + issues: Set +) : AbstractSpecTest(testArea, testType, sections, testNumber, description, cases, unexpectedBehavior, issues) { + override fun checkPathConsistency(pathMatcher: Matcher) = + testArea == TestArea.valueOf(pathMatcher.group("testArea").withUnderscores()) + && testType == TestType.fromValue(pathMatcher.group("testType"))!! + && sections == pathMatcher.group("sections").splitByPathSeparator() + && paragraphNumber == pathMatcher.group("paragraphNumber").toInt() + && sentenceNumber == pathMatcher.group("sentenceNumber").toInt() + && testNumber == pathMatcher.group("testNumber").toInt() + + override fun toString() = buildString { + append("--------------------------------------------------$ls") + super.getUnexpectedBehaviourText()?.let { append(it + ls) } + append("${testArea.name.withSpaces()} $testType SPEC TEST (${testType.toString().withSpaces()})$ls") + append("SECTIONS: ${sections.joinToString()} (paragraph: $paragraphNumber)$ls") + append("SENTENCE $sentenceNumber: $sentence$ls") + append("NUMBER: $testNumber$ls") + append("TEST CASES: ${cases.byNumbers.size.coerceAtLeast(1)}$ls") + append("DESCRIPTION: $description$ls") + super.getIssuesText()?.let { append(it + ls) } + } +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/NotLinkedSpecTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/NotLinkedSpecTest.kt new file mode 100644 index 00000000000..98a70a465fe --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/models/NotLinkedSpecTest.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.models + +import org.jetbrains.kotlin.spec.SpecTestCasesSet +import org.jetbrains.kotlin.spec.SpecTestInfoElementType +import org.jetbrains.kotlin.spec.TestArea +import org.jetbrains.kotlin.spec.TestType +import org.jetbrains.kotlin.spec.parsers.CommonParser.splitByPathSeparator +import org.jetbrains.kotlin.spec.parsers.CommonParser.withUnderscores +import org.jetbrains.kotlin.spec.parsers.CommonParser.withSpaces +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.ls +import java.util.regex.Matcher +import java.util.regex.Pattern + +enum class NotLinkedSpecTestFileInfoElementType( + override val valuePattern: Pattern? = null, + override val required: Boolean = false +) : SpecTestInfoElementType + +class NotLinkedSpecTest( + testArea: TestArea, + testType: TestType, + sections: List, + testNumber: Int, + description: String, + cases: SpecTestCasesSet, + unexpectedBehavior: Boolean, + issues: Set +) : AbstractSpecTest(testArea, testType, sections, testNumber, description, cases, unexpectedBehavior, issues) { + override fun checkPathConsistency(pathMatcher: Matcher) = + testArea == TestArea.valueOf(pathMatcher.group("testArea").withUnderscores()) + && testType == TestType.fromValue(pathMatcher.group("testType"))!! + && sections == pathMatcher.group("sections").splitByPathSeparator() + && testNumber == pathMatcher.group("testNumber").toInt() + + override fun toString() = buildString { + append("--------------------------------------------------$ls") + super.getUnexpectedBehaviourText()?.let { append(it + ls) } + append("${testArea.name.withSpaces()} $testType SPEC TEST (${testType.type.withSpaces()})$ls") + append("SECTIONS: ${sections.joinToString()}$ls") + append("NUMBER: $testNumber$ls") + append("TEST CASES: ${cases.byNumbers.size.coerceAtLeast(1)}$ls") + append("DESCRIPTION: $description$ls") + super.getIssuesText()?.let { append(it + ls) } + } +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/CommonParser.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/CommonParser.kt new file mode 100644 index 00000000000..b48352615b7 --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/CommonParser.kt @@ -0,0 +1,121 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.parsers + +import org.jetbrains.kotlin.spec.* +import org.jetbrains.kotlin.spec.SpecTestInfoElementContent +import org.jetbrains.kotlin.spec.SpecTestLinkedType +import org.jetbrains.kotlin.spec.models.LinkedSpecTest +import org.jetbrains.kotlin.spec.models.LinkedSpecTestFileInfoElementType +import org.jetbrains.kotlin.spec.models.NotLinkedSpecTest +import org.jetbrains.kotlin.spec.models.SpecTestInfoElements +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.testInfoElementPattern +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.testPathBaseRegexTemplate +import org.jetbrains.kotlin.spec.parsers.LinkedSpecTestPatterns.testInfoPattern +import org.jetbrains.kotlin.spec.parsers.TestCasePatterns.testCaseInfoPattern +import org.jetbrains.kotlin.spec.validators.* +import java.io.File +import java.util.regex.Pattern + +object CommonParser { + fun String.withUnderscores() = replace(" ", "_").toUpperCase() + fun String.splitByComma() = split(Regex(""",\s*""")) + fun String.splitByPathSeparator() = split(File.separator) + fun String.withSpaces() = replace("_", " ") + + private fun isPathMatched(pathPartRegex: String, testFilePath: String) = + Pattern.compile(testPathBaseRegexTemplate.format(pathPartRegex)).matcher(testFilePath).find() + + fun parseSpecTest(testFilePath: String, files: TestFiles) = when { + isPathMatched(LinkedSpecTestPatterns.pathPartRegex, testFilePath) -> + Pair(parseLinkedSpecTest(testFilePath, files), SpecTestLinkedType.LINKED) + isPathMatched(NotLinkedSpecTestPatterns.pathPartRegex, testFilePath) -> + Pair(parseNotLinkedSpecTest(testFilePath, files), SpecTestLinkedType.NOT_LINKED) + else -> + throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID) + } + + private fun parseLinkedSpecTest(testFilePath: String, testFiles: TestFiles): LinkedSpecTest { + val parsedTestFile = parseTestInfo(testFilePath, testFiles, SpecTestLinkedType.LINKED) + val testInfoElements = parsedTestFile.testInfoElements + val sentenceMatcher = testInfoElements[LinkedSpecTestFileInfoElementType.SENTENCE]!!.additionalMatcher!! + + return LinkedSpecTest( + parsedTestFile.testArea, + parsedTestFile.testType, + parsedTestFile.sections, + testInfoElements[LinkedSpecTestFileInfoElementType.PARAGRAPH]!!.content.toInt(), + sentenceMatcher.group("number").toInt(), + sentenceMatcher.group("text"), + parsedTestFile.testNumber, + parsedTestFile.testDescription, + parsedTestFile.testCasesSet, + parsedTestFile.unexpectedBehavior, + parsedTestFile.issues + ) + } + + private fun parseNotLinkedSpecTest(testFilePath: String, testFiles: TestFiles): NotLinkedSpecTest { + val parsedTestFile = parseTestInfo(testFilePath, testFiles, SpecTestLinkedType.NOT_LINKED) + + return NotLinkedSpecTest( + parsedTestFile.testArea, + parsedTestFile.testType, + parsedTestFile.sections, + parsedTestFile.testNumber, + parsedTestFile.testDescription, + parsedTestFile.testCasesSet, + parsedTestFile.unexpectedBehavior, + parsedTestFile.issues + ) + } + + fun parseIssues(issues: SpecTestInfoElementContent?) = issues?.content?.splitByComma()?.toSet().orEmpty() + + fun parseTestInfoElements(rules: Array, rawElements: String): + SpecTestInfoElements { + val testInfoElementsMap = mutableMapOf() + val testInfoElementMatcher = testInfoElementPattern.matcher(rawElements) + + while (testInfoElementMatcher.find()) { + val testInfoOriginalElementName = testInfoElementMatcher.group("name") + val testInfoElementName = rules.find { + it as Enum<*> + it.name == testInfoOriginalElementName.withUnderscores() + } ?: throw SpecTestValidationException( + SpecTestValidationFailedReason.TESTINFO_NOT_VALID, + "Unknown '$testInfoOriginalElementName' test info element name." + ) + val testInfoElementValue = testInfoElementMatcher.group("value") + val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue) + + if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find()) + throw SpecTestValidationException( + SpecTestValidationFailedReason.TESTINFO_NOT_VALID, + "'$testInfoElementValue' in '$testInfoElementName' is not parsed." + ) + + testInfoElementsMap[testInfoElementName] = + SpecTestInfoElementContent(testInfoElementValue ?: "", testInfoElementValueMatcher) + } + + rules.forEach { + if (it.required && !testInfoElementsMap.contains(it)) { + throw SpecTestValidationException( + SpecTestValidationFailedReason.TESTINFO_NOT_VALID, + "$it in case or test info is required." + ) + } + } + + return testInfoElementsMap + } + + fun testInfoFilter(fileContent: String) = + testInfoPattern.matcher(fileContent).replaceAll("").let { + testCaseInfoPattern.matcher(it).replaceAll("") + } +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/Patterns.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/Patterns.kt new file mode 100644 index 00000000000..1e89fb53bee --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/Patterns.kt @@ -0,0 +1,94 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.parsers + +import org.jetbrains.kotlin.spec.models.SpecTestCaseInfoElementType +import org.jetbrains.kotlin.spec.SpecTestLinkedType +import org.jetbrains.kotlin.spec.TestArea +import org.jetbrains.kotlin.spec.TestType +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.INTEGER_REGEX +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.SINGLE_LINE_COMMENT_REGEX +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.ASTERISK_REGEX +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.directiveRegex +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.multilineCommentRegex +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.ps +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.testAreaRegex +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.testPathRegexTemplate +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.testTypeRegex +import org.jetbrains.kotlin.spec.parsers.CommonParser.withSpaces +import org.jetbrains.kotlin.spec.parsers.CommonPatterns.sectionsInPathRegex +import java.io.File +import java.util.regex.Pattern + +object CommonPatterns { + const val ISSUE_TRACKER = "https://youtrack.jetbrains.com/issue/" + const val INTEGER_REGEX = """[1-9]\d*""" + const val SINGLE_LINE_COMMENT_REGEX = """\/\/\s*%s""" + const val ASTERISK_REGEX = """\*""" + + val ls: String = System.lineSeparator() + val ps: String = Pattern.quote(File.separator) + + val multilineCommentRegex = """\/\*\s+?%s\s+\*\/(?:\n)*""" + val directiveRegex = + """${SINGLE_LINE_COMMENT_REGEX.format("""[\w\s]+:""")}|${multilineCommentRegex.format(""" $ASTERISK_REGEX [\w\s]+:[\s\S]*?""")}""" + val testAreaRegex = """(?${TestArea.joinedValues})""" + val testTypeRegex = """(?${TestType.joinedValues})""" + val testInfoElementPattern: Pattern = Pattern.compile("""(?: \* )?(?[A-Z ]+?)(?::\s*(?.*?))?\n""") + val testPathBaseRegexTemplate = """^.*?$ps(?diagnostics|psi|(?:codegen${ps}box))$ps%s""" + val testPathRegexTemplate = """$testPathBaseRegexTemplate$ps(?pos|neg)$ps%s$""" + val issuesPattern: Pattern = Pattern.compile("""(KT-[1-9]\d*)(,\s*KT-[1-9]\d*)*""") + val sectionsInFilePattern: Pattern = Pattern.compile("""\w+(,\s+\w+)*""") + val sectionsInPathRegex = """(?(?:[\w-]+)(?:$ps[\w-]+)*?)""" + val packagePattern: Pattern = Pattern.compile("""(?:^|\n)package (?.*?)(?:;|\ns)""") +} + +interface BasePatterns { + val pathPartRegex: String + val testPathPattern: Pattern + val testInfoPattern: Pattern +} + +object NotLinkedSpecTestPatterns : BasePatterns { + private const val FILENAME_REGEX = """(?$INTEGER_REGEX)\.kt""" + + override val pathPartRegex = SpecTestLinkedType.NOT_LINKED.testDataPath + ps + sectionsInPathRegex + override val testPathPattern: Pattern = + Pattern.compile(testPathRegexTemplate.format(pathPartRegex, FILENAME_REGEX)) + override val testInfoPattern: Pattern = + Pattern.compile(multilineCommentRegex.format(""" $ASTERISK_REGEX KOTLIN $testAreaRegex NOT LINKED SPEC TEST \($testTypeRegex\)\n(?[\s\S]*?\n)""")) +} + +object LinkedSpecTestPatterns : BasePatterns { + private const val FILENAME_REGEX = """(?$INTEGER_REGEX)\.(?$INTEGER_REGEX)\.kt""" + + override val pathPartRegex = + """${SpecTestLinkedType.LINKED.testDataPath}$ps$sectionsInPathRegex${ps}p-(?$INTEGER_REGEX)""" + override val testPathPattern: Pattern = + Pattern.compile(testPathRegexTemplate.format(pathPartRegex, FILENAME_REGEX)) + override val testInfoPattern: Pattern = + Pattern.compile(multilineCommentRegex.format(""" $ASTERISK_REGEX KOTLIN $testAreaRegex SPEC TEST \($testTypeRegex\)\n(?[\s\S]*?\n)""")) + + val sentencePattern: Pattern = Pattern.compile("""^\[(?$INTEGER_REGEX)\]\s*(?.*?)$""") +} + +object TestCasePatterns { + private const val TEST_CASE_CODE_REGEX = """(?<%s>[\s\S]*?)""" + + private val testCaseInfoElementsRegex = """(?<%s>%s${SpecTestCaseInfoElementType.TESTCASE_NUMBER.name.withSpaces()}:%s*?\n)""" + private val testCaseInfoRegex = """$TEST_CASE_CODE_REGEX(?<%s>(?:$directiveRegex)|$)""" + private val testCaseInfoSingleLineRegex = + SINGLE_LINE_COMMENT_REGEX.format( + testCaseInfoElementsRegex.format("infoElementsSL", "", """\s*.""") + ) + testCaseInfoRegex.format("codeSL", "nextDirectiveSL") + private val testCaseInfoMultilineRegex = + multilineCommentRegex.format( + testCaseInfoElementsRegex.format("infoElementsML", """ $ASTERISK_REGEX """, """[\s\S]""") + ) + testCaseInfoRegex.format("codeML", "nextDirectiveML") + + val testCaseInfoPattern: Pattern = Pattern.compile("(?:$testCaseInfoSingleLineRegex)|(?:$testCaseInfoMultilineRegex)") + val testCaseNumberPattern: Pattern = Pattern.compile("""([1-9]\d*)(,\s*[1-9]\d*)*""") +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestCasesParser.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestCasesParser.kt new file mode 100644 index 00000000000..59b1e213346 --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestCasesParser.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.parsers + +import org.jetbrains.kotlin.spec.* +import org.jetbrains.kotlin.spec.models.CommonInfoElementType +import org.jetbrains.kotlin.spec.models.SpecTestCaseInfoElementType +import org.jetbrains.kotlin.spec.models.SpecTestInfoElements +import org.jetbrains.kotlin.spec.parsers.CommonParser.splitByComma +import org.jetbrains.kotlin.spec.parsers.TestCasePatterns.testCaseInfoPattern +import java.util.* + +private operator fun SpecTestCase.plusAssign(addTestCase: SpecTestCase) { + this.code += addTestCase.code + this.unexpectedBehavior = this.unexpectedBehavior or addTestCase.unexpectedBehavior + this.issues?.addAll(addTestCase.issues!!) + this.ranges.addAll(addTestCase.ranges) +} + +private fun SpecTestCase.save( + testCasesByNumbers: TestCasesByNumbers, + testCasesOfFile: TestCasesByNumbers, + testCasesByRangesOfFile: NavigableMap, + caseInfoElements: SpecTestInfoElements +) { + val testCaseNumbers = + caseInfoElements[SpecTestCaseInfoElementType.TESTCASE_NUMBER]!!.content.splitByComma().map { it.trim().toInt() } + val startPosition = this.ranges[0].first + + testCaseNumbers.forEach { testCaseNumber -> + if (testCasesOfFile[testCaseNumber] != null) { + testCasesOfFile[testCaseNumber]!! += this + testCasesByNumbers[testCaseNumber]!! += this + } else { + testCasesOfFile[testCaseNumber] = this + testCasesByNumbers[testCaseNumber] = this + } + testCasesByRangesOfFile.putIfAbsent(startPosition, mutableMapOf()) + testCasesByRangesOfFile[startPosition]!![testCaseNumber] = this + } +} + +fun parseTestCases(testFiles: TestFiles): SpecTestCasesSet { + val testCasesSet = SpecTestCasesSet(mutableMapOf(), mutableMapOf(), mutableMapOf()) + var rangeOffset = 0 + + for ((filename, fileContent) in testFiles) { + val matcher = testCaseInfoPattern.matcher(fileContent) + var startFind = 0 + + if (!testCasesSet.byFiles.contains(filename)) { + testCasesSet.byFiles[filename] = mutableMapOf() + testCasesSet.byRanges[filename] = TreeMap() + } + + val testCasesOfFile = testCasesSet.byFiles[filename]!! + val testCasesByRangesOfFile = testCasesSet.byRanges[filename]!! + + while (matcher.find(startFind)) { + val caseInfoElements = CommonParser.parseTestInfoElements( + arrayOf(*CommonInfoElementType.values(), *SpecTestCaseInfoElementType.values()), + matcher.group("infoElementsSL") ?: matcher.group("infoElementsML") + ) + val nextDirective = matcher.group("nextDirectiveSL") ?: matcher.group("nextDirectiveML") + val range = matcher.start()..matcher.end() - nextDirective.length + + SpecTestCase( + code = matcher.group("codeSL") ?: matcher.group("codeML"), + ranges = mutableListOf(range), + unexpectedBehavior = caseInfoElements.contains(CommonInfoElementType.UNEXPECTED_BEHAVIOUR), + issues = CommonParser.parseIssues(caseInfoElements[CommonInfoElementType.ISSUES]).toMutableList() + ).save(testCasesSet.byNumbers, testCasesOfFile, testCasesByRangesOfFile, caseInfoElements) + + startFind = matcher.end() - nextDirective.length + } + rangeOffset += fileContent.length + } + + return testCasesSet +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestInfoParser.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestInfoParser.kt new file mode 100644 index 00000000000..3821ad91ed6 --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/parsers/TestInfoParser.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.parsers + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.spec.* +import org.jetbrains.kotlin.spec.models.CommonInfoElementType +import org.jetbrains.kotlin.spec.models.CommonSpecTestFileInfoElementType +import org.jetbrains.kotlin.spec.models.SpecTestInfoElements +import org.jetbrains.kotlin.spec.parsers.CommonParser.withUnderscores +import org.jetbrains.kotlin.spec.parsers.CommonParser.splitByComma +import org.jetbrains.kotlin.spec.validators.* +import java.io.File + +data class ParsedTestFile( + val testArea: TestArea, + val testType: TestType, + val sections: List, + val testNumber: Int, + val testDescription: String, + val testInfoElements: SpecTestInfoElements, + val testCasesSet: SpecTestCasesSet, + val unexpectedBehavior: Boolean, + val issues: Set +) + +fun parseTestInfo(testFilePath: String, testFiles: TestFiles, linkedTestType: SpecTestLinkedType): ParsedTestFile { + val patterns = linkedTestType.patterns.value + val testInfoByFilenameMatcher = patterns.testPathPattern.matcher(testFilePath) + + if (!testInfoByFilenameMatcher.find()) + throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID) + + val testInfoByContentMatcher = patterns.testInfoPattern.matcher(FileUtil.loadFile(File(testFilePath), true)) + + if (!testInfoByContentMatcher.find()) + throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID) + + val testInfoElements = CommonParser.parseTestInfoElements( + arrayOf(*CommonInfoElementType.values(), *CommonSpecTestFileInfoElementType.values(), *linkedTestType.infoElements.value), + testInfoByContentMatcher.group("infoElements") + ) + + return ParsedTestFile( + testArea = TestArea.valueOf(testInfoByContentMatcher.group("testArea").withUnderscores()), + testType = TestType.valueOf(testInfoByContentMatcher.group("testType")), + sections = testInfoElements[CommonSpecTestFileInfoElementType.SECTIONS]!!.content.splitByComma(), + testNumber = testInfoElements[CommonSpecTestFileInfoElementType.NUMBER]!!.content.toInt(), + testDescription = testInfoElements[CommonSpecTestFileInfoElementType.DESCRIPTION]!!.content, + testInfoElements = testInfoElements, + testCasesSet = parseTestCases(testFiles), + unexpectedBehavior = testInfoElements.contains(CommonInfoElementType.UNEXPECTED_BEHAVIOUR), + issues = CommonParser.parseIssues(testInfoElements[CommonInfoElementType.ISSUES]) + ) +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateFeatureInteractionSpecTestData.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateFeatureInteractionSpecTestData.kt index aacf1725719..71c7d97b3b3 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateFeatureInteractionSpecTestData.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateFeatureInteractionSpecTestData.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.spec.tasks -import org.jetbrains.kotlin.spec.generators.featureinteraction.Feature -import org.jetbrains.kotlin.spec.generators.featureinteraction.generationLinkedSpecTestDataConfig -import org.jetbrains.kotlin.spec.generators.featureinteraction.generationSpecTestDataConfigGroup -import org.jetbrains.kotlin.spec.validators.TestArea -import org.jetbrains.kotlin.spec.validators.TestType +import org.jetbrains.kotlin.spec.TestArea +import org.jetbrains.kotlin.spec.TestType +import org.jetbrains.kotlin.spec.generators.templates.Feature +import org.jetbrains.kotlin.spec.generators.templates.generationLinkedSpecTestDataConfig +import org.jetbrains.kotlin.spec.generators.templates.generationSpecTestDataConfigGroup fun main(args: Array) { generationSpecTestDataConfigGroup(regenerateTests = true) { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateJsonTestsMap.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateJsonTestsMap.kt index 1dfa3aaeeda..09460fe2539 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateJsonTestsMap.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/GenerateJsonTestsMap.kt @@ -6,11 +6,11 @@ package org.jetbrains.kotlin.spec.tasks import com.google.gson.JsonObject +import org.jetbrains.kotlin.spec.models.LinkedSpecTest +import org.jetbrains.kotlin.spec.parsers.CommonParser import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.MODULE_PATH import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH import org.jetbrains.kotlin.spec.utils.TestsJsonMapBuilder -import org.jetbrains.kotlin.spec.validators.LinkedSpecTestValidator -import org.jetbrains.kotlin.spec.validators.SpecTestValidationException import java.io.File private const val OUT_DIR = "out" @@ -20,15 +20,10 @@ fun main(args: Array) { val testsMap = JsonObject() File(TESTDATA_PATH).walkTopDown().forEach { - val specTestValidator = LinkedSpecTestValidator(it) + val (specTest, _) = CommonParser.parseSpecTest(it.canonicalPath, mapOf("main.kt" to it.readText())) - try { - specTestValidator.parseTestInfo() - } catch (e: SpecTestValidationException) { - return@forEach - } - - TestsJsonMapBuilder.buildJsonElement(specTestValidator.testInfo, testsMap) + if (specTest is LinkedSpecTest) + TestsJsonMapBuilder.buildJsonElement(specTest, testsMap) } val outDir = "$MODULE_PATH/$OUT_DIR" diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/PrintSpecTestsStatistic.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/PrintSpecTestsStatistic.kt index 35f5d6a99c8..5d6ef22e2c9 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/PrintSpecTestsStatistic.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/tasks/PrintSpecTestsStatistic.kt @@ -5,15 +5,15 @@ package org.jetbrains.kotlin.spec.tasks +import org.jetbrains.kotlin.spec.SpecTestLinkedType import org.jetbrains.kotlin.spec.utils.SpecTestsStatElement import org.jetbrains.kotlin.spec.utils.SpecTestsStatElementType import org.jetbrains.kotlin.spec.utils.TestsStatisticCollector -import org.jetbrains.kotlin.spec.validators.SpecTestLinkedType const val PRINT_BASE_INDENT = " " fun linkedSpecTestsPrint() { - println("SPEC TESTS STATISTIC") + println("LINKED SPEC TESTS STATISTIC") println("--------------------------------------------------") val statistic = TestsStatisticCollector.collect(SpecTestLinkedType.LINKED) @@ -21,14 +21,9 @@ fun linkedSpecTestsPrint() { for ((areaName, areaElement) in statistic) { println("$areaName: ${areaElement.number} tests") for ((sectionName, sectionElement) in areaElement.elements) { - println(" $sectionName: ${sectionElement.number} tests") - for ((paragraphName, paragraphElement) in sectionElement.elements) { - val testsStatByType = mutableListOf() - for ((typeName, typeElement) in paragraphElement.elements) - testsStatByType.add(" [ $typeName: ${typeElement.number} ]") - print(PRINT_BASE_INDENT.repeat(2)) - println("PARAGRAPH $paragraphName: ${paragraphElement.number} tests${testsStatByType.joinToString("")}") - } + print(" $sectionName: ${sectionElement.number} tests") + notLinkedSpecTestsCategoriesPrint(sectionElement.elements) + println() } } } diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt index 6674ff77a18..6073ca4980e 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt @@ -7,7 +7,7 @@ package org.jetbrains.kotlin.spec.utils import com.google.gson.* import com.google.gson.reflect.TypeToken -import org.jetbrains.kotlin.spec.validators.* +import org.jetbrains.kotlin.spec.models.LinkedSpecTest object TestsJsonMapBuilder { private val stringListType = object : TypeToken>() {}.type @@ -19,7 +19,7 @@ object TestsJsonMapBuilder { } fun buildJsonElement(testInfo: LinkedSpecTest, testsMap: JsonObject) { - val sectionElement = addJsonIfNotExist(testsMap, testInfo.section) + val sectionElement = addJsonIfNotExist(testsMap, testInfo.sections[0]) val paragraphElement = addJsonIfNotExist(sectionElement, testInfo.paragraphNumber) val sentenceElement = addJsonIfNotExist(paragraphElement, testInfo.sentenceNumber) val testAreaElement = addJsonIfNotExist(sentenceElement, testInfo.testArea.name.toLowerCase()) @@ -27,12 +27,12 @@ object TestsJsonMapBuilder { val testNumberElement = addJsonIfNotExist(testTypeElement, testInfo.testNumber) testNumberElement.addProperty("description", testInfo.description) - testNumberElement.addProperty("caseNumber", testInfo.cases!!.size) + testNumberElement.addProperty("caseNumber", testInfo.cases.byFiles.size) - if (testInfo.unexpectedBehavior!!) + if (testInfo.unexpectedBehavior) testNumberElement.addProperty("unexpectedBehavior", testInfo.unexpectedBehavior) - if (testInfo.issues!!.isNotEmpty()) + if (testInfo.issues.isNotEmpty()) testNumberElement.add("issues", Gson().toJsonTree(testInfo.issues, stringListType)) } } \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt index 098ecf04ee5..26432ff50f9 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt @@ -5,8 +5,11 @@ package org.jetbrains.kotlin.spec.utils +import org.jetbrains.kotlin.spec.SpecTestLinkedType +import org.jetbrains.kotlin.spec.TestArea +import org.jetbrains.kotlin.spec.models.AbstractSpecTest +import org.jetbrains.kotlin.spec.parsers.CommonParser import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH -import org.jetbrains.kotlin.spec.validators.* import java.io.File open class SpecTestsStatElement(val type: SpecTestsStatElementType) { @@ -42,27 +45,18 @@ object TestsStatisticCollector { val statistic = mutableMapOf() for (specTestArea in TestArea.values()) { - val specTestsPath = "$TESTDATA_PATH/${specTestArea.name.toLowerCase()}/${testLinkedType.testDataPath}" + val specTestsPath = "$TESTDATA_PATH/${specTestArea.name.toLowerCase().replace("_", "/")}/${testLinkedType.testDataPath}" statistic[specTestArea] = SpecTestsStatElement(SpecTestsStatElementType.AREA) File(specTestsPath).walkTopDown().forEach areaTests@{ if (!it.isFile || it.extension != "kt") return@areaTests - val specTestsValidator = AbstractSpecTestValidator.getInstanceByType(it) - - try { - specTestsValidator.parseTestInfo() - } catch (e: SpecTestValidationException) { - return@areaTests - } + val (specTest, _) = CommonParser.parseSpecTest(it.canonicalPath, mapOf("main.kt" to it.readText())) incrementStatCounters( statistic[specTestArea]!!, - when (testLinkedType) { - SpecTestLinkedType.LINKED -> getStatElementsByLinkedTests(specTestsValidator.testInfo as LinkedSpecTest) - SpecTestLinkedType.NOT_LINKED -> getStatElementsByNotLinkedTests(specTestsValidator.testInfo as NotLinkedSpecTest) - } + getStatElements(specTest) ) } } @@ -70,15 +64,9 @@ object TestsStatisticCollector { return statistic } - private fun getStatElementsByLinkedTests(testInfo: LinkedSpecTest) = listOf( - SpecTestsStatElementType.SECTION to testInfo.section, - SpecTestsStatElementType.PARAGRAPH to testInfo.paragraphNumber, - SpecTestsStatElementType.TYPE to testInfo.testType.type - ) - - private fun getStatElementsByNotLinkedTests(testInfo: NotLinkedSpecTest) = - mutableListOf(SpecTestsStatElementType.SECTION to testInfo.section).apply { - addAll(testInfo.categories.map { SpecTestsStatElementType.CATEGORY to it }) + private fun getStatElements(testInfo: AbstractSpecTest) = + mutableListOf(SpecTestsStatElementType.SECTION to testInfo.sections[0]).apply { + addAll(testInfo.sections.map { SpecTestsStatElementType.CATEGORY to it }) add(SpecTestsStatElementType.TYPE to testInfo.testType.type) } } \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractSpecTestValidator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractSpecTestValidator.kt deleted file mode 100644 index 2b3c772dff4..00000000000 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractSpecTestValidator.kt +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.spec.validators - -import java.io.File -import java.util.regex.Matcher -import java.util.regex.Pattern - -enum class TestType(val type: String) { - POSITIVE("pos"), - NEGATIVE("neg"); - - companion object { - private val map = TestType.values().associateBy(TestType::type) - fun fromValue(type: String) = map[type] - } -} - -enum class TestArea(val testDataPath: String) { - PSI("psi"), - DIAGNOSTICS("diagnostics"), - CODEGEN_BOX("codegen/box") -} - -enum class SpecTestLinkedType(val testDataPath: String) { - LINKED("linked"), - NOT_LINKED("notLinked") -} - -interface SpecTestInfoElementType { - val valuePattern: Pattern? - val required: Boolean -} - -enum class SpecTestCaseInfoElementType( - override val valuePattern: Pattern? = null, - override val required: Boolean = false -) : SpecTestInfoElementType { - CASE_DESCRIPTION(required = true), - ISSUES(valuePattern = LinkedSpecTestFileInfoElementType.ISSUES.valuePattern), - UNEXPECTED_BEHAVIOUR, - DISCUSSION, - NOTE -} - -data class SpecTestInfoElementContent( - val content: String, - val additionalMatcher: Matcher? = null -) - -data class SpecTestCase( - val number: Int, - val description: String, - val unexpectedBehavior: Boolean, - val issues: List? -) - -enum class SpecTestValidationFailedReason(val description: String) { - FILENAME_NOT_VALID("Incorrect test filename or folder name."), - TESTINFO_NOT_VALID("Test info is incorrect."), - FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY("Test info from filepath and file content is not consistency"), - TEST_IS_NOT_POSITIVE("Test is not positive because it contains error elements (PsiErrorElement or diagnostic with error severity)."), - TEST_IS_NOT_NEGATIVE("Test is not negative because it not contains error type elements (PsiErrorElement or diagnostic with error severity)."), - UNKNOWN("Unknown validation error.") -} - -class SpecTestValidationException(reason: SpecTestValidationFailedReason, details: String = "") : Exception() { - val description = "${reason.description} $details" -} - -typealias SpecTestInfoElements = Map - -interface SpecTestValidatorHelperObject { - val pathPartRegex: String - val filenameRegex: String - fun getPathPattern(): Pattern -} - -abstract class AbstractSpecTest( - val testArea: TestArea, - val testType: TestType, - val section: String, - val testNumber: Int, - val description: String? = null, - val cases: List? = null, - val unexpectedBehavior: Boolean? = null, - val issues: Set? = null -) { - abstract fun checkConsistency(other: AbstractSpecTest): Boolean -} - -abstract class AbstractSpecTestValidator(private val testDataFile: File) { - val testInfo by lazy { testInfoByContent } - - protected lateinit var testInfoByFilename: T - protected lateinit var testInfoByContent: T - abstract val testPathPattern: Pattern - abstract val testInfoPattern: Pattern - - companion object { - const val ISSUE_TRACKER = "https://youtrack.jetbrains.com/issue/" - const val INTEGER_REGEX = """[1-9]\d*""" - - val pathSeparator: String = Pattern.quote(File.separator) - val lineSeparator: String = System.lineSeparator() - val testAreaRegex = """(?${TestArea.values().joinToString("|").replace("_", " ")})""" - val testTypeRegex = """(?${TestType.values().joinToString("|")})""" - val multilineCommentRegex = """\/\*\s*%s\s+\*\/(?:$lineSeparator)*""" - private val singlelineCommentRegex = """\/\/\s*%s(?:$lineSeparator)*""" - private val testInfoElementPattern: Pattern = Pattern.compile("""\s*(?[A-Z ]+?)(?::\s*(?.*?))?$lineSeparator""") - private val testCaseInfoRegex = """(?CASE DESCRIPTION:[\s\S]*?$lineSeparator)(?:$lineSeparator)*""" - private val testPathBaseRegexTemplate = - """^.*?$pathSeparator(?diagnostics|psi|(?:codegen${pathSeparator}box))$pathSeparator%s""" - val testPathRegexTemplate = """$testPathBaseRegexTemplate$pathSeparator(?pos|neg)$pathSeparator%s$""" - val testCaseInfoSingleLinePattern: Pattern = Pattern.compile(singlelineCommentRegex.format(testCaseInfoRegex)) - val testCaseInfoMultilinePattern: Pattern = Pattern.compile(multilineCommentRegex.format(testCaseInfoRegex)) - - fun getInstanceByType(testFile: File) = when { - Pattern.compile(testPathBaseRegexTemplate.format(LinkedSpecTestValidator.pathPartRegex)).matcher(testFile.canonicalPath).find() -> - LinkedSpecTestValidator(testFile) - Pattern.compile(testPathBaseRegexTemplate.format(NotLinkedSpecTestValidator.pathPartRegex)).matcher(testFile.canonicalPath).find() -> - NotLinkedSpecTestValidator(testFile) - else -> throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID) - } - - fun getInstanceByType(testPath: String) = getInstanceByType(File(testPath)) - - private fun getTestInfoElements( - testInfoElementRules: Array, - testInfoElements: String - ): SpecTestInfoElements { - val testInfoElementsMap = mutableMapOf() - val testInfoElementMatcher = testInfoElementPattern.matcher(testInfoElements) - - while (testInfoElementMatcher.find()) { - val testInfoOriginalElementName = testInfoElementMatcher.group("name") - val testInfoElementName = testInfoElementRules.find { - it as Enum<*> - it.name == testInfoOriginalElementName.replace(" ", "_") - } ?: throw SpecTestValidationException( - SpecTestValidationFailedReason.TESTINFO_NOT_VALID, - "Unknown '$testInfoOriginalElementName' test info element name." - ) - val testInfoElementValue = testInfoElementMatcher.group("value") - val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue) - - if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find()) - throw SpecTestValidationException( - SpecTestValidationFailedReason.TESTINFO_NOT_VALID, - "'$testInfoElementValue' in '$testInfoElementName' is not parsed." - ) - - testInfoElementsMap[testInfoElementName] = - SpecTestInfoElementContent(testInfoElementValue ?: "", testInfoElementValueMatcher) - } - - testInfoElementRules.forEach { - if (it.required && !testInfoElementsMap.contains(it)) { - throw SpecTestValidationException( - SpecTestValidationFailedReason.TESTINFO_NOT_VALID, - "$it in case or test info is required." - ) - } - } - - return testInfoElementsMap - } - - private fun getIssues(testCases: List, testIssues: List?): Set { - val issues = mutableSetOf() - - testCases.forEach { - if (it.issues != null) issues.addAll(it.issues) - } - - if (testIssues != null) issues.addAll(testIssues) - - return issues - } - - fun parseIssues(issues: SpecTestInfoElementContent?) = issues?.content?.split(",") - } - - private fun getTestCasesInfo( - testCaseInfoMatcher: Matcher, - infoElements: SpecTestInfoElements - ): List { - val testCases = mutableListOf() - var testCasesCounter = 1 - - while (testCaseInfoMatcher.find()) { - val caseInfoElements = getTestInfoElements( - SpecTestCaseInfoElementType.values(), - testCaseInfoMatcher.group("infoElements") - ) - - testCases.add( - SpecTestCase( - testCasesCounter++, - caseInfoElements[SpecTestCaseInfoElementType.CASE_DESCRIPTION]!!.content, - caseInfoElements.contains(SpecTestCaseInfoElementType.UNEXPECTED_BEHAVIOUR), - parseIssues(caseInfoElements[SpecTestCaseInfoElementType.ISSUES]) - ) - ) - } - - if (testCases.isEmpty()) - testCases.add(getSingleTestCase(infoElements)) - - return testCases - } - - abstract fun getSingleTestCase(testInfoElements: SpecTestInfoElements) : SpecTestCase - - fun testInfoFilter(fileContent: String): String = - testInfoPattern.matcher(fileContent).replaceAll("").let { - testCaseInfoSingleLinePattern.matcher(it).replaceAll("").let { - testCaseInfoMultilinePattern.matcher(it).replaceAll("") - } - } - - abstract fun getTestInfo( - testInfoMatcher: Matcher, - testInfoElements: SpecTestInfoElements, - testCases: List, - unexpectedBehavior: Boolean = false, - issues: Set? = null - ): T - - abstract fun getTestInfo(testInfoMatcher: Matcher): T - - abstract fun parseTestInfo() - - abstract fun printTestInfo() - - fun parseTestInfo(testInfoElementsRules: Array) { - val testInfoByFilenameMatcher = testPathPattern.matcher(testDataFile.canonicalPath) - - if (!testInfoByFilenameMatcher.find()) - throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID) - - val fileContent = testDataFile.readText() - val testInfoByContentMatcher = testInfoPattern.matcher(fileContent) - - if (!testInfoByContentMatcher.find()) - throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID) - - val testInfoElements = getTestInfoElements( - testInfoElementsRules, - testInfoByContentMatcher.group("infoElements") - ) - val testCases = getTestCasesInfo(testCaseInfoSingleLinePattern.matcher(fileContent), testInfoElements) + - getTestCasesInfo(testCaseInfoMultilinePattern.matcher(fileContent), testInfoElements) - - testInfoByFilename = getTestInfo(testInfoByFilenameMatcher) - testInfoByContent = getTestInfo( - testInfoByContentMatcher, - testInfoElements, - testCases = testCases, - unexpectedBehavior = testInfoElements.contains(LinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR) || testCases.any { it.unexpectedBehavior }, - issues = getIssues( - testCases, - parseIssues( - testInfoElements[LinkedSpecTestFileInfoElementType.ISSUES] - ) - ) - ) - - if (!testInfoByFilename.checkConsistency(testInfoByContent)) - throw SpecTestValidationException(SpecTestValidationFailedReason.FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY) - } - - fun validateTestType(computedTestType: TestType) { - if (computedTestType != testInfo.testType) { - val isNotNegative = computedTestType == TestType.POSITIVE && testInfo.testType == TestType.NEGATIVE - val isNotPositive = computedTestType == TestType.NEGATIVE && testInfo.testType == TestType.POSITIVE - val reason = when { - isNotNegative -> SpecTestValidationFailedReason.TEST_IS_NOT_NEGATIVE - isNotPositive -> SpecTestValidationFailedReason.TEST_IS_NOT_POSITIVE - else -> SpecTestValidationFailedReason.UNKNOWN - } - throw SpecTestValidationException(reason) - } - } -} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractTestValidator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractTestValidator.kt new file mode 100644 index 00000000000..46ac74e6bab --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/AbstractTestValidator.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.spec.validators + +import org.jetbrains.kotlin.spec.models.AbstractSpecTest +import org.jetbrains.kotlin.spec.SpecTestLinkedType +import org.jetbrains.kotlin.spec.TestType +import org.jetbrains.kotlin.spec.parsers.CommonPatterns +import java.io.File + +enum class SpecTestValidationFailedReason(val description: String) { + FILENAME_NOT_VALID("Incorrect test filename or folder name."), + TESTINFO_NOT_VALID("Test info is incorrect."), + FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY("Test info from filepath and file content is not consistency"), + TEST_IS_NOT_POSITIVE("Test is not positive because it contains error elements (PsiErrorElement or diagnostic with error severity)."), + TEST_IS_NOT_NEGATIVE("Test is not negative because it not contains error type elements (PsiErrorElement or diagnostic with error severity)."), + INVALID_TEST_CASES_STRUCTURE( + "All code in the test file must be divided and marked as a 'test case' label.${CommonPatterns.ls}Example:${CommonPatterns.ls.repeat(2)}// TESTCASE NUMBER: 1${CommonPatterns.ls}fun main() { println(\"Hello, Kotlin!\") }${CommonPatterns.ls.repeat(2)}" + ), + UNKNOWN_FRONTEND_EXCEPTION("Unknown frontend exception. Manual analysis is required."), + UNMATCHED_FRONTEND_EXCEPTION("Unmatched frontend exception. Manual analysis is required."), + UNKNOWN("Unknown validation error.") +} + +class SpecTestValidationException(reason: SpecTestValidationFailedReason, details: String = "") : Exception() { + val description = "${reason.description} $details" +} + +abstract class AbstractTestValidator(private val testInfo: AbstractSpecTest, private val testDataFile: File) { + fun validatePathConsistency(testLinkedType: SpecTestLinkedType) { + val matcher = testLinkedType.patterns.value.testPathPattern.matcher(testDataFile.canonicalPath).apply { find() } + + if (!testInfo.checkPathConsistency(matcher)) + throw SpecTestValidationException(SpecTestValidationFailedReason.FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY) + } + + abstract fun computeTestTypes(): Map + + fun validateTestType() { + val computedTestTypes = computeTestTypes() + + for ((caseNumber, case) in testInfo.cases.byNumbers) { + val testType = computedTestTypes[caseNumber] ?: TestType.POSITIVE + + if (testType != testInfo.testType && !testInfo.unexpectedBehavior && !case.unexpectedBehavior) { + val isNotNegative = testType == TestType.POSITIVE && testInfo.testType == TestType.NEGATIVE + val isNotPositive = testType == TestType.NEGATIVE && testInfo.testType == TestType.POSITIVE + val reason = when { + isNotNegative -> SpecTestValidationFailedReason.TEST_IS_NOT_NEGATIVE + isNotPositive -> SpecTestValidationFailedReason.TEST_IS_NOT_POSITIVE + else -> SpecTestValidationFailedReason.UNKNOWN + } + throw SpecTestValidationException(reason, details = "TESTCASE: $caseNumber") + } + } + } +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/DiagnosticTestTypeValidator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/DiagnosticTestTypeValidator.kt index 01e0494aba0..2c3f19d136a 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/DiagnosticTestTypeValidator.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/DiagnosticTestTypeValidator.kt @@ -8,20 +8,44 @@ package org.jetbrains.kotlin.spec.validators import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Severity +import org.jetbrains.kotlin.spec.models.AbstractSpecTest +import org.jetbrains.kotlin.spec.TestCasesByNumbers +import org.jetbrains.kotlin.spec.TestType +import java.io.File -class DiagnosticTestTypeValidator(testFiles: List) { +class DiagnosticTestTypeValidator( + testFiles: List, + testDataFile: File, + private val testInfo: AbstractSpecTest +) : AbstractTestValidator(testInfo, testDataFile) { private val diagnostics = mutableListOf() private val diagnosticStats = mutableMapOf() - private val diagnosticSeverityStats = mutableMapOf() + private val diagnosticSeverityStats = mutableMapOf>() init { collectDiagnostics(testFiles) } + private fun findTestCases(diagnostic: Diagnostic): TestCasesByNumbers { + val ranges = diagnostic.textRanges + val filename = diagnostic.psiFile.name + val foundTestCases = testInfo.cases.byRanges[filename]!!.floorEntry(ranges[0].startOffset) + + if (foundTestCases != null) + return foundTestCases.value + + throw SpecTestValidationException(SpecTestValidationFailedReason.INVALID_TEST_CASES_STRUCTURE) + } + private fun collectDiagnosticStatistic() { diagnostics.forEach { + val testCases = findTestCases(it) val severity = it.factory.severity - diagnosticSeverityStats.run { put(severity, getOrDefault(severity, 0) + 1) } + + for ((caseNumber, _) in testCases) { + diagnosticSeverityStats.putIfAbsent(caseNumber, mutableMapOf()) + diagnosticSeverityStats[caseNumber]!!.run { put(severity, getOrDefault(severity, 0) + 1) } + } } } @@ -36,8 +60,9 @@ class DiagnosticTestTypeValidator(testFiles: List) collectDiagnosticStatistic() } - fun computeTestType() = - if (Severity.ERROR in diagnosticSeverityStats) TestType.NEGATIVE else TestType.POSITIVE + override fun computeTestTypes() = diagnosticSeverityStats.mapValues { + if (Severity.ERROR in it.value) TestType.NEGATIVE else TestType.POSITIVE + } fun printDiagnosticStatistic() { val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain" diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/LinkedSpecTestValidator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/LinkedSpecTestValidator.kt deleted file mode 100644 index a5e6369f50a..00000000000 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/LinkedSpecTestValidator.kt +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.spec.validators - -import java.io.File -import java.util.regex.Matcher -import java.util.regex.Pattern - -enum class LinkedSpecTestFileInfoElementType( - override val valuePattern: Pattern? = null, - override val required: Boolean = false -) : SpecTestInfoElementType { - SECTIONS( - Pattern.compile("""\w+(,\s+\w+)*"""), - required = true - ), - PARAGRAPH(required = true), - SENTENCE( - valuePattern = Pattern.compile("""\[(?${AbstractSpecTestValidator.INTEGER_REGEX})\](?.*?)"""), - required = true - ), - NUMBER(required = true), - DESCRIPTION(required = true), - ISSUES(valuePattern = Pattern.compile("""(KT-[1-9]\d*)(,\s*KT-[1-9]\d*)*""")), - UNEXPECTED_BEHAVIOUR, - DISCUSSION, - NOTE -} - -class LinkedSpecTest( - testArea: TestArea, - testType: TestType, - val sections: List, - val paragraphNumber: Int, - val sentenceNumber: Int, - val sentence: String? = null, - testNumber: Int, - description: String? = null, - cases: List? = null, - unexpectedBehavior: Boolean? = null, - issues: Set? = null -) : AbstractSpecTest(testArea, testType, sections[0], testNumber, description, cases, unexpectedBehavior, issues) { - override fun checkConsistency(other: AbstractSpecTest) = - other is LinkedSpecTest - && this.sections == other.sections - && this.testArea == other.testArea - && this.testType == other.testType - && this.testNumber == other.testNumber - && this.paragraphNumber == other.paragraphNumber - && this.sentenceNumber == other.sentenceNumber -} - -class LinkedSpecTestValidator(testDataFile: File) : AbstractSpecTestValidator(testDataFile) { - override val testPathPattern = getPathPattern() - override val testInfoPattern: Pattern = - Pattern.compile(multilineCommentRegex.format("""KOTLIN $testAreaRegex SPEC TEST \($testTypeRegex\)$lineSeparator(?[\s\S]*?$lineSeparator)""")) - - companion object : SpecTestValidatorHelperObject { - override val pathPartRegex = - """${SpecTestLinkedType.LINKED.testDataPath}$pathSeparator(?(?:[\w-]+)(?:$pathSeparator[\w-]+)*?)${pathSeparator}p-(?$INTEGER_REGEX)""" - override val filenameRegex = """(?$INTEGER_REGEX)\.(?$INTEGER_REGEX)\.kt""" - override fun getPathPattern(): Pattern = Pattern.compile(testPathRegexTemplate.format(pathPartRegex, filenameRegex)) - } - - override fun getTestInfo( - testInfoMatcher: Matcher, - testInfoElements: SpecTestInfoElements, - testCases: List, - unexpectedBehavior: Boolean, - issues: Set? - ): LinkedSpecTest { - val sentenceMatcher = testInfoElements[LinkedSpecTestFileInfoElementType.SENTENCE]!!.additionalMatcher!! - - return LinkedSpecTest( - TestArea.valueOf(testInfoMatcher.group("testArea").replace(" ", "_").toUpperCase()), - TestType.valueOf(testInfoMatcher.group("testType")), - testInfoElements[LinkedSpecTestFileInfoElementType.SECTIONS]!!.content.split(Regex(""",\s*""")), - testInfoElements[LinkedSpecTestFileInfoElementType.PARAGRAPH]!!.content.toInt(), - sentenceMatcher.group("number").toInt(), - sentenceMatcher.group("text"), - testInfoElements[LinkedSpecTestFileInfoElementType.NUMBER]!!.content.toInt(), - testInfoElements[LinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content, - testCases, - unexpectedBehavior, - issues - ) - } - - override fun getTestInfo(testInfoMatcher: Matcher) = - LinkedSpecTest( - TestArea.valueOf(testInfoMatcher.group("testArea").replace(File.separator, "_").toUpperCase()), - TestType.fromValue(testInfoMatcher.group("testType"))!!, - testInfoMatcher.group("sections").split(File.separator), - testInfoMatcher.group("paragraphNumber").toInt(), - testInfoMatcher.group("sentenceNumber").toInt(), - testNumber = testInfoMatcher.group("testNumber").toInt() - ) - - override fun parseTestInfo() = parseTestInfo(LinkedSpecTestFileInfoElementType.values()) - - override fun printTestInfo() { - println("--------------------------------------------------") - if (testInfoByContent.unexpectedBehavior!!) - println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)") - println("${testInfoByFilename.testArea.name.replace("_", " ")} ${testInfoByFilename.testType} SPEC TEST") - println("SECTIONS: ${testInfoByContent.sections} (paragraph: ${testInfoByFilename.paragraphNumber})") - println("SENTENCE ${testInfoByContent.sentenceNumber}: ${testInfoByContent.sentence}") - println("TEST NUMBER: ${testInfoByContent.testNumber}") - println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}") - println("DESCRIPTION: ${testInfoByContent.description}") - if (testInfoByContent.issues!!.isNotEmpty()) - println("LINKED ISSUES: ${testInfoByContent.issues!!.joinToString { "${ISSUE_TRACKER + it}," }}") - } - - override fun getSingleTestCase(testInfoElements: SpecTestInfoElements) = - SpecTestCase( - 1, - description = testInfoElements[LinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content, - unexpectedBehavior = testInfoElements.contains(LinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR), - issues = parseIssues(testInfoElements[LinkedSpecTestFileInfoElementType.ISSUES]) - ) -} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/NotLinkedSpecTestValidator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/NotLinkedSpecTestValidator.kt deleted file mode 100644 index 2517b472026..00000000000 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/NotLinkedSpecTestValidator.kt +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.spec.validators - -import java.io.File -import java.util.regex.Matcher -import java.util.regex.Pattern - -enum class NotLinkedSpecTestFileInfoElementType( - override val valuePattern: Pattern? = null, - override val required: Boolean = false -) : SpecTestInfoElementType { - SECTION(required = true), - CATEGORIES( - valuePattern = Pattern.compile("""\w+(,\s+\w+)*"""), - required = true - ), - NUMBER(required = true), - DESCRIPTION(required = true), - ISSUES(valuePattern = LinkedSpecTestFileInfoElementType.ISSUES.valuePattern), - UNEXPECTED_BEHAVIOUR, - DISCUSSION, - NOTE -} - -class NotLinkedSpecTest( - testArea: TestArea, - testType: TestType, - section: String, - val categories: List, - testNumber: Int, - description: String? = null, - cases: List? = null, - unexpectedBehavior: Boolean? = null, - issues: Set? = null -) : AbstractSpecTest(testArea, testType, section, testNumber, description, cases, unexpectedBehavior, issues) { - override fun checkConsistency(other: AbstractSpecTest) = - other is NotLinkedSpecTest - && this.section == other.section - && this.testArea == other.testArea - && this.testType == other.testType - && this.categories.joinToString(",") == other.categories.joinToString(",") - && this.testNumber == other.testNumber -} - -class NotLinkedSpecTestValidator(testDataFile: File) : AbstractSpecTestValidator(testDataFile) { - override val testPathPattern = getPathPattern() - override val testInfoPattern: Pattern = - Pattern.compile(multilineCommentRegex.format("""KOTLIN $testAreaRegex NOT LINKED SPEC TEST \($testTypeRegex\)$lineSeparator(?[\s\S]*?$lineSeparator)""")) - - companion object : SpecTestValidatorHelperObject { - override val pathPartRegex = - """${SpecTestLinkedType.NOT_LINKED.testDataPath}$pathSeparator(?[\w-]+)$pathSeparator(?(?:[\w-]+)(?:$pathSeparator[\w-]+)*?)""" - override val filenameRegex = """(?$INTEGER_REGEX)\.kt""" - override fun getPathPattern(): Pattern = Pattern.compile(testPathRegexTemplate.format(pathPartRegex, filenameRegex)) - } - - override fun getTestInfo( - testInfoMatcher: Matcher, - testInfoElements: SpecTestInfoElements, - testCases: List, - unexpectedBehavior: Boolean, - issues: Set? - ) = - NotLinkedSpecTest( - TestArea.valueOf(testInfoMatcher.group("testArea").replace(" ", "_").toUpperCase()), - TestType.valueOf(testInfoMatcher.group("testType")), - testInfoElements[NotLinkedSpecTestFileInfoElementType.SECTION]!!.content, - testInfoElements[NotLinkedSpecTestFileInfoElementType.CATEGORIES]!!.content.split(Regex(""",\s*""")), - testInfoElements[NotLinkedSpecTestFileInfoElementType.NUMBER]!!.content.toInt(), - testInfoElements[NotLinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content, - testCases, - unexpectedBehavior, - issues - ) - - override fun getTestInfo(testInfoMatcher: Matcher) = - NotLinkedSpecTest( - TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()), - TestType.fromValue(testInfoMatcher.group("testType"))!!, - testInfoMatcher.group("sections"), - testInfoMatcher.group("categories").split(File.separator), - testNumber = testInfoMatcher.group("testNumber").toInt() - ) - - override fun parseTestInfo() = parseTestInfo(NotLinkedSpecTestFileInfoElementType.values()) - - override fun printTestInfo() { - println("--------------------------------------------------") - if (testInfoByContent.unexpectedBehavior!!) - println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)") - println("${testInfoByFilename.testArea} ${testInfoByFilename.testType} NOT LINKED SPEC TEST") - println("SECTIONS: ${testInfoByContent.section}") - println("CATEGORIES: ${testInfoByContent.categories.joinToString(", ")}") - println("TEST NUMBER: ${testInfoByContent.testNumber}") - println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}") - println("DESCRIPTION: ${testInfoByContent.description}") - if (testInfoByContent.issues!!.isNotEmpty()) - println("LINKED ISSUES: ${testInfoByContent.issues!!.map { ISSUE_TRACKER + it }.joinToString(", ")}") - } - - override fun getSingleTestCase(testInfoElements: SpecTestInfoElements) = - SpecTestCase( - 1, - description = testInfoElements[NotLinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content, - unexpectedBehavior = testInfoElements.contains(NotLinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR), - issues = parseIssues(testInfoElements[NotLinkedSpecTestFileInfoElementType.ISSUES]) - ) -} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/ParsingTestTypeValidator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/ParsingTestTypeValidator.kt index 4b95b947ff5..65f1ea7002f 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/ParsingTestTypeValidator.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/validators/ParsingTestTypeValidator.kt @@ -8,11 +8,17 @@ package org.jetbrains.kotlin.spec.validators import com.intellij.psi.PsiElement import com.intellij.psi.PsiErrorElement import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.spec.TestType +import org.jetbrains.kotlin.spec.models.AbstractSpecTest +import java.io.File -object ParsingTestTypeValidator { +class ParsingTestTypeValidator( + private val psiFile: PsiFile, + testDataFile: File, + testInfo: AbstractSpecTest +) : AbstractTestValidator(testInfo, testDataFile) { private fun checkErrorElement(psi: PsiElement): Boolean = psi.children.any { it is PsiErrorElement || checkErrorElement(it) } - fun computeTestType(psiFile: PsiFile) = - if (checkErrorElement(psiFile)) TestType.NEGATIVE else TestType.POSITIVE + override fun computeTestTypes() = mapOf(1 to if (checkErrorElement(psiFile)) TestType.NEGATIVE else TestType.POSITIVE) }