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
This commit is contained in:
victor.petukhov
2018-10-31 12:56:27 +03:00
parent 2af9efa4a0
commit 64f531fc93
348 changed files with 4722 additions and 3802 deletions
@@ -128,7 +128,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
private val diagnosedRanges: List<CheckerTestUtil.DiagnosedRange> = ArrayList() private val diagnosedRanges: List<CheckerTestUtil.DiagnosedRange> = ArrayList()
val actualDiagnostics: MutableList<ActualDiagnostic> = ArrayList() val actualDiagnostics: MutableList<ActualDiagnostic> = ArrayList()
val expectedText: String val expectedText: String
private val clearText: String val clearText: String
private val createKtFile: Lazy<KtFile?> private val createKtFile: Lazy<KtFile?>
private val whatDiagnosticsToConsider: Condition<Diagnostic> private val whatDiagnosticsToConsider: Condition<Diagnostic>
val customLanguageVersionSettings: LanguageVersionSettings? val customLanguageVersionSettings: LanguageVersionSettings?
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
open class `true` { open class `true` {
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 10 * NUMBER: 10
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the companionObject. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
package org.jetbrains.`true` package org.jetbrains.`true`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 11 * NUMBER: 11
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the function. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
fun `true`(): Boolean { fun `true`(): Boolean {
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 12 * NUMBER: 12
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the setter. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
class A { class A {
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 13 * NUMBER: 13
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the simpleUserType. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
package org.jetbrains.`true` package org.jetbrains.`true`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 14 * NUMBER: 14
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeParameter. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
package org.jetbrains.`true` package org.jetbrains.`true`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 15 * NUMBER: 15
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the parameter. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
fun f1(`true`: Boolean) = !!!`true` fun f1(`true`: Boolean) = !!!`true`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 16 * NUMBER: 16
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationComplex. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
@file:[org.jetbrains.`true`.`false`() `true`] @file:[org.jetbrains.`true`.`false`() `true`]
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 17 * NUMBER: 17
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the object. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
open class A { open class A {
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 18 * NUMBER: 18
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeAlias. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
typealias `true` = Boolean typealias `true` = Boolean
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 19 * NUMBER: 19
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the import. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
// FILE: 2_19_1.kt // FILE: 2_19_1.kt
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 2 * NUMBER: 2
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelReference. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
fun `true`() { fun `true`() {
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 20 * NUMBER: 20
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the infixFunctionCall. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
infix fun Int.`true`(value: Int) = value > 100 infix fun Int.`true`(value: Int) = value > 100
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 21 * NUMBER: 21
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the catchBlock. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
annotation class A annotation class A
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 22 * NUMBER: 22
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the labelDefinition. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 23 * NUMBER: 23
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the atomicExpression. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
fun box(): String? { fun box(): String? {
@@ -1,14 +1,14 @@
// WITH_RUNTIME // WITH_RUNTIME
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 24 * NUMBER: 24
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the variableDeclarationEntry. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
val `true` = {`false`: Boolean -> !`false` } val `true` = {`false`: Boolean -> !`false` }
@@ -1,14 +1,14 @@
// WITH_RUNTIME // WITH_RUNTIME
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 25 * NUMBER: 25
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the valueArgument. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
fun f1(`true`: Boolean, `false`: Boolean) = `true` && !!!`false` fun f1(`true`: Boolean, `false`: Boolean) = `true` && !!!`false`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 26 * NUMBER: 26
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the callableReference. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
val Boolean.`true`: Boolean val Boolean.`true`: Boolean
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 3 * NUMBER: 3
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the typeConstraint. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
class A <`true`, `false`> class A <`true`, `false`>
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 4 * NUMBER: 4
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the fileAnnotationSimple. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
@file:`true` @file:`true`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 5 * NUMBER: 5
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageComplex. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
package org.jetbrains.`true` package org.jetbrains.`true`
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 6 * NUMBER: 6
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the packageSimple. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
package `true` package `true`
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 7 * NUMBER: 7
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the enumEntry. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
enum class A(val x: Boolean) { enum class A(val x: Boolean) {
@@ -1,12 +1,12 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 8 * NUMBER: 8
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the stringTemplateElement. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
fun box(): String? { fun box(): String? {
@@ -1,14 +1,14 @@
// HELPERS: REFLECT // HELPERS: REFLECT
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, boolean-literals * SECTIONS: constant-literals, boolean-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped. * SENTENCE: [2] These are strong keywords which cannot be used as identifiers unless escaped.
NUMBER: 9 * NUMBER: 9
DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the unescapedAnnotation. * 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! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
package org.jetbrains.`true` package org.jetbrains.`true`
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, binary-integer-literals * SECTIONS: constant-literals, integer-literals, binary-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Sequences with binary digit symbols. * DESCRIPTION: Sequences with binary digit symbols.
*/ */
val value_1 = 0b1110001100 val value_1 = 0b1110001100
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, binary-integer-literals * SECTIONS: constant-literals, integer-literals, binary-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Sequences with binary digit symbols separated by underscores. * DESCRIPTION: Sequences with binary digit symbols separated by underscores.
*/ */
val value_1 = 0b1_110110100 val value_1 = 0b1_110110100
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, decimal-integer-literals * SECTIONS: constant-literals, integer-literals, decimal-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Sequences with decimal digit symbols. * DESCRIPTION: Sequences with decimal digit symbols.
*/ */
val value_1 = 1234567890 val value_1 = 1234567890
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, decimal-integer-literals * SECTIONS: constant-literals, integer-literals, decimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Sequences with decimal digit symbols separated by underscores. * DESCRIPTION: Sequences with decimal digit symbols separated by underscores.
*/ */
val value_1 = 1234_5678_90 val value_1 = 1234_5678_90
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Sequences with hexadecimal digit symbols. * DESCRIPTION: Sequences with hexadecimal digit symbols.
*/ */
val value_1 = 0x1234567890 val value_1 = 0x1234567890
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [2] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Sequences with hexadecimal digit symbols separated by underscores. * DESCRIPTION: Sequences with hexadecimal digit symbols separated by underscores.
*/ */
val value_1 = 0x1_23a567b90 val value_1 = 0x1_23a567b90
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Decimal integer literals with long literal mark. * DESCRIPTION: Decimal integer literals with long literal mark.
*/ */
val value_1 = 0L val value_1 = 0L
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 2 * NUMBER: 2
DESCRIPTION: Hexadecimal integer literals with long literal mark. * DESCRIPTION: Hexadecimal integer literals with long literal mark.
*/ */
val value_1 = 0x0L val value_1 = 0x0L
@@ -1,11 +1,11 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal. * SENTENCE: [1] A sequence of decimal digit symbols (0 though 9) is a decimal integer literal.
NUMBER: 3 * NUMBER: 3
DESCRIPTION: Binary integer literals with long literal mark. * DESCRIPTION: Binary integer literals with long literal mark.
*/ */
val value_1 = 0b0L val value_1 = 0b0L
@@ -1,10 +1,10 @@
/* /*
KOTLIN CODEGEN BOX SPEC TEST (<!TEST_TYPE!>) * KOTLIN CODEGEN BOX SPEC TEST (<!TEST_TYPE!>)
*
SECTIONS: <!SECTIONS!> * SECTIONS: <!SECTIONS!>
PARAGRAPH: <!PARAGRAPH_NUMBER!> * PARAGRAPH: <!PARAGRAPH_NUMBER!>
SENTENCE: [<!SENTENCE_NUMBER!>] <!SENTENCE!> * SENTENCE: [<!SENTENCE_NUMBER!>] <!SENTENCE!>
NUMBER: <!TEST_NUMBER!> * NUMBER: <!TEST_NUMBER!>
DESCRIPTION: <!TEST_DESCRIPTION!> * DESCRIPTION: <!TEST_DESCRIPTION!>
NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
@@ -1,9 +1,9 @@
/* /*
KOTLIN NOT LINKED CODEGEN BOX SPEC TEST (<!TEST_TYPE!>) * KOTLIN NOT LINKED CODEGEN BOX SPEC TEST (<!TEST_TYPE!>)
*
SECTION: <!SECTION!> * SECTION: <!SECTION!>
CATEGORIES: <!CATEGORIES!> * CATEGORIES: <!CATEGORIES!>
NUMBER: <!TEST_NUMBER!> * NUMBER: <!TEST_NUMBER!>
DESCRIPTION: <!TEST_DESCRIPTION!> * DESCRIPTION: <!TEST_DESCRIPTION!>
NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY! * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
*/ */
-136
View File
@@ -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:
* `<sectionName>`
* `p-<paragraphNumber>`
* `<neg|pos>`
* `<setenceNumber>.<testNumber>.kt` (test source code)
* `<setenceNumber>.<testNumber>.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 (<POSITIVE|NEGATIVE>)
SECTIONS: <sectionNames{,}>
PARAGRAPH: <paragraphNumber>
SENTENCE: [<setenceNumber>] <setence>
NUMBER: <testNumber>
DESCRIPTION: <testDescription>
*/
```
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: <caseDescription>
```
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 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.n
is Sum -> <!DEBUG_INFO_SMARTCAST!>expr<!>.e1 + <!DEBUG_INFO_SMARTCAST!>expr<!>.e2
is Mul -> <!DEBUG_INFO_SMARTCAST!>expr<!>.m1 + <!DEBUG_INFO_SMARTCAST!>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 <POSITIVE|NEGATIVE> SPEC TEST
SECTIONS: <sectionName> (paragraph: <paragraphNumber>)
SENTENCE <sentenceNumber>: <sentence>
TEST NUMBER: <testNumber>
TEST CASES: <casesNumber>
DESCRIPTION: <testDescription>
DIAGNOSTICS: <diagnosticSeverities> | <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
```
@@ -1,12 +1,15 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, binary-integer-literals * SECTIONS: constant-literals, integer-literals, binary-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal. * SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Binary integer literals with the prefix only. * DESCRIPTION: Binary integer literals with the prefix only.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0b<!> val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0b<!>
// TESTCASE NUMBER: 2
val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0B<!> val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0B<!>
@@ -1,14 +1,21 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, binary-integer-literals * SECTIONS: constant-literals, integer-literals, binary-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Binary integer literals with an underscore after the prefix. * DESCRIPTION: Binary integer literals with an underscore after the prefix.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!ILLEGAL_UNDERSCORE!>0b_1110100000<!> val value_1 = <!ILLEGAL_UNDERSCORE!>0b_1110100000<!>
// TESTCASE NUMBER: 2
val value_2 = <!ILLEGAL_UNDERSCORE!>0B_______11010000<!> val value_2 = <!ILLEGAL_UNDERSCORE!>0B_______11010000<!>
// TESTCASE NUMBER: 3
val value_3 = <!ILLEGAL_UNDERSCORE!>0B_1_1_0_1_0_0_0_0<!> val value_3 = <!ILLEGAL_UNDERSCORE!>0B_1_1_0_1_0_0_0_0<!>
// TESTCASE NUMBER: 4
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!> val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!>
@@ -1,21 +1,42 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, binary-integer-literals * SECTIONS: constant-literals, integer-literals, binary-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 2
DESCRIPTION: Binary integer literals with an underscore in the first position (it's considered as identifiers). * DESCRIPTION: Binary integer literals with an underscore in the first position (it's considered as identifiers).
*/ */
val value_0 = <!UNRESOLVED_REFERENCE!>_____0b0_1_1_1_0_1<!> // TESTCASE NUMBER: 1
val value_1 = <!UNRESOLVED_REFERENCE!>_0B1_______1_______1_______0<!> val value_1 = <!UNRESOLVED_REFERENCE!>_____0b0_1_1_1_0_1<!>
val value_2 = <!UNRESOLVED_REFERENCE!>_0_0B1_0_1_1_1_0_1_1<!>
val value_3 = <!UNRESOLVED_REFERENCE!>_0B000000000<!> // TESTCASE NUMBER: 2
val value_4 = <!UNRESOLVED_REFERENCE!>_0000000000b<!> val value_2 = <!UNRESOLVED_REFERENCE!>_0B1_______1_______1_______0<!>
val value_5 = <!UNRESOLVED_REFERENCE!>_0_1b<!>
val value_6 = <!UNRESOLVED_REFERENCE!>____________0b<!> // TESTCASE NUMBER: 3
val value_7 = <!UNRESOLVED_REFERENCE!>_0_b_0<!> val value_3 = <!UNRESOLVED_REFERENCE!>_0_0B1_0_1_1_1_0_1_1<!>
val value_8 = <!UNRESOLVED_REFERENCE!>_b_0<!>
val value_9 = <!UNRESOLVED_REFERENCE!>_b<!> // TESTCASE NUMBER: 4
val value_10 = <!UNRESOLVED_REFERENCE!>_b_<!> val value_4 = <!UNRESOLVED_REFERENCE!>_0B000000000<!>
// TESTCASE NUMBER: 5
val value_5 = <!UNRESOLVED_REFERENCE!>_0000000000b<!>
// TESTCASE NUMBER: 6
val value_6 = <!UNRESOLVED_REFERENCE!>_0_1b<!>
// TESTCASE NUMBER: 7
val value_7 = <!UNRESOLVED_REFERENCE!>____________0b<!>
// TESTCASE NUMBER: 8
val value_8 = <!UNRESOLVED_REFERENCE!>_0_b_0<!>
// TESTCASE NUMBER: 9
val value_9 = <!UNRESOLVED_REFERENCE!>_b_0<!>
// TESTCASE NUMBER: 10
val value_10 = <!UNRESOLVED_REFERENCE!>_b<!>
// TESTCASE NUMBER: 12
val value_12 = <!UNRESOLVED_REFERENCE!>_b_<!>
@@ -1,13 +1,13 @@
package package
public val value_0: [ERROR : Type for _____0b0_1_1_1_0_1] public val value_1: [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_10: [ERROR : Type for _b_] public val value_12: [ERROR : Type for _b_]
public val value_2: [ERROR : Type for _0_0B1_0_1_1_1_0_1_1] public val value_2: [ERROR : Type for _0B1_______1_______1_______0]
public val value_3: [ERROR : Type for _0B000000000] public val value_3: [ERROR : Type for _0_0B1_0_1_1_1_0_1_1]
public val value_4: [ERROR : Type for _0000000000b] public val value_4: [ERROR : Type for _0B000000000]
public val value_5: [ERROR : Type for _0_1b] public val value_5: [ERROR : Type for _0000000000b]
public val value_6: [ERROR : Type for ____________0b] public val value_6: [ERROR : Type for _0_1b]
public val value_7: [ERROR : Type for _0_b_0] public val value_7: [ERROR : Type for ____________0b]
public val value_8: [ERROR : Type for _b_0] public val value_8: [ERROR : Type for _0_b_0]
public val value_9: [ERROR : Type for _b] public val value_9: [ERROR : Type for _b_0]
@@ -1,17 +1,30 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, binary-integer-literals * SECTIONS: constant-literals, integer-literals, binary-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 3
DESCRIPTION: Binary integer literals with an underscore in the last position. * DESCRIPTION: Binary integer literals with an underscore in the last position.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!ILLEGAL_UNDERSCORE!>0b0_1_1_0_1_1_____<!> val value_1 = <!ILLEGAL_UNDERSCORE!>0b0_1_1_0_1_1_____<!>
// TESTCASE NUMBER: 2
val value_2 = <!ILLEGAL_UNDERSCORE!>0B1_______1_______0_______1_<!> val value_2 = <!ILLEGAL_UNDERSCORE!>0B1_______1_______0_______1_<!>
// TESTCASE NUMBER: 3
val value_3 = <!ILLEGAL_UNDERSCORE!>0B000000000_<!> val value_3 = <!ILLEGAL_UNDERSCORE!>0B000000000_<!>
// TESTCASE NUMBER: 4
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!> val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!>
// TESTCASE NUMBER: 5
val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B______________<!> val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B______________<!>
// TESTCASE NUMBER: 6
val value_6 = <!ILLEGAL_UNDERSCORE!>0B0_<!> val value_6 = <!ILLEGAL_UNDERSCORE!>0B0_<!>
// TESTCASE NUMBER: 7
val value_7 = <!ILLEGAL_UNDERSCORE!>0B10_<!> val value_7 = <!ILLEGAL_UNDERSCORE!>0B10_<!>
@@ -1,15 +1,24 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, decimal-integer-literals * SECTIONS: constant-literals, integer-literals, decimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Integer literals with an underscore in the last position. * DESCRIPTION: Integer literals with an underscore in the last position.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!ILLEGAL_UNDERSCORE!>1_<!> val value_1 = <!ILLEGAL_UNDERSCORE!>1_<!>
// TESTCASE NUMBER: 2
val value_2 = <!ILLEGAL_UNDERSCORE!>1_00000000000000000_<!> val value_2 = <!ILLEGAL_UNDERSCORE!>1_00000000000000000_<!>
// TESTCASE NUMBER: 3
val value_3 = <!ILLEGAL_UNDERSCORE!>1_____________<!> val value_3 = <!ILLEGAL_UNDERSCORE!>1_____________<!>
// TESTCASE NUMBER: 4
val value_4 = <!ILLEGAL_UNDERSCORE!>9____________0_<!> val value_4 = <!ILLEGAL_UNDERSCORE!>9____________0_<!>
// TESTCASE NUMBER: 5
val value_5 = <!ILLEGAL_UNDERSCORE!>1_______________________________________________________________________________________________________________________________________________________<!> val value_5 = <!ILLEGAL_UNDERSCORE!>1_______________________________________________________________________________________________________________________________________________________<!>
@@ -1,18 +1,33 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, decimal-integer-literals * SECTIONS: constant-literals, integer-literals, decimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 2
DESCRIPTION: Integer literals with an underscore in the first position (it's considered as identifiers). * DESCRIPTION: Integer literals with an underscore in the first position (it's considered as identifiers).
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!UNRESOLVED_REFERENCE!>_5678_90<!> val value_1 = <!UNRESOLVED_REFERENCE!>_5678_90<!>
// TESTCASE NUMBER: 2
val value_2 = <!UNRESOLVED_REFERENCE!>_2_3_4_5_6_7_8_9_<!> val value_2 = <!UNRESOLVED_REFERENCE!>_2_3_4_5_6_7_8_9_<!>
// TESTCASE NUMBER: 3
val value_3 = <!UNRESOLVED_REFERENCE!>_____________0000<!> val value_3 = <!UNRESOLVED_REFERENCE!>_____________0000<!>
// TESTCASE NUMBER: 4
val value_4 = <!UNRESOLVED_REFERENCE!>_______________________________________________________________________________________________________________________________________________________0<!> val value_4 = <!UNRESOLVED_REFERENCE!>_______________________________________________________________________________________________________________________________________________________0<!>
// TESTCASE NUMBER: 5
val value_5 = <!UNRESOLVED_REFERENCE!>____________________________________________________<!> val value_5 = <!UNRESOLVED_REFERENCE!>____________________________________________________<!>
// TESTCASE NUMBER: 6
val value_6 = <!UNRESOLVED_REFERENCE!>_<!> val value_6 = <!UNRESOLVED_REFERENCE!>_<!>
// TESTCASE NUMBER: 7
val value_7 = <!UNRESOLVED_REFERENCE!>_0_<!> val value_7 = <!UNRESOLVED_REFERENCE!>_0_<!>
// TESTCASE NUMBER: 8
val value_8 = <!UNRESOLVED_REFERENCE!>_9_<!> val value_8 = <!UNRESOLVED_REFERENCE!>_9_<!>
@@ -1,12 +1,15 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Hexadecimal integer literals with the prefix only. * DESCRIPTION: Hexadecimal integer literals with the prefix only.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0x<!> val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0x<!>
// TESTCASE NUMBER: 2
val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0X<!> val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0X<!>
@@ -1,14 +1,21 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Hexadecimal integer literals with an underscore after the prefix. * DESCRIPTION: Hexadecimal integer literals with an underscore after the prefix.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!ILLEGAL_UNDERSCORE!>0x_1234567890<!> val value_1 = <!ILLEGAL_UNDERSCORE!>0x_1234567890<!>
// TESTCASE NUMBER: 2
val value_2 = <!ILLEGAL_UNDERSCORE!>0X_______23456789<!> val value_2 = <!ILLEGAL_UNDERSCORE!>0X_______23456789<!>
// TESTCASE NUMBER: 3
val value_3 = <!ILLEGAL_UNDERSCORE!>0X_2_3_4_5_6_7_8_9<!> val value_3 = <!ILLEGAL_UNDERSCORE!>0X_2_3_4_5_6_7_8_9<!>
// TESTCASE NUMBER: 4
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_<!> val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_<!>
@@ -1,21 +1,42 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 2
DESCRIPTION: Hexadecimal integer literals with an underscore in the first position (it's considered as identifiers). * DESCRIPTION: Hexadecimal integer literals with an underscore in the first position (it's considered as identifiers).
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!UNRESOLVED_REFERENCE!>_____0x3_4_5_6_7_8<!> val value_1 = <!UNRESOLVED_REFERENCE!>_____0x3_4_5_6_7_8<!>
// TESTCASE NUMBER: 2
val value_2 = <!UNRESOLVED_REFERENCE!>_0X4_______5_______6_______7<!> val value_2 = <!UNRESOLVED_REFERENCE!>_0X4_______5_______6_______7<!>
// TESTCASE NUMBER: 3
val value_3 = <!UNRESOLVED_REFERENCE!>_0_0X4_3_4_5_6_7_8_9<!> val value_3 = <!UNRESOLVED_REFERENCE!>_0_0X4_3_4_5_6_7_8_9<!>
// TESTCASE NUMBER: 4
val value_4 = <!UNRESOLVED_REFERENCE!>_0X000000000<!> val value_4 = <!UNRESOLVED_REFERENCE!>_0X000000000<!>
// TESTCASE NUMBER: 5
val value_5 = <!UNRESOLVED_REFERENCE!>_0000000000x<!> val value_5 = <!UNRESOLVED_REFERENCE!>_0000000000x<!>
// TESTCASE NUMBER: 6
val value_6 = <!UNRESOLVED_REFERENCE!>_0_9x<!> val value_6 = <!UNRESOLVED_REFERENCE!>_0_9x<!>
// TESTCASE NUMBER: 7
val value_7 = <!UNRESOLVED_REFERENCE!>____________0x<!> val value_7 = <!UNRESOLVED_REFERENCE!>____________0x<!>
// TESTCASE NUMBER: 8
val value_8 = <!UNRESOLVED_REFERENCE!>_0_x_0<!> val value_8 = <!UNRESOLVED_REFERENCE!>_0_x_0<!>
// TESTCASE NUMBER: 9
val value_9 = <!UNRESOLVED_REFERENCE!>_x_0<!> val value_9 = <!UNRESOLVED_REFERENCE!>_x_0<!>
// TESTCASE NUMBER: 10
val value_10 = <!UNRESOLVED_REFERENCE!>_x<!> val value_10 = <!UNRESOLVED_REFERENCE!>_x<!>
// TESTCASE NUMBER: 11
val value_11 = <!UNRESOLVED_REFERENCE!>_x_<!> val value_11 = <!UNRESOLVED_REFERENCE!>_x_<!>
@@ -1,17 +1,30 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals * SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 3
DESCRIPTION: Hexadecimal integer literals with an underscore in the last position. * DESCRIPTION: Hexadecimal integer literals with an underscore in the last position.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!ILLEGAL_UNDERSCORE!>0x3_4_5_6_7_8_____<!> val value_1 = <!ILLEGAL_UNDERSCORE!>0x3_4_5_6_7_8_____<!>
// TESTCASE NUMBER: 2
val value_2 = <!ILLEGAL_UNDERSCORE!>0X4_______5_______6_______7_<!> val value_2 = <!ILLEGAL_UNDERSCORE!>0X4_______5_______6_______7_<!>
// TESTCASE NUMBER: 3
val value_3 = <!ILLEGAL_UNDERSCORE!>0X000000000_<!> val value_3 = <!ILLEGAL_UNDERSCORE!>0X000000000_<!>
// TESTCASE NUMBER: 5
val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_<!> val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_<!>
// TESTCASE NUMBER: 6
val value_6 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0X______________<!> val value_6 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0X______________<!>
// TESTCASE NUMBER: 7
val value_7 = <!ILLEGAL_UNDERSCORE!>0X0_<!> val value_7 = <!ILLEGAL_UNDERSCORE!>0X0_<!>
// TESTCASE NUMBER: 8
val value_8 = <!ILLEGAL_UNDERSCORE!>0X10_<!> val value_8 = <!ILLEGAL_UNDERSCORE!>0X10_<!>
@@ -1,19 +1,33 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L).
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Binary and hexadecimal integer literals with a long literal mark only. * DESCRIPTION: Binary and hexadecimal integer literals with a long literal mark only.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0bl<!> val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0bl<!>
// TESTCASE NUMBER: 2
val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0BL<!> val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0BL<!>
// TESTCASE NUMBER: 3
val value_3 = <!INT_LITERAL_OUT_OF_RANGE!>0Xl<!> val value_3 = <!INT_LITERAL_OUT_OF_RANGE!>0Xl<!>
// TESTCASE NUMBER: 4
val value_4 = <!INT_LITERAL_OUT_OF_RANGE!>0xL<!> val value_4 = <!INT_LITERAL_OUT_OF_RANGE!>0xL<!>
// TESTCASE NUMBER: 5
val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_l<!> val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_l<!>
// TESTCASE NUMBER: 6
val value_6 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B_L<!> val value_6 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B_L<!>
// TESTCASE NUMBER: 7
val value_7 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0X____l<!> val value_7 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0X____l<!>
// TESTCASE NUMBER: 8
val value_8 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_L<!> val value_8 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_L<!>
@@ -1,14 +1,21 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L).
NUMBER: 2 * NUMBER: 2
DESCRIPTION: Various integer literals with a not allowed underscore before the long literal mark. * DESCRIPTION: Various integer literals with a not allowed underscore before the long literal mark.
*/ */
// TESTCASE NUMBER: 1
val value_1 = <!ILLEGAL_UNDERSCORE!>0b0_<!WRONG_LONG_SUFFIX!>l<!><!> val value_1 = <!ILLEGAL_UNDERSCORE!>0b0_<!WRONG_LONG_SUFFIX!>l<!><!>
// TESTCASE NUMBER: 2
val value_2 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B12_L<!> val value_2 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B12_L<!>
// TESTCASE NUMBER: 3
val value_3 = <!ILLEGAL_UNDERSCORE!>0X234_<!WRONG_LONG_SUFFIX!>l<!><!> val value_3 = <!ILLEGAL_UNDERSCORE!>0X234_<!WRONG_LONG_SUFFIX!>l<!><!>
// TESTCASE NUMBER: 4
val value_4 = <!ILLEGAL_UNDERSCORE!>0x3567_L<!> val value_4 = <!ILLEGAL_UNDERSCORE!>0x3567_L<!>
@@ -1,14 +1,21 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * PARAGRAPH: 1
SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L). * SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L).
NUMBER: 3 * NUMBER: 3
DESCRIPTION: Various integer literals with not allowed long literal mark in lower case. * DESCRIPTION: Various integer literals with not allowed long literal mark in lower case.
*/ */
// TESTCASE NUMBER: 1
val value_1 = 0<!WRONG_LONG_SUFFIX!>l<!> val value_1 = 0<!WRONG_LONG_SUFFIX!>l<!>
// TESTCASE NUMBER: 2
val value_2 = 1000000000000000<!WRONG_LONG_SUFFIX!>l<!> val value_2 = 1000000000000000<!WRONG_LONG_SUFFIX!>l<!>
// TESTCASE NUMBER: 3
val value_3 = 0X0<!WRONG_LONG_SUFFIX!>l<!> val value_3 = 0X0<!WRONG_LONG_SUFFIX!>l<!>
// TESTCASE NUMBER: 4
val value_4 = 0b101<!WRONG_LONG_SUFFIX!>l<!> val value_4 = 0b101<!WRONG_LONG_SUFFIX!>l<!>
@@ -2,15 +2,16 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Various integer literals with not allowed long literal mark in lower case (type checking). * DESCRIPTION: Various integer literals with not allowed long literal mark in lower case (type checking).
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() } 0<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
10000000000000<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() } 10000000000000<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
@@ -2,15 +2,16 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 2
DESCRIPTION: Type checking (comparison with invalid types) of various integer literals with long literal mark. * DESCRIPTION: Type checking (comparison with invalid types) of various integer literals with long literal mark.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0L checkType { <!TYPE_MISMATCH!>_<!><Short>() } 0L checkType { <!TYPE_MISMATCH!>_<!><Short>() }
1000000L checkType { <!TYPE_MISMATCH!>_<!><Int>() } 1000000L checkType { <!TYPE_MISMATCH!>_<!><Int>() }
@@ -2,20 +2,24 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 3
DESCRIPTION: Type checking (comparison with invalid types) of various integer literals. * DESCRIPTION: Type checking (comparison with invalid types) of various integer literals.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } 0 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
0 checkType { <!TYPE_MISMATCH!>_<!><Short>() } 0 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
0 checkType { <!TYPE_MISMATCH!>_<!><Long>() } 0 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
}
// TESTCASE NUMBER: 2
fun case_2() {
127 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } 127 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
127 checkType { <!TYPE_MISMATCH!>_<!><Short>() } 127 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
127 checkType { <!TYPE_MISMATCH!>_<!><Long>() } 127 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
@@ -33,7 +37,10 @@ fun case_1() {
-129 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } -129 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
-129 checkType { <!TYPE_MISMATCH!>_<!><Short>() } -129 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
-129 checkType { <!TYPE_MISMATCH!>_<!><Long>() } -129 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
}
// TESTCASE NUMBER: 3
fun case_3() {
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32767<!>) checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32767<!>)
32767 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } 32767 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
32767 checkType { <!TYPE_MISMATCH!>_<!><Short>() } 32767 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
@@ -55,7 +62,10 @@ fun case_1() {
-32769 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } -32769 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
-32769 checkType { <!TYPE_MISMATCH!>_<!><Short>() } -32769 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
-32769 checkType { <!TYPE_MISMATCH!>_<!><Long>() } -32769 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
}
// TESTCASE NUMBER: 4
fun case_4() {
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>) checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>)
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>) checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>)
2147483647 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } 2147483647 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
@@ -81,7 +91,10 @@ fun case_1() {
-2147483649 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } -2147483649 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
-2147483649 checkType { <!TYPE_MISMATCH!>_<!><Short>() } -2147483649 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
-2147483649 checkType { <!TYPE_MISMATCH!>_<!><Int>() } -2147483649 checkType { <!TYPE_MISMATCH!>_<!><Int>() }
}
// TESTCASE NUMBER: 5
fun case_5() {
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>) checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>) checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>) checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
@@ -95,7 +108,10 @@ fun case_1() {
-9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Byte>() } -9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
-9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Short>() } -9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
-9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Int>() } -9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Int>() }
}
// TESTCASE NUMBER: 6
fun case_6() {
checkSubtype<Byte>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>) checkSubtype<Byte>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>)
checkSubtype<Short>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>) checkSubtype<Short>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>)
checkSubtype<Int>(-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!>) checkSubtype<Int>(-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!>)
@@ -2,22 +2,26 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 4
DESCRIPTION: Type checking (comparison with invalid types) of too a big integers. * DESCRIPTION: Type checking (comparison with invalid types) of too a big integers.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
checkSubtype<Long>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!><!>) checkSubtype<Long>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!><!>)
-<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() } -<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!>) checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!>)
<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() } <!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
}
// TESTCASE NUMBER: 2
fun case_2() {
checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!>) checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!>)
<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() } <!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
@@ -2,31 +2,33 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 5
DESCRIPTION: Check of integer type selection depends on the context (incopatible types). * DESCRIPTION: Check of integer type selection depends on the context (incopatible types).
*/ */
// FILE: functions.kt // FILE: functions.kt
package functions package functions
// TESTCASE NUMBER: 1
fun f1(x1: Byte) = x1 fun f1(x1: Byte) = x1
// TESTCASE NUMBER: 2
fun f2(x1: Short) = x1 fun f2(x1: Short) = x1
// TESTCASE NUMBER: 3, 4
fun f3(x1: Int) = x1 fun f3(x1: Int) = x1
fun f4(x1: Long) = x1 // FILE: main.kt
// FILE: usages.kt
import functions.* import functions.*
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
f1(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>128<!>) f1(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>128<!>)
f1(<!TYPE_MISMATCH!>-129<!>) f1(<!TYPE_MISMATCH!>-129<!>)
@@ -40,6 +42,7 @@ fun case_1() {
f1(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!><!>) f1(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!><!>)
} }
// TESTCASE NUMBER: 2
fun case_2() { fun case_2() {
f2(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32768<!>) f2(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32768<!>)
f2(<!TYPE_MISMATCH!>-32769<!>) f2(<!TYPE_MISMATCH!>-32769<!>)
@@ -51,6 +54,7 @@ fun case_2() {
f2(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!><!>) f2(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!><!>)
} }
// TESTCASE NUMBER: 3
fun case_3() { fun case_3() {
f3(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>) f3(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
f3(<!TYPE_MISMATCH!>-9223372036854775807<!>) f3(<!TYPE_MISMATCH!>-9223372036854775807<!>)
@@ -58,6 +62,7 @@ fun case_3() {
f3(-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>) f3(-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
} }
// TESTCASE NUMBER: 4
fun case_4() { fun case_4() {
f3(<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>) f3(<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
f3(-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>) f3(-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
@@ -2,15 +2,16 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 1
DESCRIPTION: Type checking of various integer literals with long literal mark. * DESCRIPTION: Type checking of various integer literals with long literal mark.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0L checkType { _<Long>() } 0L checkType { _<Long>() }
10000000000000L checkType { _<Long>() } 10000000000000L checkType { _<Long>() }
@@ -20,6 +21,7 @@ fun case_1() {
0b0L checkType { _<Long>() } 0b0L checkType { _<Long>() }
} }
// TESTCASE NUMBER: 2
fun case_2() { fun case_2() {
9223372036854775807L checkType { _<Long>() } 9223372036854775807L checkType { _<Long>() }
-9223372036854775807L checkType { _<Long>() } -9223372036854775807L checkType { _<Long>() }
@@ -2,22 +2,26 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 2
DESCRIPTION: Type checking of decimal integer literals. * DESCRIPTION: Type checking of decimal integer literals.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0 checkType { _<Int>() } 0 checkType { _<Int>() }
checkSubtype<Int>(0) checkSubtype<Int>(0)
checkSubtype<Short>(0) checkSubtype<Short>(0)
checkSubtype<Byte>(0) checkSubtype<Byte>(0)
checkSubtype<Long>(0) checkSubtype<Long>(0)
}
// TESTCASE NUMBER: 2
fun case_2() {
127 checkType { _<Int>() } 127 checkType { _<Int>() }
checkSubtype<Int>(127) checkSubtype<Int>(127)
checkSubtype<Short>(127) checkSubtype<Short>(127)
@@ -39,7 +43,10 @@ fun case_1() {
checkSubtype<Int>(-129) checkSubtype<Int>(-129)
checkSubtype<Short>(-129) checkSubtype<Short>(-129)
checkSubtype<Long>(-129) checkSubtype<Long>(-129)
}
// TESTCASE NUMBER: 3
fun case_3() {
32767 checkType { _<Int>() } 32767 checkType { _<Int>() }
checkSubtype<Int>(32767) checkSubtype<Int>(32767)
checkSubtype<Short>(32767) checkSubtype<Short>(32767)
@@ -57,7 +64,10 @@ fun case_1() {
-32769 checkType { _<Int>() } -32769 checkType { _<Int>() }
checkSubtype<Int>(-32769) checkSubtype<Int>(-32769)
checkSubtype<Long>(-32769) checkSubtype<Long>(-32769)
}
// TESTCASE NUMBER: 4
fun case_4() {
2147483647 checkType { _<Int>() } 2147483647 checkType { _<Int>() }
checkSubtype<Int>(2147483647) checkSubtype<Int>(2147483647)
checkSubtype<Long>(2147483647) checkSubtype<Long>(2147483647)
@@ -71,7 +81,10 @@ fun case_1() {
-2147483649 checkType { _<Long>() } -2147483649 checkType { _<Long>() }
checkSubtype<Long>(-2147483649) checkSubtype<Long>(-2147483649)
}
// TESTCASE NUMBER: 5
fun case_5() {
9223372036854775807 checkType { _<Long>() } 9223372036854775807 checkType { _<Long>() }
checkSubtype<Long>(9223372036854775807) checkSubtype<Long>(9223372036854775807)
@@ -2,22 +2,26 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 3
DESCRIPTION: Type checking of hexadecimal integer literals. * DESCRIPTION: Type checking of hexadecimal integer literals.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0x0 checkType { _<Int>() } 0x0 checkType { _<Int>() }
checkSubtype<Int>(0x0) checkSubtype<Int>(0x0)
checkSubtype<Short>(0x0) checkSubtype<Short>(0x0)
checkSubtype<Byte>(0x0) checkSubtype<Byte>(0x0)
checkSubtype<Long>(0x0) checkSubtype<Long>(0x0)
}
// TESTCASE NUMBER: 2
fun case_2() {
0x7F checkType { _<Int>() } 0x7F checkType { _<Int>() }
checkSubtype<Int>(0x7F) checkSubtype<Int>(0x7F)
checkSubtype<Short>(0x7F) checkSubtype<Short>(0x7F)
@@ -39,7 +43,10 @@ fun case_1() {
checkSubtype<Int>(-0x81) checkSubtype<Int>(-0x81)
checkSubtype<Short>(-0x81) checkSubtype<Short>(-0x81)
checkSubtype<Long>(-0x81) checkSubtype<Long>(-0x81)
}
// TESTCASE NUMBER: 3
fun case_3() {
0x7FFF checkType { _<Int>() } 0x7FFF checkType { _<Int>() }
checkSubtype<Int>(0x7FFF) checkSubtype<Int>(0x7FFF)
checkSubtype<Short>(0x7FFF) checkSubtype<Short>(0x7FFF)
@@ -57,7 +64,10 @@ fun case_1() {
-0X8001 checkType { _<Int>() } -0X8001 checkType { _<Int>() }
checkSubtype<Int>(-0X8001) checkSubtype<Int>(-0X8001)
checkSubtype<Long>(-0X8001) checkSubtype<Long>(-0X8001)
}
// TESTCASE NUMBER: 4
fun case_4() {
0x7FFFFFFF checkType { _<Int>() } 0x7FFFFFFF checkType { _<Int>() }
checkSubtype<Int>(0x7FFFFFFF) checkSubtype<Int>(0x7FFFFFFF)
checkSubtype<Long>(0x7FFFFFFF) checkSubtype<Long>(0x7FFFFFFF)
@@ -71,7 +81,10 @@ fun case_1() {
-0x80000001 checkType { _<Long>() } -0x80000001 checkType { _<Long>() }
checkSubtype<Long>(-0x80000001) checkSubtype<Long>(-0x80000001)
}
// TESTCASE NUMBER: 5
fun case_5() {
0X7FFFFFFFFFFFFFFF checkType { _<Long>() } 0X7FFFFFFFFFFFFFFF checkType { _<Long>() }
checkSubtype<Long>(0X7FFFFFFFFFFFFFFF) checkSubtype<Long>(0X7FFFFFFFFFFFFFFF)
@@ -2,22 +2,26 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 4
DESCRIPTION: Type checking of binary integer literals. * DESCRIPTION: Type checking of binary integer literals.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
0b0 checkType { _<Int>() } 0b0 checkType { _<Int>() }
checkSubtype<Int>(0b0) checkSubtype<Int>(0b0)
checkSubtype<Short>(0b0) checkSubtype<Short>(0b0)
checkSubtype<Byte>(0b0) checkSubtype<Byte>(0b0)
checkSubtype<Long>(0b0) checkSubtype<Long>(0b0)
}
// TESTCASE NUMBER: 2
fun case_2() {
0B1111111 checkType { _<Int>() } 0B1111111 checkType { _<Int>() }
checkSubtype<Int>(0B1111111) checkSubtype<Int>(0B1111111)
checkSubtype<Short>(0B1111111) checkSubtype<Short>(0B1111111)
@@ -39,7 +43,10 @@ fun case_1() {
checkSubtype<Int>(-0b10000001) checkSubtype<Int>(-0b10000001)
checkSubtype<Short>(-0b10000001) checkSubtype<Short>(-0b10000001)
checkSubtype<Long>(-0b10000001) checkSubtype<Long>(-0b10000001)
}
// TESTCASE NUMBER: 3
fun case_3() {
0B111111111111111 checkType { _<Int>() } 0B111111111111111 checkType { _<Int>() }
checkSubtype<Int>(0B111111111111111) checkSubtype<Int>(0B111111111111111)
checkSubtype<Short>(0B111111111111111) checkSubtype<Short>(0B111111111111111)
@@ -57,7 +64,10 @@ fun case_1() {
-0B1000000000000001 checkType { _<Int>() } -0B1000000000000001 checkType { _<Int>() }
checkSubtype<Int>(-0B1000000000000001) checkSubtype<Int>(-0B1000000000000001)
checkSubtype<Long>(-0B1000000000000001) checkSubtype<Long>(-0B1000000000000001)
}
// TESTCASE NUMBER: 4
fun case_4() {
0b1111111111111111111111111111111 checkType { _<Int>() } 0b1111111111111111111111111111111 checkType { _<Int>() }
checkSubtype<Int>(0b1111111111111111111111111111111) checkSubtype<Int>(0b1111111111111111111111111111111)
checkSubtype<Long>(0b1111111111111111111111111111111) checkSubtype<Long>(0b1111111111111111111111111111111)
@@ -71,7 +81,10 @@ fun case_1() {
-0b10000000000000000000000000000001 checkType { _<Long>() } -0b10000000000000000000000000000001 checkType { _<Long>() }
checkSubtype<Long>(-0b10000000000000000000000000000001) checkSubtype<Long>(-0b10000000000000000000000000000001)
}
// TESTCASE NUMBER: 5
fun case_5() {
0b111111111111111111111111111111111111111111111111111111111111111 checkType { _<Long>() } 0b111111111111111111111111111111111111111111111111111111111111111 checkType { _<Long>() }
checkSubtype<Long>(0b111111111111111111111111111111111111111111111111111111111111111) checkSubtype<Long>(0b111111111111111111111111111111111111111111111111111111111111111)
@@ -2,37 +2,43 @@
// SKIP_TXT // SKIP_TXT
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: constant-literals, integer-literals, long-integer-literals * SECTIONS: constant-literals, integer-literals, long-integer-literals
PARAGRAPH: 1 * 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. * 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 * NUMBER: 5
DESCRIPTION: Check of integer type selection depends on the context. * DESCRIPTION: Check of integer type selection depends on the context.
*/ */
// FILE: functions.kt // FILE: functions.kt
package functions package functions
// TESTCASE NUMBER: 1
fun f1(x1: Byte, x2: Short, x3: Int, x4: Long) = x1 + x2 + x3 + x4 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 fun f2(x1: Short, x2: Int, x3: Long) = x1 + x2 + x3
// TESTCASE NUMBER: 3
fun f3(x1: Int, x2: Long) = x1 + x2 fun f3(x1: Int, x2: Long) = x1 + x2
// TESTCASE NUMBER: 4
fun f4(x1: Long) = x1 fun f4(x1: Long) = x1
// FILE: usages.kt // FILE: main.kt
import functions.* import functions.*
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
f1(0, 0, 0, 0) f1(0, 0, 0, 0)
f1(127, 127, 127, 127) f1(127, 127, 127, 127)
f1(-128, -128, -128, -128) f1(-128, -128, -128, -128)
} }
// TESTCASE NUMBER: 2
fun case_2() { fun case_2() {
f2(128, 128, 128) f2(128, 128, 128)
f2(-129, -129, -129) f2(-129, -129, -129)
@@ -40,6 +46,7 @@ fun case_2() {
f2(-32768, -32768, -32768) f2(-32768, -32768, -32768)
} }
// TESTCASE NUMBER: 3
fun case_3() { fun case_3() {
f3(32768, 32768) f3(32768, 32768)
f3(-32769, -32769) f3(-32769, -32769)
@@ -47,6 +54,7 @@ fun case_3() {
f3(-2147483648, -2147483648) f3(-2147483648, -2147483648)
} }
// TESTCASE NUMBER: 4
fun case_4() { fun case_4() {
f4(2147483648) f4(2147483648)
f4(-2147483649) f4(-2147483649)
@@ -1,24 +1,24 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [1] It has an else entry; * SENTENCE: [1] It has an else entry;
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Checking for not exhaustive when without bound value when there is no else branch. * 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 = <!NO_ELSE_IN_WHEN!>when<!> { fun case_1(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 == 1 -> "" value_1 == 1 -> ""
value_1 == 2 -> "" value_1 == 2 -> ""
value_1 == 3 -> "" value_1 == 3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch). // TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> { fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 == 1 -> "" value_1 == 1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches). // TESTCASE NUMBER: 3
fun case_3(): Int = <!NO_ELSE_IN_WHEN!>when<!> {} fun case_3(): Int = <!NO_ELSE_IN_WHEN!>when<!> {}
@@ -1,26 +1,26 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION // !DIAGNOSTICS: -UNUSED_EXPRESSION
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [1] It has an else entry; * SENTENCE: [1] It has an else entry;
NUMBER: 2 * NUMBER: 2
DESCRIPTION: Checking for not exhaustive when with bound value when there is no else branch. * 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 = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { fun case_1(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
1 -> "" 1 -> ""
2 -> "" 2 -> ""
3 -> "" 3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch). // TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
1 -> "" 1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches). // TESTCASE NUMBER: 3
fun case_3(value_1: Int): Int = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {} fun case_3(value_1: Int): Int = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {}
@@ -1,38 +1,38 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION // !DIAGNOSTICS: -UNUSED_EXPRESSION
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: * SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' when not contains by all Boolean values or 'when' does not have bound value. * 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_1(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_2(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
false -> "" false -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (no branches). // TESTCASE NUMBER: 3
fun case_3(value_1: Boolean): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { } fun case_3(value_1: Boolean): Int = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!> { fun case_4(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 == true -> "" value_1 == true -> ""
value_1 == false -> "" value_1 == false -> ""
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' with both Boolean values covered, but using variables. * TESTCASE NUMBER: 5
DISCUSSION: maybe use const propagation here? * DISCUSSION: maybe use const propagation here?
ISSUES: KT-25265 * ISSUES: KT-25265
*/ */
fun case_5(value_1: Boolean): String { fun case_5(value_1: Boolean): String {
val trueValue = true val trueValue = true
@@ -2,55 +2,55 @@
// !WITH_SEALED_CLASSES // !WITH_SEALED_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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; * 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 * NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' when not covered by all possible subtypes or 'when' does not have bound value. * 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_1(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_2(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1, is _SealedChild2 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_3(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
_SealedMixedChildObject1 -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_4(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_SealedMixedChildObject1, is _SealedMixedChild2, is _SealedMixedChild1 -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_5(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { } fun case_6(value_1: _SealedClassMixed): Int = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { } fun case_7(value_1: _SealedClassSingleWithObject): Int = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { } fun case_8(value_1: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { fun case_9(value_1: Number): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Byte -> "" is Byte -> ""
is Double -> "" is Double -> ""
@@ -61,21 +61,21 @@ fun case_9(value_1: Number): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the Any. * TESTCASE NUMBER: 10
DISCUSSION: maybe make exhaustive without else? * DISCUSSION: maybe make exhaustive without else?
*/ */
fun case_10(value_1: Any): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { fun case_10(value_1: Any): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
<!USELESS_IS_CHECK!>is Any<!> -> "" <!USELESS_IS_CHECK!>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 = <!NO_ELSE_IN_WHEN!>when<!> { fun case_11(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 is _SealedChild1 -> "" value_1 is _SealedChild1 -> ""
value_1 is _SealedChild2 -> "" value_1 is _SealedChild2 -> ""
value_1 is _SealedChild3 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_12(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
@@ -2,42 +2,42 @@
// !WITH_ENUM_CLASSES // !WITH_ENUM_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; * SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Checking for not exhaustive when when not covered by all enumerated values. * 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_1(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
_EnumClass.NORTH -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_2(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST, _EnumClass.SOUTH, _EnumClass.NORTH -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_3(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { } fun case_4(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { } fun case_5(value_1: _EnumClassSingle): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' with all Enum values covered, but using variable. * TESTCASE NUMBER: 6
DISCUSSION: maybe use const propagation here? * DISCUSSION: maybe use const propagation here?
ISSUES: KT-25265 * ISSUES: KT-25265
*/ */
fun case_6(value_1: _EnumClass): String { fun case_6(value_1: _EnumClass): String {
val west = _EnumClass.WEST 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. * TESTCASE NUMBER: 7
DISCUSSION * DISCUSSION
ISSUES: KT-26044 * ISSUES: KT-26044
*/ */
fun case_7(value_1: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { } fun case_7(value_1: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { }
@@ -1,26 +1,26 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION // !DIAGNOSTICS: -UNUSED_EXPRESSION
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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. * 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 * NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean. * 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_1(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> "" true -> ""
false -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_2(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> "" true -> ""
null -> "" null -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without branches. // TESTCASE NUMBER: 3
fun case_3(value_1: Boolean?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { } fun case_3(value_1: Boolean?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
@@ -2,23 +2,23 @@
// !WITH_SEALED_CLASSES // !WITH_SEALED_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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. * 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 * NUMBER: 2
DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed). * 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_1(value_1: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
is _SealedChild3 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_2(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
@@ -26,12 +26,12 @@ fun case_2(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
null -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_3(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null, is _SealedMixedChild1, is _SealedMixedChild2, _SealedMixedChildObject1 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_4(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
@@ -41,17 +41,17 @@ fun case_4(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
_SealedMixedChildObject3 -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_5(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {} fun case_6(value_1: _SealedClassMixed?): Int = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_7(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2-> "" is _SealedMixedChild2-> ""
@@ -59,23 +59,23 @@ fun case_7(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
null -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_8(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_SealedMixedChildObject1 -> "" _SealedMixedChildObject1 -> ""
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable Any. * TESTCASE NUMBER: 9
DISCUSSION: maybe make exhaustive without else? * DISCUSSION: maybe make exhaustive without else?
*/ */
fun case_10(value_1: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { fun case_9(value_1: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Any -> "" is Any -> ""
null -> "" null -> ""
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes). * TESTCASE NUMBER: 10
DISCUSSION * DISCUSSION
ISSUES: KT-26044 * ISSUES: KT-26044
*/ */
fun case_11(value: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {} fun case_10(value: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {}
@@ -2,16 +2,16 @@
// !WITH_ENUM_CLASSES // !WITH_ENUM_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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. * 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 * NUMBER: 3
DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums. * 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_1(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
@@ -19,7 +19,7 @@ fun case_1(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.WEST -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_2(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
@@ -27,20 +27,20 @@ fun case_2(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> "" 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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_3(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST, null, _EnumClass.SOUTH, _EnumClass.NORTH -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {} fun case_4(value_1: _EnumClassSingle): Int = <!NO_ELSE_IN_WHEN!>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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_5(value_1: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClassSingle.EVERYTHING -> "" _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 = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_6(value_1: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> "" null -> ""
} }
@@ -1,14 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [1] It has an else entry; * SENTENCE: [1] It has an else entry;
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Check when exhaustive via else entry (when without bound value). * 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 { fun case_1(value_1: Int): String = when {
value_1 == 0 -> "" value_1 == 0 -> ""
value_1 > 0 && value_1 <= 10 -> "" value_1 > 0 && value_1 <= 10 -> ""
@@ -17,13 +17,13 @@ fun case_1(value_1: Int): String = when {
else -> "" else -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch). // TESTCASE NUMBER: 2
fun case_2(): String = when { fun case_2(): String = when {
true -> "" true -> ""
else -> "" else -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch). // TESTCASE NUMBER: 3
fun case_3(): String = when { fun case_3(): String = when {
else -> "" else -> ""
} }
@@ -1,16 +1,16 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION // !DIAGNOSTICS: -UNUSED_EXPRESSION
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [1] It has an else entry; * SENTENCE: [1] It has an else entry;
NUMBER: 2 * NUMBER: 2
DESCRIPTION: Check when exhaustive via else entry (when with bound value). * 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) { fun case_1(value_1: Int): String = when (value_1) {
0 -> "" 0 -> ""
1 -> "" 1 -> ""
@@ -19,22 +19,22 @@ fun case_1(value_1: Int): String = when (value_1) {
else -> "" 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) { fun case_2(value_1: Boolean): String = when (value_1) {
true -> "" true -> ""
else -> "" else -> ""
} }
/* /*
CASE DESCRIPTION: Checking for exhaustive 'when' with constant bound value (value check branch and 'else' branch). * TESTCASE NUMBER: 3
NOTE: for potential bound value constant analysis. * NOTE: for a potential bound value constant analysis.
*/ */
fun case_3(): String = when (true) { fun case_3(): String = when (true) {
true -> "" true -> ""
else -> "" else -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch). // TESTCASE NUMBER: 4
fun case_4(value_1: Int): String = when(value_1) { fun case_4(value_1: Int): String = when(value_1) {
else -> "" else -> ""
} }
@@ -2,16 +2,16 @@
// !WITH_SEALED_CLASSES // !WITH_SEALED_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [1] It has an else entry; * SENTENCE: [1] It has an else entry;
NUMBER: 3 * NUMBER: 3
DESCRIPTION: Check when exhaustive via else entry (when with bound value, redundant else). * 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) { fun case_1(value_1: _EnumClass): String = when (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -20,7 +20,7 @@ fun case_1(value_1: _EnumClass): String = when (value_1) {
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_2(value_1: _EnumClass?): String = when (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -30,14 +30,14 @@ fun case_2(value_1: _EnumClass?): String = when (value_1) {
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_3(value_1: Boolean): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_4(value_1: Boolean?): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
@@ -45,7 +45,7 @@ fun case_4(value_1: Boolean?): String = when (value_1) {
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_5(value_1: _SealedClass): String = when (value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
@@ -53,7 +53,7 @@ fun case_5(value_1: _SealedClass): String = when (value_1) {
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_6(value_1: _SealedClass?): String = when (value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
@@ -62,13 +62,13 @@ fun case_6(value_1: _SealedClass?): String = when (value_1) {
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_7(value_1: _SealedClassSingle): String = when (value_1) {
<!USELESS_IS_CHECK!>is _SealedClassSingle<!> -> "" <!USELESS_IS_CHECK!>is _SealedClassSingle<!> -> ""
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>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) { fun case_8(value_1: _SealedClassSingle?): String = when (value_1) {
is _SealedClassSingle -> "" is _SealedClassSingle -> ""
null -> "" null -> ""
@@ -1,20 +1,20 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: * SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Check when exhaustive via boolean bound value and evaluating to value true and false. * 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) { fun case_1(value_1: Boolean): String = when (value_1) {
true -> "" true -> ""
false -> "" 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) { fun case_2(value_1: Boolean): String = when (value_1) {
true && false && ((true || false)) || true && !!!false && !!!true -> "" true && false && ((true || false)) || true && !!!false && !!!true -> ""
true && false && ((true || false)) || true && !!!false -> "" true && false && ((true || false)) || true && !!!false -> ""
@@ -2,42 +2,42 @@
// !WITH_SEALED_CLASSES // !WITH_SEALED_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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; * 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 * NUMBER: 1
DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered. * 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) { fun case_1(value_1: _SealedClass): Int = when (value_1) {
is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number
is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.e2 is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.e2
is _SealedChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2 is _SealedChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1 + <!DEBUG_INFO_SMARTCAST!>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) { fun case_2(value_1: _SealedClass): String = when (value_1) {
<!USELESS_IS_CHECK!>is _SealedClass<!> -> "" <!USELESS_IS_CHECK!>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) { fun case_3(value_1: _SealedClassWithMethods): String = when (value_1) {
is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1() is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1()
is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2() is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2()
is _SealedWithMethodsChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m3() is _SealedWithMethodsChild3 -> <!DEBUG_INFO_SMARTCAST!>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) { fun case_4(value_1: _SealedClassWithObjects): String = when (value_1) {
_SealedWithObjectsChild1 -> "" _SealedWithObjectsChild1 -> ""
_SealedWithObjectsChild2 -> "" _SealedWithObjectsChild2 -> ""
_SealedWithObjectsChild3 -> "" _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) { fun case_5(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" 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). * TESTCASE NUMBER: 6
DISCUSSION: is it correct that objects can be checked using the type checking operator? * DISCUSSION: is it correct that objects can be checked using the type checking operator?
*/ */
fun case_6(value_1: _SealedClassMixed): String = when (value_1) { fun case_6(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
@@ -60,24 +60,24 @@ fun case_6(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChildObject3 -> "" 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) { fun case_7(value_1: _SealedClassEmpty): String = when (value_1) {
else -> "" else -> ""
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types. * TESTCASE NUMBER: 8
UNEXPECTED BEHAVIOUR: must be exhaustive * UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996 * ISSUES: KT-22996
*/ */
fun case_8(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_8(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3?, <!USELESS_IS_CHECK!>is _SealedChild3?<!> -> "" is _SealedChild1, !is _SealedChild3?, <!USELESS_IS_CHECK!>is _SealedChild3?<!> -> ""
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types. * TESTCASE NUMBER: 9
UNEXPECTED BEHAVIOUR: must be exhaustive * UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996 * ISSUES: KT-22996
*/ */
fun case_9(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_9(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3 -> "" is _SealedChild1, !is _SealedChild3 -> ""
@@ -1,16 +1,16 @@
// !WITH_ENUM_CLASSES // !WITH_ENUM_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; * SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Check when exhaustive when all enumerated values are checked. * 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) { fun case_1(dir: _EnumClass): String = when (dir) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -18,7 +18,7 @@ fun case_1(dir: _EnumClass): String = when (dir) {
_EnumClass.WEST -> "" _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) { fun case_2(value_1: _EnumClassSingle): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> "" _EnumClassSingle.EVERYTHING -> ""
} }
@@ -1,21 +1,21 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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. * 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 * NUMBER: 1
DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check. * 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) { fun case_1(value_1: Boolean?): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
null -> "" 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) { fun case_2(value_1: Boolean?): String = when (value_1) {
true && false && ((true || false)) || true && !!!false && !!!true -> "" true && false && ((true || false)) || true && !!!false && !!!true -> ""
true && false && ((true || false)) || true && !!!false -> "" true && false && ((true || false)) || true && !!!false -> ""
@@ -1,16 +1,16 @@
// !WITH_ENUM_CLASSES // !WITH_ENUM_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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. * 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 * NUMBER: 2
DESCRIPTION: Check when exhaustive when enumerated values are checked and contains a null check. * 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) { fun case_1(value_1: _EnumClass?): String = when (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -19,16 +19,16 @@ fun case_1(value_1: _EnumClass?): String = when (value_1) {
null -> "" 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) { fun case_2(value_1: _EnumClassSingle?): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> "" _EnumClassSingle.EVERYTHING -> ""
null -> "" null -> ""
} }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable enum class. * TESTCASE NUMBER: 3
UNEXPECTED BEHAVIOUR * UNEXPECTED BEHAVIOUR
ISSUES: KT-26044 * ISSUES: KT-26044
*/ */
fun case_3(value_1: _EnumClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { fun case_3(value_1: _EnumClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> "" null -> ""
@@ -1,16 +1,16 @@
// !WITH_SEALED_CLASSES // !WITH_SEALED_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 11 * 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. * 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 * NUMBER: 3
DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check. * 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) { fun case_1(value_1: _SealedClass?): Int = when (value_1) {
is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number
is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.e2 is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.e2
@@ -18,13 +18,13 @@ fun case_1(value_1: _SealedClass?): Int = when (value_1) {
null -> 0 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) { fun case_2(value_1: _SealedClass?): String = when (value_1) {
is _SealedClass -> "" is _SealedClass -> ""
null -> "" 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) { fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) {
is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1() is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1()
is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2() is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2()
@@ -32,7 +32,7 @@ fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) {
null -> "" 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) { fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) {
_SealedWithObjectsChild1 -> "" _SealedWithObjectsChild1 -> ""
_SealedWithObjectsChild2 -> "" _SealedWithObjectsChild2 -> ""
@@ -40,7 +40,7 @@ fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) {
null -> "" 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) { fun case_5(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" 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). * TESTCASE NUMBER: 6
DISCUSSION: is it correct that objects can be checked using the type checking operator? * DISCUSSION: is it correct that objects can be checked using the type checking operator?
*/ */
fun case_6(value_1: _SealedClassMixed?): String = when (value_1) { fun case_6(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChild1 -> "" 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). * TESTCASE NUMBER: 7
UNEXPECTED BEHAVIOUR: must be exhaustive * UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-26044 * ISSUES: KT-26044
*/ */
fun case_7(value: _SealedClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_7(value: _SealedClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
null -> "" null -> ""
@@ -1,13 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 2 * PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it. * SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: Empty 'when' with bound value. * DESCRIPTION: Empty 'when' with bound value.
*/ */
// TESTCASE NUMBER: 1
fun case_1(value_1: Int) { fun case_1(value_1: Int) {
when (<!UNUSED_EXPRESSION!>value_1<!>) {} when (<!UNUSED_EXPRESSION!>value_1<!>) {}
} }
@@ -1,13 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 2 * PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it. * SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 2 * NUMBER: 2
DESCRIPTION: Empty 'when' without bound value. * DESCRIPTION: Empty 'when' without bound value.
*/ */
// TESTCASE NUMBER: 1
fun case_1() { fun case_1() {
when {} when {}
} }
@@ -1,14 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body. * 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 { fun case_1(value_1: Int): String {
while (true) { while (true) {
when { when {
@@ -19,7 +19,7 @@ fun case_1(value_1: Int): String {
return "" return ""
} }
// CASE DESCRIPTION: 'When' with continue expression (without label). // TESTCASE NUMBER: 2
fun case_2(value_1: Int): String { fun case_2(value_1: Int): String {
while (true) { while (true) {
when { when {
@@ -1,15 +1,16 @@
// !WITH_BASIC_TYPES // !WITH_BASIC_TYPES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'. * 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 { fun case_1(value_1: Int, value_2: String, value_3: _BasicTypesProvider): String {
when { when {
<!TYPE_MISMATCH!>.012f / value_1<!> -> return "" <!TYPE_MISMATCH!>.012f / value_1<!> -> return ""
@@ -1,15 +1,16 @@
// !WITH_BASIC_TYPES // !WITH_BASIC_TYPES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 2
DESCRIPTION: 'When' without bound value and not allowed comma in when entry. * DESCRIPTION: 'When' without bound value and not allowed comma in when entry.
*/ */
// TESTCASE NUMBER: 1
fun case_1(value_1: _BasicTypesProvider) { fun case_1(value_1: _BasicTypesProvider) {
when { when {
getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> value_1.getBoolean() -> return getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> value_1.getBoolean() -> return
@@ -4,16 +4,16 @@
// !WITH_FUNCTIONS // !WITH_FUNCTIONS
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' without bound value and with different variants of expressions in the control structure body. * 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) { fun case_1(value_1: Int) {
when { when {
value_1 == 1 -> true 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) { fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
when { when {
value_1 == 1 -> -.09 % 10L 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) { fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
when { when {
value_1 == 1 -> value_2 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) { fun case_4(value_1: Int, value_2: String, value_3: String) {
when { when {
value_1 == 1 -> "..." + value_2 + "" + "$value_3" + "..." 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?) { fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when { when {
value_1 == 1 -> 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 { fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when {
value_1 == 1 -> when { value_1 == 1 -> when {
value_2 > 1000 -> 1 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?) { fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
when { when {
value_1 == 1 -> if (value_2 > 1000) "1" 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 { fun case_8(value_1: Int, value_2: Int) = when {
value_1 == 1 -> if (value_2 > 1000) "1" value_1 == 1 -> if (value_2 > 1000) "1"
else "2" else "2"
@@ -118,14 +118,14 @@ fun case_8(value_1: Int, value_2: Int) = when {
else "4" 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 { fun case_9(value_1: Int, value_2: String, value_3: String) = when {
value_1 == 1 -> <!IMPLICIT_CAST_TO_ANY!>try { 4 } catch (e: Exception) { 5 }<!> value_1 == 1 -> <!IMPLICIT_CAST_TO_ANY!>try { 4 } catch (e: Exception) { 5 }<!>
value_1 == 2 -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { value_2 }<!> value_1 == 2 -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { value_2 }<!>
else -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { {value_3} } finally { }<!> else -> <!IMPLICIT_CAST_TO_ANY!>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?) { fun case_10(value_1: Int, value_2: String?, value_3: String?) {
when { when {
value_1 == 1 -> value_2 ?: true 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) { fun case_11(value_1: Int) {
when { when {
value_1 == 1 -> 1..10 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<Int>, value_3: Collection<Int>?) { fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when { when {
value_1 == 1 -> value_2 as MutableList<Int> value_1 == 1 -> value_2 as MutableList<Int>
@@ -153,7 +153,7 @@ fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
} }
} }
// 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) { fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) {
var mutablevalue_2 = value_2 var mutablevalue_2 = value_2
var mutablevalue_3 = value_3 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?) { fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
var mutablevalue_2 = value_2 var mutablevalue_2 = value_2
var mutablevalue_3 = value_3 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<Int>, value_3: List<List<List<List<Int>>>>) { fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when { when {
value_1 == 1 -> value_2[0] value_1 == 1 -> value_2[0]
@@ -185,7 +185,7 @@ fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>
} }
} }
// 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 case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Unit { return fun() { } } 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?) { fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
when { when {
value_1 == 1 -> value_2.prop_1 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) { fun case_18(value_1: Int) {
val fun_1 = fun(): Int { return 0 } 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 { fun case_19(value_1: Int): () -> Any {
val lambda_1 = { 0 } 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) { fun case_20(value_1: Int) {
val object_1 = object { val object_1 = object {
val prop_1 = 1 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 { class A {
val prop_1 = 1 val prop_1 = 1
val lambda_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) { fun case_22(value_1: Int) {
when { when {
value_1 == 1 -> throw Exception() 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 case_23(value_1: Int) {
fun r_1() { fun r_1() {
when { 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) { fun case_24(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ 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) { fun case_25(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
@@ -3,16 +3,16 @@
// !WITH_ENUM_CLASSES // !WITH_ENUM_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' without bound value and different variants of the boolean conditions (logical, equality, comparison, type checking operator, containment operator). * 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 { fun case_1(value_1: Boolean, value_2: Long): Int {
return when { return when {
value_1 -> 1 value_1 -> 1
@@ -26,8 +26,8 @@ fun case_1(value_1: Boolean, value_2: Long): Int {
} }
/* /*
CASE DESCRIPTION: 'When' with boolean expressions. * TESTCASE NUMBER: 2
NOTE: for potential analysys on exhaustive by enum of when without bound value. * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/ */
fun case_2(value_1: _EnumClass) { fun case_2(value_1: _EnumClass) {
when { when {
@@ -39,8 +39,8 @@ fun case_2(value_1: _EnumClass) {
} }
/* /*
CASE DESCRIPTION: 'When' with boolean expressions. * TESTCASE NUMBER: 3
NOTE: for potential analysys on exhaustive by boolean of when without bound value. * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/ */
fun case_3(value_1: Boolean) { fun case_3(value_1: Boolean) {
when { when {
@@ -50,8 +50,8 @@ fun case_3(value_1: Boolean) {
} }
/* /*
CASE DESCRIPTION: 'When' with boolean literals. * TESTCASE NUMBER: 4
NOTE: for potential mark code after true branch as unreacable. * NOTE: for a potential mark the code after the true branch as unreacable.
*/ */
fun case_4(value_1: Boolean) { fun case_4(value_1: Boolean) {
when { when {
@@ -62,8 +62,8 @@ fun case_4(value_1: Boolean) {
} }
/* /*
CASE DESCRIPTION: 'When' with boolean constants. * TESTCASE NUMBER: 5
NOTE: for potential const propagation use in this case. * NOTE: for a potential const propagation.
*/ */
fun case_5(value_1: Boolean) { fun case_5(value_1: Boolean) {
val value_2 = false 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) { fun case_6(value_1: Any) {
when { when {
value_1 is Nothing -> {} value_1 is Nothing -> {}
@@ -90,8 +90,8 @@ fun case_6(value_1: Any) {
} }
/* /*
CASE DESCRIPTION: 'When' with invert type checking operator. * TESTCASE NUMBER: 7
NOTE: for potential analysys on exhaustive of when without bound value_1. * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/ */
fun case_7(value_1: Any) { fun case_7(value_1: Any) {
when { when {
@@ -103,8 +103,8 @@ fun case_7(value_1: Any) {
} }
/* /*
CASE DESCRIPTION: 'When' with type checking operator by sealed class. * TESTCASE NUMBER: 8
NOTE: for potential analysys on exhaustive by sealed class of when without bound value_1. * NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/ */
fun case_8(value_1: _SealedClass) { fun case_8(value_1: _SealedClass) {
when { 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) { fun case_9(value_1: Int, value_2: IntRange) {
when { when {
value_1 in -10..100L -> {} value_1 in -10..100L -> {}
@@ -1,19 +1,19 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 2
DESCRIPTION: 'When' without bound value and only one 'else' branch. * 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 { fun case_1() = when {
else -> "" else -> ""
} }
// CASE DESCRIPTION: 'When' as statement with only one 'else' branch. // TESTCASE NUMBER: 2
fun case_2(): String { fun case_2(): String {
when { when {
else -> return "" else -> return ""
@@ -1,18 +1,18 @@
// !WITH_BASIC_TYPES // !WITH_BASIC_TYPES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 3 * 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. * 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 * NUMBER: 3
DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean). * DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean).
DISCUSSION * DISCUSSION
ISSUES: KT-25948 * ISSUES: KT-25948
*/ */
// CASE DESCRIPTION: 'When' with return expression in condition. // TESTCASE NUMBER: 1
fun case_1(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) { fun case_1(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
when { when {
return -> <!UNREACHABLE_CODE!>return<!> return -> <!UNREACHABLE_CODE!>return<!>
@@ -23,7 +23,7 @@ fun case_1(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
} }
} }
// CASE DESCRIPTION: 'When' with throw expression in condition. // TESTCASE NUMBER: 2
fun case_2(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) { fun case_2(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
when { when {
throw Exception() -> <!UNREACHABLE_CODE!>return<!> throw Exception() -> <!UNREACHABLE_CODE!>return<!>
@@ -34,7 +34,7 @@ fun case_2(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
} }
} }
// CASE DESCRIPTION: 'When' with break expression in condition. // TESTCASE NUMBER: 3
fun case_3(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) { fun case_3(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
@@ -49,7 +49,7 @@ fun case_3(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
} }
} }
// CASE DESCRIPTION: 'When' with continue expression in condition. // TESTCASE NUMBER: 4
fun case_4(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider): String { fun case_4(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider): String {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
@@ -64,7 +64,7 @@ fun case_4(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider): String {
} }
} }
// CASE DESCRIPTION: 'When' with values of Nothing type. // TESTCASE NUMBER: 6
fun case_6(value_1: Nothing, <!UNUSED_PARAMETER!>value_2<!>: _BasicTypesProvider): String { fun case_6(value_1: Nothing, <!UNUSED_PARAMETER!>value_2<!>: _BasicTypesProvider): String {
when { when {
value_1 -> <!UNREACHABLE_CODE!>return ""<!> value_1 -> <!UNREACHABLE_CODE!>return ""<!>
@@ -76,7 +76,7 @@ fun case_6(value_1: Nothing, <!UNUSED_PARAMETER!>value_2<!>: _BasicTypesProvider
<!UNREACHABLE_CODE!>return ""<!> <!UNREACHABLE_CODE!>return ""<!>
} }
// CASE DESCRIPTION: 'When' with mixed Nothing expression in condition. // TESTCASE NUMBER: 5
fun case_5(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider, <!UNUSED_PARAMETER!>value_2<!>: Nothing) { fun case_5(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider, <!UNUSED_PARAMETER!>value_2<!>: Nothing) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
@@ -1,27 +1,27 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 5 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' without bound value and with 'else' branch not in the last position. * 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(<!UNUSED_PARAMETER!>value_1<!>: Int): String = when { fun case_1(<!UNUSED_PARAMETER!>value_1<!>: Int): String = when {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>value_1 == 1 -> ""<!> <!UNREACHABLE_CODE!>value_1 == 1 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with 'else' branch in the middle position. // TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = when { fun case_2(value_1: Int): String = when {
value_1 == 1 -> "" value_1 == 1 -> ""
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>value_1 == 2 -> ""<!> <!UNREACHABLE_CODE!>value_1 == 2 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with two 'else' branches. // TESTCASE NUMBER: 3
fun case_3(): String { fun case_3(): String {
when { when {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> return "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> return ""
@@ -1,14 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 5 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' without bound value and with else branch in the last position. * 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 { fun case_1(value_1: Int): String {
when { when {
value_1 == 1 -> return "" 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 { fun case_2(value_1: Int): String = when {
value_1 == 1 -> "" value_1 == 1 -> ""
value_1 == 2 -> "" value_1 == 2 -> ""
@@ -1,14 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 6 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in the control structure body. * 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 { fun case_1(value_1: Int): Int {
while (true) { while (true) {
when (value_1) { when (value_1) {
@@ -20,7 +20,7 @@ fun case_1(value_1: Int): Int {
return 0 return 0
} }
// CASE DESCRIPTION: 'When' with continue expression (without label). // TESTCASE NUMBER: 2
fun case_2(value_1: Int): Int { fun case_2(value_1: Int): Int {
while (true) { while (true) {
when (value_1) { when (value_1) {
@@ -4,16 +4,16 @@
// !WITH_CLASSES // !WITH_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 6 * 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. * 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 * NUMBER: 1
DESCRIPTION: 'When' with bound value and with different variants of expressions in the control structure body. * 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) { fun case_1(value_1: Int) {
when (value_1) { when (value_1) {
1 -> true 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) { fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
when (value_1) { when (value_1) {
1 -> -.09 % 10L 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) { fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
when (value_1) { when (value_1) {
1 -> value_2 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) { fun case_4(value_1: Int, value_2: String, value_3: String) {
when (value_1) { when (value_1) {
1 -> "..." + value_2 + "" + "$value_3" + "..." 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?) { fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value_1) { when (value_1) {
1 -> when (value_3) { 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) { fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when (value_1) {
1 -> when (value_3) { 1 -> when (value_3) {
value_2 > 1000 -> 1 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?) { fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value_1) { when (value_1) {
1 -> if (value_2 > 1000) "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) { fun case_8(value_1: Int, value_2: Int) = when (value_1) {
1 -> if (value_2 > 1000) "1" 1 -> if (value_2 > 1000) "1"
else "2" else "2"
@@ -119,7 +119,7 @@ fun case_8(value_1: Int, value_2: Int) = when (value_1) {
else "4" 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 { fun case_9(value_1: Int, value_2: String, value_3: String): Any {
return when (value_1) { return when (value_1) {
1 -> try { 4 } catch (e: Exception) { 5 } 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?) { fun case_10(value_1: Int, value_2: String?, value_3: String?) {
when (value_1) { when (value_1) {
1 -> value_2 ?: true 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) { fun case_11(value_1: Int) {
when (value_1) { when (value_1) {
1 -> 1..10 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<Int>, value_3: Collection<Int>?) { fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value_1) { when (value_1) {
1 -> value_2 as MutableList<Int> 1 -> value_2 as MutableList<Int>
@@ -156,7 +156,7 @@ fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
} }
} }
// 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) { fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value_2 var mutableValue1 = value_2
var mutableValue2 = value_3 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?) { fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
var mutableValue1 = value_2 var mutableValue1 = value_2
var mutableValue2 = value_3 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<Int>, value_3: List<List<List<List<Int>>>>) { fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value_1) { when (value_1) {
1 -> value_2[0] 1 -> value_2[0]
@@ -188,7 +188,7 @@ fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>
} }
} }
// 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 case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Unit { return fun() { } } 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?) { fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value_1) { when (value_1) {
1 -> value_2.prop_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) { fun case_18(value_1: Int) {
val fun_1 = fun(): Int { return 0 } 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 { fun case_19(value_1: Int): Any {
val lambda_1 = { 0 } 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) { fun case_20(value_1: Int) {
val object_1 = object { val object_1 = object {
val prop_1 = 1 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 { class A {
val prop_1 = 1 val prop_1 = 1
val lambda_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) { fun case_22(value_1: Int) {
when (value_1) { when (value_1) {
1 -> throw Exception() 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 case_23(value_1: Int) {
fun r_1() { fun r_1() {
when (value_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) { fun case_24(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ 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) { fun case_25(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
@@ -1,16 +1,16 @@
// !WITH_CLASSES // !WITH_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. * SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: 'When' with bound value and type test condition (without companion object in classes), but without type checking operator. * 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 { fun case_1(value_1: Any): String {
when (value_1) { when (value_1) {
<!NO_COMPANION_OBJECT!>_EmptyClass<!> -> return "" <!NO_COMPANION_OBJECT!>_EmptyClass<!> -> return ""
@@ -19,7 +19,7 @@ fun case_1(value_1: Any): String {
return "" return ""
} }
// CASE DESCRIPTION: 'When' with Any type test condition. // TESTCASE NUMBER: 2
fun case_2(value_1: Any): String { fun case_2(value_1: Any): String {
when (value_1) { when (value_1) {
<!NO_COMPANION_OBJECT!>Any<!> -> return "" <!NO_COMPANION_OBJECT!>Any<!> -> return ""
@@ -28,7 +28,7 @@ fun case_2(value_1: Any): String {
return "" return ""
} }
// CASE DESCRIPTION: 'When' with Nothing type test condition. // TESTCASE NUMBER: 3
fun case_3(value_1: Any): String { fun case_3(value_1: Any): String {
when (value_1) { when (value_1) {
<!NO_COMPANION_OBJECT!>Nothing<!> -> return "" <!NO_COMPANION_OBJECT!>Nothing<!> -> return ""
@@ -1,15 +1,16 @@
// !WITH_CLASSES // !WITH_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. * SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2 * NUMBER: 2
DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator. * 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, <!UNUSED_PARAMETER!>value_2<!>: Int): String { fun case_1(value_1: Any, <!UNUSED_PARAMETER!>value_2<!>: Int): String {
when (value_1) { when (value_1) {
is <!UNRESOLVED_REFERENCE!>value_2<!> -> return "" is <!UNRESOLVED_REFERENCE!>value_2<!> -> return ""
@@ -1,15 +1,16 @@
// !WITH_BASIC_TYPES // !WITH_BASIC_TYPES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression. * SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator. * 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 { fun case_1(value_1: Int, value_2: _BasicTypesProvider): String {
when (value_1) { when (value_1) {
<!INCOMPATIBLE_TYPES!>-1000L..100<!> -> return "" <!INCOMPATIBLE_TYPES!>-1000L..100<!> -> return ""
@@ -2,16 +2,16 @@
// !WITH_CLASSES // !WITH_CLASSES
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression. * SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2 * NUMBER: 2
DESCRIPTION: 'When' with bound value and 'when condition' with contains operator and type without defined contains operator. * 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 { fun case_1(value_1: Int, value_2: _EmptyClass, value_3: Int, value_4: Any): String {
when (value_1) { when (value_1) {
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value_2 -> return "" <!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>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). * TESTCASE NUMBER: 2
DISCUSSION * DISCUSSION
ISSUES: KT-25948 * ISSUES: KT-25948
*/ */
fun case_2(value_1: Int, value_3: Nothing) { fun case_2(value_1: Int, value_3: Nothing) {
when (value_1) { when (value_1) {
@@ -1,16 +1,16 @@
// !DIAGNOSTICS: -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE // !DIAGNOSTICS: -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [5] Any other expression. * SENTENCE: [5] Any other expression.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: 'When' with bound value and non-expressions in 'when condition'. * 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<Int>): String { fun case_1(value_1: Int, value_2: List<Int>): String {
when (value_1) { when (value_1) {
<!EXPRESSION_EXPECTED!>while (false) {}<!> -> return "" <!EXPRESSION_EXPECTED!>while (false) {}<!> -> return ""
@@ -21,7 +21,7 @@ fun case_1(value_1: Int, value_2: List<Int>): String {
return "" return ""
} }
// CASE DESCRIPTION: 'When' with assignments in when condition. // TESTCASE NUMBER: 4
fun case_4(value_1: Int): String { fun case_4(value_1: Int): String {
var value_2: Int var value_2: Int
var value_3 = 10 var value_3 = 10
@@ -1,14 +1,14 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [5] Any other expression. * SENTENCE: [5] Any other expression.
NUMBER: 2 * NUMBER: 2
DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in 'when condition'. * 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 { fun case_1(value_1: Int): String {
while (true) { while (true) {
when (value_1) { when (value_1) {
@@ -19,7 +19,7 @@ fun case_1(value_1: Int): String {
return "" return ""
} }
// CASE DESCRIPTION: 'When' with continue expression (without label). // TESTCASE NUMBER: 2
fun case_2(value_1: Int): String { fun case_2(value_1: Int): String {
while (true) { while (true) {
when (value_1) { when (value_1) {
@@ -1,29 +1,29 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION // !DIAGNOSTICS: -UNUSED_EXPRESSION
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
SECTIONS: when-expression * SECTIONS: when-expression
PARAGRAPH: 7 * PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. * SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1 * NUMBER: 1
DESCRIPTION: 'When' with bound value and with else branch not in the last position. * 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) { fun case_1(value_1: Int): String = when (value_1) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>1 -> ""<!> <!UNREACHABLE_CODE!>1 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with 'else' branch in the middle position. // TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = when (value_1) { fun case_2(value_1: Int): String = when (value_1) {
1 -> "" 1 -> ""
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>2 -> ""<!> <!UNREACHABLE_CODE!>2 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with two 'else' branches. // TESTCASE NUMBER: 3
fun case_3(value_1: Int): String { fun case_3(value_1: Int): String {
when (value_1) { when (value_1) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> return "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> return ""

Some files were not shown because too many files have changed in this diff Show More