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
@@ -1,24 +1,24 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 1
DESCRIPTION: Checking for not exhaustive when without bound value when there is no else branch.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [1] It has an else entry;
* NUMBER: 1
* DESCRIPTION: Checking for not exhaustive when without bound value when there is no else branch.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 == 1 -> ""
value_1 == 2 -> ""
value_1 == 3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch).
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> {
value_1 == 1 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches).
// TESTCASE NUMBER: 3
fun case_3(): Int = <!NO_ELSE_IN_WHEN!>when<!> {}
@@ -1,26 +1,26 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 2
DESCRIPTION: Checking for not exhaustive when with bound value when there is no else branch.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [1] It has an else entry;
* NUMBER: 2
* DESCRIPTION: Checking for not exhaustive when with bound value when there is no else branch.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
1 -> ""
2 -> ""
3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch).
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_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) {}
@@ -1,38 +1,38 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' when not contains by all Boolean values or 'when' does not have bound value.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
* NUMBER: 1
* DESCRIPTION: Checking for not exhaustive 'when' when not contains by all Boolean values or 'when' does not have bound value.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only true branch).
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only false branch).
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
false -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (no branches).
// TESTCASE NUMBER: 3
fun case_3(value_1: Boolean): Int = <!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<!> {
value_1 == true -> ""
value_1 == false -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' with both Boolean values covered, but using variables.
DISCUSSION: maybe use const propagation here?
ISSUES: KT-25265
* TESTCASE NUMBER: 5
* DISCUSSION: maybe use const propagation here?
* ISSUES: KT-25265
*/
fun case_5(value_1: Boolean): String {
val trueValue = true
@@ -2,55 +2,55 @@
// !WITH_SEALED_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression;
NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' when not covered by all possible subtypes or 'when' does not have bound value.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression;
* NUMBER: 1
* DESCRIPTION: Checking for not exhaustive 'when' when not covered by all possible subtypes or 'when' does not have bound value.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking).
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1 -> ""
is _SealedChild2 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking with enumeration).
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1, is _SealedChild2 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object).
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
_SealedMixedChildObject1 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object with enumeration).
// TESTCASE NUMBER: 4
fun case_4(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_SealedMixedChildObject1, is _SealedMixedChild2, is _SealedMixedChild1 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking).
// TESTCASE NUMBER: 5
fun case_5(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with several subtypes (no branches).
// TESTCASE NUMBER: 6
fun case_6(value_1: _SealedClassMixed): Int = <!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) { }
// 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) { }
// 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) {
is Byte -> ""
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.
DISCUSSION: maybe make exhaustive without else?
* TESTCASE NUMBER: 10
* DISCUSSION: maybe make exhaustive without else?
*/
fun case_10(value_1: Any): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
<!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<!> {
value_1 is _SealedChild1 -> ""
value_1 is _SealedChild2 -> ""
value_1 is _SealedChild3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking).
// TESTCASE NUMBER: 12
fun case_12(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
@@ -2,42 +2,42 @@
// !WITH_ENUM_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1
DESCRIPTION: Checking for not exhaustive when when not covered by all enumerated values.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
* NUMBER: 1
* DESCRIPTION: Checking for not exhaustive when when not covered by all enumerated values.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values).
// TESTCASE NUMBER: 1
fun case_1(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> ""
_EnumClass.SOUTH -> ""
_EnumClass.NORTH -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values with enumerations).
// TESTCASE NUMBER: 2
fun case_2(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST, _EnumClass.SOUTH, _EnumClass.NORTH -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (one branch).
// TESTCASE NUMBER: 3
fun case_3(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with several values (no branches).
// TESTCASE NUMBER: 4
fun case_4(value_1: _EnumClass): String = <!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) { }
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' with all Enum values covered, but using variable.
DISCUSSION: maybe use const propagation here?
ISSUES: KT-25265
* TESTCASE NUMBER: 6
* DISCUSSION: maybe use const propagation here?
* ISSUES: KT-25265
*/
fun case_6(value_1: _EnumClass): String {
val west = _EnumClass.WEST
@@ -51,8 +51,8 @@ fun case_6(value_1: _EnumClass): String {
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class.
DISCUSSION
ISSUES: KT-26044
* TESTCASE NUMBER: 7
* DISCUSSION
* ISSUES: KT-26044
*/
fun case_7(value_1: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { }
@@ -1,26 +1,26 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
* NUMBER: 1
* DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without null-check branch.
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> ""
false -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean with null-check branch, but all possible values not covered.
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> ""
null -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without branches.
// TESTCASE NUMBER: 3
fun case_3(value_1: Boolean?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
@@ -2,23 +2,23 @@
// !WITH_SEALED_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 2
DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed).
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
* NUMBER: 2
* DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed).
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch.
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1 -> ""
is _SealedChild2 -> ""
is _SealedChild3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with mixed checks (type and object check) and null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
@@ -26,12 +26,12 @@ fun case_2(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
null -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with enumeration mixed checks (type and object check) and null-check branch.
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null, is _SealedMixedChild1, is _SealedMixedChild2, _SealedMixedChildObject1 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with all subtypes and objects covered without null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
@@ -41,17 +41,17 @@ fun case_4(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
_SealedMixedChildObject3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and all subtypes covered, but objects not covered.
// TESTCASE NUMBER: 5
fun case_5(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without branches.
// TESTCASE NUMBER: 6
fun case_6(value_1: _SealedClassMixed?): Int = <!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) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2-> ""
@@ -59,23 +59,23 @@ fun case_7(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(val
null -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and only object covered.
// TESTCASE NUMBER: 8
fun case_8(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_SealedMixedChildObject1 -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable Any.
DISCUSSION: maybe make exhaustive without else?
* TESTCASE NUMBER: 9
* DISCUSSION: maybe make exhaustive without else?
*/
fun case_10(value_1: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
fun case_9(value_1: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Any -> ""
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes).
DISCUSSION
ISSUES: KT-26044
* TESTCASE NUMBER: 10
* DISCUSSION
* ISSUES: KT-26044
*/
fun case_11(value: _SealedClassEmpty): String = <!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
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 3
DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
* NUMBER: 3
* DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums.
*/
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without null-check branch.
// TESTCASE NUMBER: 1
fun case_1(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> ""
_EnumClass.SOUTH -> ""
@@ -19,7 +19,7 @@ fun case_1(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.WEST -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered.
// TESTCASE NUMBER: 2
fun case_2(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> ""
_EnumClass.SOUTH -> ""
@@ -27,20 +27,20 @@ fun case_2(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered.
// TESTCASE NUMBER: 3
fun case_3(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST, null, _EnumClass.SOUTH, _EnumClass.NORTH -> ""
}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without branches.
// TESTCASE NUMBER: 4
fun case_4(value_1: _EnumClassSingle): Int = <!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) {
_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) {
null -> ""
}
@@ -1,14 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 1
DESCRIPTION: Check when exhaustive via else entry (when without bound value).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [1] It has an else entry;
* NUMBER: 1
* DESCRIPTION: Check when exhaustive via else entry (when without bound value).
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (several value check branches and 'else' branch).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String = when {
value_1 == 0 -> ""
value_1 > 0 && value_1 <= 10 -> ""
@@ -17,13 +17,13 @@ fun case_1(value_1: Int): String = when {
else -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch).
// TESTCASE NUMBER: 2
fun case_2(): String = when {
true -> ""
else -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch).
// TESTCASE NUMBER: 3
fun case_3(): String = when {
else -> ""
}
@@ -1,16 +1,16 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 2
DESCRIPTION: Check when exhaustive via else entry (when with bound value).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [1] It has an else entry;
* NUMBER: 2
* DESCRIPTION: Check when exhaustive via else entry (when with bound value).
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (several branches).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String = when (value_1) {
0 -> ""
1 -> ""
@@ -19,22 +19,22 @@ fun case_1(value_1: Int): String = when (value_1) {
else -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch).
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean): String = when (value_1) {
true -> ""
else -> ""
}
/*
CASE DESCRIPTION: Checking for exhaustive 'when' with constant bound value (value check branch and 'else' branch).
NOTE: for potential bound value constant analysis.
* TESTCASE NUMBER: 3
* NOTE: for a potential bound value constant analysis.
*/
fun case_3(): String = when (true) {
true -> ""
else -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch).
// TESTCASE NUMBER: 4
fun case_4(value_1: Int): String = when(value_1) {
else -> ""
}
@@ -2,16 +2,16 @@
// !WITH_SEALED_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 3
DESCRIPTION: Check when exhaustive via else entry (when with bound value, redundant else).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [1] It has an else entry;
* NUMBER: 3
* DESCRIPTION: Check when exhaustive via else entry (when with bound value, redundant else).
*/
// CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values covered).
// TESTCASE NUMBER: 1
fun case_1(value_1: _EnumClass): String = when (value_1) {
_EnumClass.EAST -> ""
_EnumClass.NORTH -> ""
@@ -20,7 +20,7 @@ fun case_1(value_1: _EnumClass): String = when (value_1) {
<!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) {
_EnumClass.EAST -> ""
_EnumClass.NORTH -> ""
@@ -30,14 +30,14 @@ fun case_2(value_1: _EnumClass?): String = when (value_1) {
<!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) {
true -> ""
false -> ""
<!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) {
true -> ""
false -> ""
@@ -45,7 +45,7 @@ fun case_4(value_1: Boolean?): String = when (value_1) {
<!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) {
is _SealedChild1 -> ""
is _SealedChild2 -> ""
@@ -53,7 +53,7 @@ fun case_5(value_1: _SealedClass): String = when (value_1) {
<!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) {
is _SealedChild1 -> ""
is _SealedChild2 -> ""
@@ -62,13 +62,13 @@ fun case_6(value_1: _SealedClass?): String = when (value_1) {
<!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) {
<!USELESS_IS_CHECK!>is _SealedClassSingle<!> -> ""
<!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) {
is _SealedClassSingle -> ""
null -> ""
@@ -1,20 +1,20 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1
DESCRIPTION: Check when exhaustive via boolean bound value and evaluating to value true and false.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
* NUMBER: 1
* DESCRIPTION: Check when exhaustive via boolean bound value and evaluating to value true and false.
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value covered).
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean): String = when (value_1) {
true -> ""
false -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value as complex expression covered).
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean): String = when (value_1) {
true && false && ((true || false)) || true && !!!false && !!!true -> ""
true && false && ((true || false)) || true && !!!false -> ""
@@ -2,42 +2,42 @@
// !WITH_SEALED_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession;
NUMBER: 1
DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession;
* NUMBER: 1
* DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered.
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes covered).
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass): Int = when (value_1) {
is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number
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
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (single sealed class subtypes covered).
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClass): String = when (value_1) {
<!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) {
is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1()
is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2()
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) {
_SealedWithObjectsChild1 -> ""
_SealedWithObjectsChild2 -> ""
_SealedWithObjectsChild3 -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered).
// TESTCASE NUMBER: 5
fun case_5(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
@@ -48,8 +48,8 @@ fun case_5(value_1: _SealedClassMixed): String = when (value_1) {
}
/*
CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered).
DISCUSSION: is it correct that objects can be checked using the type checking operator?
* TESTCASE NUMBER: 6
* DISCUSSION: is it correct that objects can be checked using the type checking operator?
*/
fun case_6(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChild1 -> ""
@@ -60,24 +60,24 @@ fun case_6(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChildObject3 -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' on the empty sealed class (without subtypes).
// TESTCASE NUMBER: 7
fun case_7(value_1: _SealedClassEmpty): String = when (value_1) {
else -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types.
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996
* TESTCASE NUMBER: 8
* UNEXPECTED BEHAVIOUR: must be exhaustive
* ISSUES: KT-22996
*/
fun case_8(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3?, <!USELESS_IS_CHECK!>is _SealedChild3?<!> -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on opposite types.
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-22996
* TESTCASE NUMBER: 9
* UNEXPECTED BEHAVIOUR: must be exhaustive
* ISSUES: KT-22996
*/
fun case_9(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
is _SealedChild1, !is _SealedChild3 -> ""
@@ -1,16 +1,16 @@
// !WITH_ENUM_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1
DESCRIPTION: Check when exhaustive when all enumerated values are checked.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
* NUMBER: 1
* DESCRIPTION: Check when exhaustive when all enumerated values are checked.
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (all enum values covered).
// TESTCASE NUMBER: 1
fun case_1(dir: _EnumClass): String = when (dir) {
_EnumClass.EAST -> ""
_EnumClass.NORTH -> ""
@@ -18,7 +18,7 @@ fun case_1(dir: _EnumClass): String = when (dir) {
_EnumClass.WEST -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value covered).
// TESTCASE NUMBER: 2
fun case_2(value_1: _EnumClassSingle): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> ""
}
@@ -1,21 +1,21 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 1
DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
* NUMBER: 1
* DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check.
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values and null value covered).
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean?): String = when (value_1) {
true -> ""
false -> ""
null -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values as complex expressions and null value covered).
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean?): String = when (value_1) {
true && false && ((true || false)) || true && !!!false && !!!true -> ""
true && false && ((true || false)) || true && !!!false -> ""
@@ -1,16 +1,16 @@
// !WITH_ENUM_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 2
DESCRIPTION: Check when exhaustive when enumerated values are checked and contains a null check.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
* NUMBER: 2
* DESCRIPTION: Check when exhaustive when enumerated values are checked and contains a null check.
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (both enum values and null value covered).
// TESTCASE NUMBER: 1
fun case_1(value_1: _EnumClass?): String = when (value_1) {
_EnumClass.EAST -> ""
_EnumClass.NORTH -> ""
@@ -19,16 +19,16 @@ fun case_1(value_1: _EnumClass?): String = when (value_1) {
null -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value and null value covered).
// TESTCASE NUMBER: 2
fun case_2(value_1: _EnumClassSingle?): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> ""
null -> ""
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable enum class.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26044
* TESTCASE NUMBER: 3
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-26044
*/
fun case_3(value_1: _EnumClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> ""
@@ -1,16 +1,16 @@
// !WITH_SEALED_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 3
DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 11
* SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
* NUMBER: 3
* DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check.
*/
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes and null value covered).
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass?): Int = when (value_1) {
is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number
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
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (sealed class itself and null value covered).
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClass?): String = when (value_1) {
is _SealedClass -> ""
null -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class with methods subtypes and null value covered).
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) {
is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1()
is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2()
@@ -32,7 +32,7 @@ fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) {
null -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator and null value covered).
// TESTCASE NUMBER: 4
fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) {
_SealedWithObjectsChild1 -> ""
_SealedWithObjectsChild2 -> ""
@@ -40,7 +40,7 @@ fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) {
null -> ""
}
// CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered + null value covered).
// TESTCASE NUMBER: 5
fun case_5(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> ""
@@ -52,8 +52,8 @@ fun case_5(value_1: _SealedClassMixed?): String = when (value_1) {
}
/*
CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered + null value covered).
DISCUSSION: is it correct that objects can be checked using the type checking operator?
* TESTCASE NUMBER: 6
* DISCUSSION: is it correct that objects can be checked using the type checking operator?
*/
fun case_6(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChild1 -> ""
@@ -66,9 +66,9 @@ fun case_6(value_1: _SealedClassMixed?): String = when (value_1) {
}
/*
CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty nullable sealed class (without subtypes).
UNEXPECTED BEHAVIOUR: must be exhaustive
ISSUES: KT-26044
* TESTCASE NUMBER: 7
* UNEXPECTED BEHAVIOUR: must be exhaustive
* ISSUES: KT-26044
*/
fun case_7(value: _SealedClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
null -> ""
@@ -1,13 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 1
DESCRIPTION: Empty 'when' with bound value.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 2
* SENTENCE: [3] When expression has two different forms: with bound value and without it.
* NUMBER: 1
* DESCRIPTION: Empty 'when' with bound value.
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: Int) {
when (<!UNUSED_EXPRESSION!>value_1<!>) {}
}
@@ -1,13 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 2
DESCRIPTION: Empty 'when' without bound value.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 2
* SENTENCE: [3] When expression has two different forms: with bound value and without it.
* NUMBER: 2
* DESCRIPTION: Empty 'when' without bound value.
*/
// TESTCASE NUMBER: 1
fun case_1() {
when {}
}
@@ -1,14 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
NUMBER: 1
DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
* NUMBER: 1
* DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body.
*/
// CASE DESCRIPTION: 'When' with break expression (without label).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String {
while (true) {
when {
@@ -19,7 +19,7 @@ fun case_1(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: 'When' with continue expression (without label).
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String {
while (true) {
when {
@@ -1,15 +1,16 @@
// !WITH_BASIC_TYPES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 1
DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
* NUMBER: 1
* DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'.
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: String, value_3: _BasicTypesProvider): String {
when {
<!TYPE_MISMATCH!>.012f / value_1<!> -> return ""
@@ -1,15 +1,16 @@
// !WITH_BASIC_TYPES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 2
DESCRIPTION: 'When' without bound value and not allowed comma in when entry.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
* NUMBER: 2
* DESCRIPTION: 'When' without bound value and not allowed comma in when entry.
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: _BasicTypesProvider) {
when {
getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> value_1.getBoolean() -> return
@@ -4,16 +4,16 @@
// !WITH_FUNCTIONS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
NUMBER: 1
DESCRIPTION: 'When' without bound value and with different variants of expressions in the control structure body.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
* NUMBER: 1
* DESCRIPTION: 'When' without bound value and with different variants of expressions in the control structure body.
*/
// CASE DESCRIPTION: 'When' with control structure body as literals.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int) {
when {
value_1 == 1 -> true
@@ -25,7 +25,7 @@ fun case_1(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions.
// TESTCASE NUMBER: 2
fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
when {
value_1 == 1 -> -.09 % 10L
@@ -34,7 +34,7 @@ fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison).
// TESTCASE NUMBER: 3
fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
when {
value_1 == 1 -> value_2
@@ -46,7 +46,7 @@ fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as concatenations.
// TESTCASE NUMBER: 4
fun case_4(value_1: Int, value_2: String, value_3: String) {
when {
value_1 == 1 -> "..." + value_2 + "" + "$value_3" + "..."
@@ -54,7 +54,7 @@ fun case_4(value_1: Int, value_2: String, value_3: String) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as when expression.
// TESTCASE NUMBER: 5
fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when {
value_1 == 1 -> when {
@@ -80,7 +80,7 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive).
// TESTCASE NUMBER: 6
fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when {
value_1 == 1 -> when {
value_2 > 1000 -> 1
@@ -94,7 +94,7 @@ fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when {
}
}
// CASE DESCRIPTION: 'When' with control structure body as if expression.
// TESTCASE NUMBER: 7
fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
when {
value_1 == 1 -> if (value_2 > 1000) "1"
@@ -109,7 +109,7 @@ fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive).
// TESTCASE NUMBER: 8
fun case_8(value_1: Int, value_2: Int) = when {
value_1 == 1 -> if (value_2 > 1000) "1"
else "2"
@@ -118,14 +118,14 @@ fun case_8(value_1: Int, value_2: Int) = when {
else "4"
}
// CASE DESCRIPTION: 'When' with control structure body as try expression.
// TESTCASE NUMBER: 9
fun case_9(value_1: Int, value_2: String, value_3: String) = when {
value_1 == 1 -> <!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 }<!>
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?) {
when {
value_1 == 1 -> value_2 ?: true
@@ -134,7 +134,7 @@ fun case_10(value_1: Int, value_2: String?, value_3: String?) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as range expression.
// TESTCASE NUMBER: 11
fun case_11(value_1: Int) {
when {
value_1 == 1 -> 1..10
@@ -143,7 +143,7 @@ fun case_11(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as cast expression.
// TESTCASE NUMBER: 12
fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when {
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) {
var mutablevalue_2 = value_2
var mutablevalue_3 = value_3
@@ -165,7 +165,7 @@ fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as postfix operator expression.
// TESTCASE NUMBER: 14
fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
var mutablevalue_2 = value_2
var mutablevalue_3 = value_3
@@ -177,7 +177,7 @@ fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as indexing expression.
// TESTCASE NUMBER: 15
fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when {
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 __fun_1(): () -> Unit { return fun() { } }
@@ -198,7 +198,7 @@ fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as property access expression.
// TESTCASE NUMBER: 17
fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
when {
value_1 == 1 -> value_2.prop_1
@@ -208,7 +208,7 @@ fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as fun literal.
// TESTCASE NUMBER: 18
fun case_18(value_1: Int) {
val fun_1 = fun(): Int { return 0 }
@@ -220,7 +220,7 @@ fun case_18(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as lambda literal.
// TESTCASE NUMBER: 19
fun case_19(value_1: Int): () -> Any {
val lambda_1 = { 0 }
@@ -233,7 +233,7 @@ fun case_19(value_1: Int): () -> Any {
}
}
// CASE DESCRIPTION: 'When' with control structure body as object literal.
// TESTCASE NUMBER: 20
fun case_20(value_1: Int) {
val object_1 = object {
val prop_1 = 1
@@ -249,7 +249,7 @@ fun case_20(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as this expression.
// TESTCASE NUMBER: 21
class A {
val prop_1 = 1
val lambda_1 = { 1 }
@@ -269,7 +269,7 @@ class A {
}
}
// CASE DESCRIPTION: 'When' with control structure body as throw expression.
// TESTCASE NUMBER: 22
fun case_22(value_1: Int) {
when {
value_1 == 1 -> throw Exception()
@@ -277,7 +277,7 @@ fun case_22(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as return expression.
// TESTCASE NUMBER: 23
fun case_23(value_1: Int) {
fun r_1() {
when {
@@ -296,7 +296,7 @@ fun case_23(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as continue expression.
// TESTCASE NUMBER: 24
fun case_24(value_1: Int) {
loop1@ while (true) {
loop2@ while (true) {
@@ -308,7 +308,7 @@ fun case_24(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as break expression.
// TESTCASE NUMBER: 25
fun case_25(value_1: Int) {
loop1@ while (true) {
loop2@ while (true) {
@@ -3,16 +3,16 @@
// !WITH_ENUM_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 1
DESCRIPTION: 'When' without bound value and different variants of the boolean conditions (logical, equality, comparison, type checking operator, containment operator).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
* NUMBER: 1
* DESCRIPTION: 'When' without bound value and different variants of the boolean conditions (logical, equality, comparison, type checking operator, containment operator).
*/
// CASE DESCRIPTION: 'When' with boolean expressions and else branch.
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean, value_2: Long): Int {
return when {
value_1 -> 1
@@ -26,8 +26,8 @@ fun case_1(value_1: Boolean, value_2: Long): Int {
}
/*
CASE DESCRIPTION: 'When' with boolean expressions.
NOTE: for potential analysys on exhaustive by enum of when without bound value.
* TESTCASE NUMBER: 2
* NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/
fun case_2(value_1: _EnumClass) {
when {
@@ -39,8 +39,8 @@ fun case_2(value_1: _EnumClass) {
}
/*
CASE DESCRIPTION: 'When' with boolean expressions.
NOTE: for potential analysys on exhaustive by boolean of when without bound value.
* TESTCASE NUMBER: 3
* NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/
fun case_3(value_1: Boolean) {
when {
@@ -50,8 +50,8 @@ fun case_3(value_1: Boolean) {
}
/*
CASE DESCRIPTION: 'When' with boolean literals.
NOTE: for potential mark code after true branch as unreacable.
* TESTCASE NUMBER: 4
* NOTE: for a potential mark the code after the true branch as unreacable.
*/
fun case_4(value_1: Boolean) {
when {
@@ -62,8 +62,8 @@ fun case_4(value_1: Boolean) {
}
/*
CASE DESCRIPTION: 'When' with boolean constants.
NOTE: for potential const propagation use in this case.
* TESTCASE NUMBER: 5
* NOTE: for a potential const propagation.
*/
fun case_5(value_1: Boolean) {
val value_2 = false
@@ -76,7 +76,7 @@ fun case_5(value_1: Boolean) {
}
}
// CASE DESCRIPTION: 'When' with type checking operator.
// TESTCASE NUMBER: 6
fun case_6(value_1: Any) {
when {
value_1 is Nothing -> {}
@@ -90,8 +90,8 @@ fun case_6(value_1: Any) {
}
/*
CASE DESCRIPTION: 'When' with invert type checking operator.
NOTE: for potential analysys on exhaustive of when without bound value_1.
* TESTCASE NUMBER: 7
* NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/
fun case_7(value_1: Any) {
when {
@@ -103,8 +103,8 @@ fun case_7(value_1: Any) {
}
/*
CASE DESCRIPTION: 'When' with type checking operator by sealed class.
NOTE: for potential analysys on exhaustive by sealed class of when without bound value_1.
* TESTCASE NUMBER: 8
* NOTE: for a potential analysys of exhaustiveness by enums in whens without a bound value.
*/
fun case_8(value_1: _SealedClass) {
when {
@@ -114,7 +114,7 @@ fun case_8(value_1: _SealedClass) {
}
}
// CASE DESCRIPTION: 'When' with containment operator.
// TESTCASE NUMBER: 9
fun case_9(value_1: Int, value_2: IntRange) {
when {
value_1 in -10..100L -> {}
@@ -1,19 +1,19 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 2
DESCRIPTION: 'When' without bound value and only one 'else' branch.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
* NUMBER: 2
* DESCRIPTION: 'When' without bound value and only one 'else' branch.
*/
// CASE DESCRIPTION: 'When' as expression with only one 'else' branch.
// TESTCASE NUMBER: 1
fun case_1() = when {
else -> ""
}
// CASE DESCRIPTION: 'When' as statement with only one 'else' branch.
// TESTCASE NUMBER: 2
fun case_2(): String {
when {
else -> return ""
@@ -1,18 +1,18 @@
// !WITH_BASIC_TYPES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 3
DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean).
DISCUSSION
ISSUES: KT-25948
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 3
* SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
* NUMBER: 3
* DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean).
* DISCUSSION
* ISSUES: KT-25948
*/
// CASE DESCRIPTION: 'When' with return expression in condition.
// TESTCASE NUMBER: 1
fun case_1(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
when {
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) {
when {
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) {
loop1@ 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 {
loop1@ 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 {
when {
value_1 -> <!UNREACHABLE_CODE!>return ""<!>
@@ -76,7 +76,7 @@ fun case_6(value_1: Nothing, <!UNUSED_PARAMETER!>value_2<!>: _BasicTypesProvider
<!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) {
loop1@ while (true) {
loop2@ while (true) {
@@ -1,27 +1,27 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 5
SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
NUMBER: 1
DESCRIPTION: 'When' without bound value and with 'else' branch not in the last position.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 5
* SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
* NUMBER: 1
* DESCRIPTION: 'When' without bound value and with 'else' branch not in the last position.
*/
// CASE DESCRIPTION: 'When' with 'else' branch in the first position.
// TESTCASE NUMBER: 1
fun case_1(<!UNUSED_PARAMETER!>value_1<!>: Int): String = when {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!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 {
value_1 == 1 -> ""
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>value_1 == 2 -> ""<!>
}
// CASE DESCRIPTION: 'When' with two 'else' branches.
// TESTCASE NUMBER: 3
fun case_3(): String {
when {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> return ""
@@ -1,14 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 5
SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
NUMBER: 1
DESCRIPTION: 'When' without bound value and with else branch in the last position.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 5
* SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
* NUMBER: 1
* DESCRIPTION: 'When' without bound value and with else branch in the last position.
*/
// CASE DESCRIPTION: 'When' with else branch as statement
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String {
when {
value_1 == 1 -> return ""
@@ -17,7 +17,7 @@ fun case_1(value_1: Int): String {
}
}
// CASE DESCRIPTION: 'When' with else branch as expression
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String = when {
value_1 == 1 -> ""
value_1 == 2 -> ""
@@ -1,14 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 6
SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
NUMBER: 1
DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in the control structure body.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 6
* SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in the control structure body.
*/
// CASE DESCRIPTION: 'When' with break expression (without label).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): Int {
while (true) {
when (value_1) {
@@ -20,7 +20,7 @@ fun case_1(value_1: Int): Int {
return 0
}
// CASE DESCRIPTION: 'When' with continue expression (without label).
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): Int {
while (true) {
when (value_1) {
@@ -4,16 +4,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 6
SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
NUMBER: 1
DESCRIPTION: 'When' with bound value and with different variants of expressions in the control structure body.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 6
* SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and with different variants of expressions in the control structure body.
*/
// CASE DESCRIPTION: 'When' with control structure body as literals.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int) {
when (value_1) {
1 -> true
@@ -25,7 +25,7 @@ fun case_1(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions.
// TESTCASE NUMBER: 2
fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
when (value_1) {
1 -> -.09 % 10L
@@ -35,7 +35,7 @@ fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison).
// TESTCASE NUMBER: 3
fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
when (value_1) {
1 -> value_2
@@ -47,7 +47,7 @@ fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as concatenations.
// TESTCASE NUMBER: 4
fun case_4(value_1: Int, value_2: String, value_3: String) {
when (value_1) {
1 -> "..." + value_2 + "" + "$value_3" + "..."
@@ -55,7 +55,7 @@ fun case_4(value_1: Int, value_2: String, value_3: String) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as when expression.
// TESTCASE NUMBER: 5
fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value_1) {
1 -> when (value_3) {
@@ -81,7 +81,7 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive).
// TESTCASE NUMBER: 6
fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when (value_1) {
1 -> when (value_3) {
value_2 > 1000 -> 1
@@ -95,7 +95,7 @@ fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when (value_1) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as if expression.
// TESTCASE NUMBER: 7
fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value_1) {
1 -> if (value_2 > 1000) "1"
@@ -110,7 +110,7 @@ fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive).
// TESTCASE NUMBER: 8
fun case_8(value_1: Int, value_2: Int) = when (value_1) {
1 -> if (value_2 > 1000) "1"
else "2"
@@ -119,7 +119,7 @@ fun case_8(value_1: Int, value_2: Int) = when (value_1) {
else "4"
}
// CASE DESCRIPTION: 'When' with control structure body as try expression.
// TESTCASE NUMBER: 9
fun case_9(value_1: Int, value_2: String, value_3: String): Any {
return when (value_1) {
1 -> try { 4 } catch (e: Exception) { 5 }
@@ -128,7 +128,7 @@ fun case_9(value_1: Int, value_2: String, value_3: String): Any {
}
}
// CASE DESCRIPTION: 'When' with control structure body as elvis operator expression.
// TESTCASE NUMBER: 10
fun case_10(value_1: Int, value_2: String?, value_3: String?) {
when (value_1) {
1 -> value_2 ?: true
@@ -137,7 +137,7 @@ fun case_10(value_1: Int, value_2: String?, value_3: String?) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as range expression.
// TESTCASE NUMBER: 11
fun case_11(value_1: Int) {
when (value_1) {
1 -> 1..10
@@ -146,7 +146,7 @@ fun case_11(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as cast expression.
// TESTCASE NUMBER: 12
fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value_1) {
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) {
var mutableValue1 = value_2
var mutableValue2 = value_3
@@ -168,7 +168,7 @@ fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as postfix operator expression.
// TESTCASE NUMBER: 14
fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
var mutableValue1 = value_2
var mutableValue2 = value_3
@@ -180,7 +180,7 @@ fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as indexing expression.
// TESTCASE NUMBER: 15
fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value_1) {
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 __fun_1(): () -> Unit { return fun() { } }
@@ -201,7 +201,7 @@ fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as property access expression.
// TESTCASE NUMBER: 17
fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value_1) {
1 -> value_2.prop_1
@@ -211,7 +211,7 @@ fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as fun literal.
// TESTCASE NUMBER: 18
fun case_18(value_1: Int) {
val fun_1 = fun(): Int { return 0 }
@@ -223,7 +223,7 @@ fun case_18(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as lambda literal.
// TESTCASE NUMBER: 19
fun case_19(value_1: Int): Any {
val lambda_1 = { 0 }
@@ -236,7 +236,7 @@ fun case_19(value_1: Int): Any {
}
}
// CASE DESCRIPTION: 'When' with control structure body as object literal.
// TESTCASE NUMBER: 20
fun case_20(value_1: Int) {
val object_1 = object {
val prop_1 = 1
@@ -252,7 +252,7 @@ fun case_20(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as this expression.
// TESTCASE NUMBER: 21
class A {
val prop_1 = 1
val lambda_1 = { 1 }
@@ -272,7 +272,7 @@ class A {
}
}
// CASE DESCRIPTION: 'When' with control structure body as throw expression.
// TESTCASE NUMBER: 22
fun case_22(value_1: Int) {
when (value_1) {
1 -> throw Exception()
@@ -280,7 +280,7 @@ fun case_22(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as return expression.
// TESTCASE NUMBER: 23
fun case_23(value_1: Int) {
fun r_1() {
when (value_1) {
@@ -299,7 +299,7 @@ fun case_23(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as continue expression.
// TESTCASE NUMBER: 24
fun case_24(value_1: Int) {
loop1@ while (true) {
loop2@ while (true) {
@@ -311,7 +311,7 @@ fun case_24(value_1: Int) {
}
}
// CASE DESCRIPTION: 'When' with control structure body as break expression.
// TESTCASE NUMBER: 25
fun case_25(value_1: Int) {
loop1@ while (true) {
loop2@ while (true) {
@@ -1,16 +1,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1
DESCRIPTION: 'When' with bound value and type test condition (without companion object in classes), but without type checking operator.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [1] Type test condition: type checking operator followed by type.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and type test condition (without companion object in classes), but without type checking operator.
*/
// CASE DESCRIPTION: 'When' with custom class type test condition.
// TESTCASE NUMBER: 1
fun case_1(value_1: Any): String {
when (value_1) {
<!NO_COMPANION_OBJECT!>_EmptyClass<!> -> return ""
@@ -19,7 +19,7 @@ fun case_1(value_1: Any): String {
return ""
}
// CASE DESCRIPTION: 'When' with Any type test condition.
// TESTCASE NUMBER: 2
fun case_2(value_1: Any): String {
when (value_1) {
<!NO_COMPANION_OBJECT!>Any<!> -> return ""
@@ -28,7 +28,7 @@ fun case_2(value_1: Any): String {
return ""
}
// CASE DESCRIPTION: 'When' with Nothing type test condition.
// TESTCASE NUMBER: 3
fun case_3(value_1: Any): String {
when (value_1) {
<!NO_COMPANION_OBJECT!>Nothing<!> -> return ""
@@ -1,15 +1,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2
DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [1] Type test condition: type checking operator followed by type.
* NUMBER: 2
* DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator.
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: Any, <!UNUSED_PARAMETER!>value_2<!>: Int): String {
when (value_1) {
is <!UNRESOLVED_REFERENCE!>value_2<!> -> return ""
@@ -1,15 +1,16 @@
// !WITH_BASIC_TYPES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1
DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [3] Contains test condition: containment operator followed by an expression.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator.
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: _BasicTypesProvider): String {
when (value_1) {
<!INCOMPATIBLE_TYPES!>-1000L..100<!> -> return ""
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2
DESCRIPTION: 'When' with bound value and 'when condition' with contains operator and type without defined contains operator.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [3] Contains test condition: containment operator followed by an expression.
* NUMBER: 2
* DESCRIPTION: 'When' with bound value and 'when condition' with contains operator and type without defined contains operator.
*/
// CASE DESCRIPTION: 'When' with values of types without defined contains operator.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: _EmptyClass, value_3: Int, value_4: Any): String {
when (value_1) {
<!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).
DISCUSSION
ISSUES: KT-25948
* TESTCASE NUMBER: 2
* DISCUSSION
* ISSUES: KT-25948
*/
fun case_2(value_1: Int, value_3: Nothing) {
when (value_1) {
@@ -1,16 +1,16 @@
// !DIAGNOSTICS: -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 1
DESCRIPTION: 'When' with bound value and non-expressions in 'when condition'.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [5] Any other expression.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and non-expressions in 'when condition'.
*/
// CASE DESCRIPTION: 'When' with cycles in when condition.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: List<Int>): String {
when (value_1) {
<!EXPRESSION_EXPECTED!>while (false) {}<!> -> return ""
@@ -21,7 +21,7 @@ fun case_1(value_1: Int, value_2: List<Int>): String {
return ""
}
// CASE DESCRIPTION: 'When' with assignments in when condition.
// TESTCASE NUMBER: 4
fun case_4(value_1: Int): String {
var value_2: Int
var value_3 = 10
@@ -1,14 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 2
DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in 'when condition'.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [5] Any other expression.
* NUMBER: 2
* DESCRIPTION: 'When' with bound value and not allowed break and continue expression (without labels) in 'when condition'.
*/
// CASE DESCRIPTION: 'When' with break expression (without label).
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String {
while (true) {
when (value_1) {
@@ -19,7 +19,7 @@ fun case_1(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: 'When' with continue expression (without label).
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String {
while (true) {
when (value_1) {
@@ -1,29 +1,29 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1
DESCRIPTION: 'When' with bound value and with else branch not in the last position.
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and with else branch not in the last position.
*/
// CASE DESCRIPTION: 'When' with 'else' branch in the first position.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String = when (value_1) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!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) {
1 -> ""
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>2 -> ""<!>
}
// CASE DESCRIPTION: 'When' with two 'else' branches.
// TESTCASE NUMBER: 3
fun case_3(value_1: Int): String {
when (value_1) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> return ""
@@ -2,16 +2,16 @@
// !WITH_OBJECTS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1
DESCRIPTION: 'When' with bound value and type test condition.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [1] Type test condition: type checking operator followed by type.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and type test condition.
*/
// CASE DESCRIPTION: 'When' with type test condition on the various basic types.
// TESTCASE NUMBER: 1
fun case_1(value_1: Any): String {
when (value_1) {
is Int -> return ""
@@ -25,29 +25,29 @@ fun case_1(value_1: Any): String {
return ""
}
// CASE DESCRIPTION: 'When' with type test condition on the various nullable basic types.
// TESTCASE NUMBER: 2
fun case_2(value_1: Any?): String = when (value_1) {
is Int? -> "" // if value is null then this branch will be executed
is Float -> ""
else -> ""
}
// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on Any.
// TESTCASE NUMBER: 3
fun case_3(value_1: Any?): String = when (value_1) {
is Any -> ""
else -> ""
}
// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on nullable (redundant) Any.
// TESTCASE NUMBER: 4
fun case_4(value_1: Any): String = when (value_1) {
<!USELESS_IS_CHECK!>is Any<!USELESS_NULLABLE_CHECK!>?<!><!> -> ""
else -> ""
}
/*
CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check).
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 5
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_5(value_1: Any?): String = when (value_1) {
is Double -> ""
@@ -59,7 +59,7 @@ fun case_5(value_1: Any?): String = when (value_1) {
else -> ""
}
// CASE DESCRIPTION: 'When' with type test condition on the objetcs.
// TESTCASE NUMBER: 6
fun case_6(value_1: Any): String {
when (value_1) {
is _EmptyObject -> return ""
@@ -3,16 +3,16 @@
// !WITH_OBJECTS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2
DESCRIPTION: 'When' with bound value and type test condition (invert type checking operator).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [1] Type test condition: type checking operator followed by type.
* NUMBER: 2
* DESCRIPTION: 'When' with bound value and type test condition (invert type checking operator).
*/
// CASE DESCRIPTION: 'When' in which all branches includes invert type checking operators.
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass) = when (value_1) {
!is _SealedChild1 -> {}
!is _SealedChild2 -> {}
@@ -20,9 +20,9 @@ fun case_1(value_1: _SealedClass) = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with direct and invert (with null-check) type checking operators on the same types and redundant null-check.
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 2
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_2(value_1: _SealedClass?): String = when (value_1) {
!is _SealedChild2 -> "" // including null
@@ -30,7 +30,7 @@ fun case_2(value_1: _SealedClass?): String = when (value_1) {
null -> "" // redundant
}
// CASE DESCRIPTION: 'When' with direct and invert type checking operators on the same types and null-check.
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClass?): String = when (value_1) {
!is _SealedChild2? -> "" // null isn't included
is _SealedChild2 -> ""
@@ -38,9 +38,9 @@ fun case_3(value_1: _SealedClass?): String = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with direct and invert (with null-check) type checking operators on the same types.
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 4
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_4(value_1: _SealedClass?) {
when (value_1) {
@@ -49,7 +49,7 @@ fun case_4(value_1: _SealedClass?) {
}
}
// CASE DESCRIPTION: 'When' with direct and invert type checking operator on the objects.
// TESTCASE NUMBER: 5
fun case_5(value_1: Any): String {
when (value_1) {
is _EmptyObject -> return ""
@@ -3,16 +3,16 @@
// !WITH_OBJECTS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 3
DESCRIPTION: 'When' with bound value and enumaration of type test conditions.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [1] Type test condition: type checking operator followed by type.
* NUMBER: 3
* DESCRIPTION: 'When' with bound value and enumaration of type test conditions.
*/
// CASE DESCRIPTION: 'When' with type test condition on the various basic types.
// TESTCASE NUMBER: 1
fun case_1(value_1: Any) = when (value_1) {
is Int -> {}
is Float, is Char, is Boolean -> {}
@@ -20,7 +20,7 @@ fun case_1(value_1: Any) = when (value_1) {
else -> {}
}
// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types.
// TESTCASE NUMBER: 2
fun case_2(value_1: Any?) = when (value_1) {
is Float, is Char, is _SealedClass? -> "" // if value is null then this branch will be executed
is Double, is Boolean, is _ClassWithCompanionObject.Companion -> ""
@@ -28,9 +28,9 @@ fun case_2(value_1: Any?) = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check in the different branches).
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 3
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_3(value_1: Any?) = when (value_1) {
is Float, is Char, is Int? -> "" // if value is null then this branch will be executed
@@ -39,9 +39,9 @@ fun case_3(value_1: Any?) = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check in the one branch).
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 4
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_4(value_1: Any?) = when (value_1) {
is Float, is Char?, is Int? -> "" // double nullable type check in the one branch
@@ -50,9 +50,9 @@ fun case_4(value_1: Any?) = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two nullable type check).
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 5
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_5(value_1: Any?): String {
when (value_1) {
@@ -64,9 +64,9 @@ fun case_5(value_1: Any?): String {
}
/*
CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types (two different nullable type check in the one branch).
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 6
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_6(value_1: Any?): String {
when (value_1) {
@@ -1,46 +1,46 @@
// !WITH_SEALED_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 4
DESCRIPTION: 'When' with bound value and enumaration of type test conditions (with invert type checking operator).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [1] Type test condition: type checking operator followed by type.
* NUMBER: 4
* DESCRIPTION: 'When' with bound value and enumaration of type test conditions (with invert type checking operator).
*/
// CASE DESCRIPTION: 'When' with direct and invert type checking operator in the one branch and other branch.
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass): String = when (value_1) {
is _SealedChild1, !is _SealedChild3 -> ""
<!USELESS_IS_CHECK!>is _SealedChild3<!> -> ""
}
// CASE DESCRIPTION: 'When' with three invert type checking operator in the one branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClass) = when (value_1) {
!is _SealedChild1, !is _SealedChild2, !is _SealedChild3 -> {}
}
// CASE DESCRIPTION: 'When' with direct (first) and invert (second) type checking operator on the some type in the one branch.
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClass): String = when (value_1) {
is _SealedChild2, !is _SealedChild2 -> ""
}
// CASE DESCRIPTION: 'When' with direct (second) and invert (first) type checking operator in the one branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: _SealedClass): String = when (value_1) {
!is _SealedChild1, <!USELESS_IS_CHECK!>is _SealedChild1<!> -> ""
}
// CASE DESCRIPTION: 'When' with direct and invert (nullable) type checking operator on the some type in the one branch.
// TESTCASE NUMBER: 5
fun case_5(value_1: Any?): String = when (value_1) {
is _SealedChild3, !is _SealedChild3? -> ""
else -> ""
}
/*
CASE DESCRIPTION: 'When' with direct and invert type checking operator in the one branch and other branch and double nullable type check.
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 6
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_6(value_1: Any?): String = when (value_1) {
is Boolean?, !is _SealedChild3 -> "" // double nullable type check in the one branch
@@ -49,9 +49,9 @@ fun case_6(value_1: Any?): String = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with direct and invert type checking operator and null-check in the one branch.
UNEXPECTED BEHAVIOUR
ISSUES: KT-22996
* TESTCASE NUMBER: 7
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_7(value_1: Any?): String = when (value_1) {
is Number?, null, !is _SealedChild3 -> "" // triple nullable type check in the one branch
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1
DESCRIPTION: 'When' with bound value and containment operator.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [3] Contains test condition: containment operator followed by an expression.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and containment operator.
*/
// CASE DESCRIPTION: 'When' with range operator.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: Int, value_3: Short): String {
when (value_1) {
in Long.MIN_VALUE..-100 -> return ""
@@ -23,7 +23,7 @@ fun case_1(value_1: Int, value_2: Int, value_3: Short): String {
return ""
}
// CASE DESCRIPTION: 'When' on types with contains method defined.
// TESTCASE NUMBER: 2
fun case_2(value_1: Int, value_2: List<IntArray>, value_3: _Class) = when (value_1) {
in value_2[0] -> ""
!in listOf(0, 1, 2, 3, 4) -> ""
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2
DESCRIPTION: 'When' with bound value and enumeration of the containment operators.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [3] Contains test condition: containment operator followed by an expression.
* NUMBER: 2
* DESCRIPTION: 'When' with bound value and enumeration of the containment operators.
*/
// CASE DESCRIPTION: 'When' with range operator.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: Int, value_3: Short): String {
when (value_1) {
in Long.MIN_VALUE..-100, in -99..0 -> return ""
@@ -21,7 +21,7 @@ fun case_1(value_1: Int, value_2: Int, value_3: Short): String {
return ""
}
// CASE DESCRIPTION: 'When' on types with contains method defined.
// TESTCASE NUMBER: 2
fun case_2(value_1: Int, value_2: List<IntArray>, value_3: _Class) = when (value_1) {
!in value_2[0], !in listOf(0, 1, 2, 3, 4), !in value_3.getIntArray(90) -> ""
else -> ""
@@ -3,16 +3,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 1
DESCRIPTION: 'When' with enumeration of the different variants of expressions in 'when condition'.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [5] Any other expression.
* NUMBER: 1
* DESCRIPTION: 'When' with enumeration of the different variants of expressions in 'when condition'.
*/
// CASE DESCRIPTION: 'When' with condition as literals.
// TESTCASE NUMBER: 1
fun case_1(value_1: Any?) {
when (value_1) {
true -> {}
@@ -24,7 +24,7 @@ fun case_1(value_1: Any?) {
}
}
// CASE DESCRIPTION: 'When' with condition as arithmetic expressions.
// TESTCASE NUMBER: 2
fun case_2(value_1: Number, value_2: Int) {
when (value_1) {
-.09 % 10L -> {}
@@ -33,7 +33,7 @@ fun case_2(value_1: Number, value_2: Int) {
}
}
// CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison).
// TESTCASE NUMBER: 3
fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) {
when (value_1) {
value_2 -> {}
@@ -45,7 +45,7 @@ fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) {
}
}
// CASE DESCRIPTION: 'When' with condition as concatenations.
// TESTCASE NUMBER: 4
fun case_4(value_1: String, value_2: String, value_3: String) {
when (value_1) {
"..." + value_2 + "" + "$value_3" + "..." -> {}
@@ -53,7 +53,7 @@ fun case_4(value_1: String, value_2: String, value_3: String) {
}
}
// CASE DESCRIPTION: 'When' with condition as when expression.
// TESTCASE NUMBER: 5
fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value_1) {
when {
@@ -73,7 +73,7 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' with condition as if expression.
// TESTCASE NUMBER: 6
fun case_6(value_1: Int, value_2: Int) {
when (value_1) {
if (value_2 > 1000) 1
@@ -84,7 +84,7 @@ fun case_6(value_1: Int, value_2: Int) {
}
}
// CASE DESCRIPTION: 'When' with condition as try expression.
// TESTCASE NUMBER: 7
fun case_7(value_1: Any, value_2: String, value_3: String) {
when (value_1) {
try { 4 } catch (e: Exception) { 5 } -> {}
@@ -93,7 +93,7 @@ fun case_7(value_1: Any, value_2: String, value_3: String) {
}
}
// CASE DESCRIPTION: 'When' with condition as elvis operator expression.
// TESTCASE NUMBER: 8
fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
when (value_1) {
value_2 ?: 0 -> {}
@@ -102,7 +102,7 @@ fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
}
}
// CASE DESCRIPTION: 'When' with condition as range expression.
// TESTCASE NUMBER: 9
fun case_9(value_1: Any) {
when (value_1) {
1..10 -> {}
@@ -111,7 +111,7 @@ fun case_9(value_1: Any) {
}
}
// CASE DESCRIPTION: 'When' with condition as cast expression.
// TESTCASE NUMBER: 10
fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value_1) {
value_2 as MutableList<Int> -> {}
@@ -121,7 +121,7 @@ fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collect
}
}
// CASE DESCRIPTION: 'When' with condition as prefix operator expression.
// TESTCASE NUMBER: 11
fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value_2
var mutableValue2 = value_3
@@ -133,7 +133,7 @@ fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) {
}
}
// CASE DESCRIPTION: 'When' with condition as postfix operator expression.
// TESTCASE NUMBER: 12
fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) {
var mutableValue1 = value_2
var mutableValue2 = value_3
@@ -145,7 +145,7 @@ fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) {
}
}
// CASE DESCRIPTION: 'When' with condition as indexing expression.
// TESTCASE NUMBER: 13
fun case_13(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value_1) {
value_2[0] -> {}
@@ -153,7 +153,7 @@ fun case_13(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>
}
}
// CASE DESCRIPTION: 'When' with condition as call expression.
// TESTCASE NUMBER: 14
fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Any { return fun() { } }
@@ -166,7 +166,7 @@ fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) {
}
}
// CASE DESCRIPTION: 'When' with condition as property access expression.
// TESTCASE NUMBER: 15
fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value_1) {
value_2.prop_1 -> {}
@@ -176,7 +176,7 @@ fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) {
}
}
// CASE DESCRIPTION: 'When' with condition as fun literal.
// TESTCASE NUMBER: 16
fun case_16(value_1: () -> Any): Any {
val fun_1 = fun() { return }
@@ -189,7 +189,7 @@ fun case_16(value_1: () -> Any): Any {
}
}
// CASE DESCRIPTION: 'When' with condition as lambda literal.
// TESTCASE NUMBER: 17
fun case_17(value_1: () -> Any) {
val lambda_1 = { 0 }
@@ -202,7 +202,7 @@ fun case_17(value_1: () -> Any) {
}
}
// CASE DESCRIPTION: 'When' with condition as object literal.
// TESTCASE NUMBER: 18
fun case_18(value_1: Any) {
val object_1 = object {
val prop_1 = 1
@@ -218,7 +218,7 @@ fun case_18(value_1: Any) {
}
}
// CASE DESCRIPTION: 'When' with condition as this expression.
// TESTCASE NUMBER: 19
class A {
val prop_1 = 1
val lambda_1 = { 1 }
@@ -238,7 +238,7 @@ class A {
}
}
// CASE DESCRIPTION: 'When' with condition as throw expression.
// TESTCASE NUMBER: 20
fun case_20(value_1: Nothing) {
when (value_1) {
<!UNREACHABLE_CODE!>throw Exception() -> {}<!>
@@ -246,16 +246,16 @@ fun case_20(value_1: Nothing) {
}
}
// CASE DESCRIPTION: 'When' with condition as return expression.
// TESTCASE NUMBER: 21
fun case_21(value_1: Nothing) {
fun r_1() {
fun f1() {
when (value_1) {
<!UNREACHABLE_CODE!>return -> 1<!>
<!UNREACHABLE_CODE!>return return return -> 2<!>
}
}
fun r_2(): List<Int>? {
fun f2(): List<Int>? {
when (value_1) {
<!UNREACHABLE_CODE!>return listOf(0, 1, 2) -> 1<!>
<!UNREACHABLE_CODE!>return null -> 2<!>
@@ -263,7 +263,7 @@ fun case_21(value_1: Nothing) {
}
}
// CASE DESCRIPTION: 'When' with condition as continue expression.
// TESTCASE NUMBER: 22
fun case_22(value_1: Nothing) {
loop1@ while (true) {
loop2@ while (true) {
@@ -275,7 +275,7 @@ fun case_22(value_1: Nothing) {
}
}
// CASE DESCRIPTION: 'When' with condition as break expression.
// TESTCASE NUMBER: 23
fun case_23(value_1: Nothing) {
loop1@ while (true) {
loop2@ while (true) {
@@ -3,16 +3,16 @@
// !WITH_FUNCTIONS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 2
DESCRIPTION: 'When' with different variants of the arithmetic expressions (additive expression and multiplicative expression) in 'when condition'.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [5] Any other expression.
* NUMBER: 2
* DESCRIPTION: 'When' with different variants of the arithmetic expressions (additive expression and multiplicative expression) in 'when condition'.
*/
// CASE DESCRIPTION: 'When' with condition as literals.
// TESTCASE NUMBER: 1
fun case_1(value_1: Any?) {
when (value_1) {
true, 100, -.09f -> {}
@@ -20,14 +20,14 @@ fun case_1(value_1: Any?) {
}
}
// CASE DESCRIPTION: 'When' with condition as arithmetic expressions.
// TESTCASE NUMBER: 2
fun case_2(value_1: Number, value_2: Int) {
when (value_1) {
-.09 % 10L, value_2 / -5, getByte(99) - 11 + 90 -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison).
// TESTCASE NUMBER: 3
fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) {
when (value_1) {
value_2, !value_2, getBoolean() && value_2, getChar(10) != 'a' -> {}
@@ -35,14 +35,14 @@ fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) {
}
}
// CASE DESCRIPTION: 'When' with condition as concatenations.
// TESTCASE NUMBER: 4
fun case_4(value_1: String, value_2: String, value_3: String) {
when (value_1) {
"..." + value_2 + "" + "$value_3" + "...", value_2 + getString() -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as when expression.
// TESTCASE NUMBER: 5
fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value_1) {
when {
@@ -60,35 +60,35 @@ fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
}
}
// CASE DESCRIPTION: 'When' with condition as if expression.
// TESTCASE NUMBER: 6
fun case_6(value_1: Int, value_2: Int) {
when (value_1) {
if (value_2 > 1000) 1 else 2, if (value_2 < 100) 1 else if (value_2 < 10) 2 else 3 -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as try expression.
// TESTCASE NUMBER: 7
fun case_7(value_1: Any, value_2: String, value_3: String) {
when (value_1) {
try { 4 } catch (e: Exception) { 5 }, try { throw Exception() } catch (e: Exception) { value_2 }, try { throw Exception() } catch (e: Exception) { {value_3} } finally { } -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as elvis operator expression.
// TESTCASE NUMBER: 8
fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
when (value_1) {
value_2 ?: 0, value_2 ?: value_3 ?: 0, value_2!! <!USELESS_ELVIS!>?: 0<!> -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as range expression.
// TESTCASE NUMBER: 9
fun case_9(value_1: Any) {
when (value_1) {
1..10, -100L..100L, -getInt()..getLong() -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as cast expression.
// TESTCASE NUMBER: 10
fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value_1) {
value_2 as MutableList<Int>, value_2 <!USELESS_CAST!>as? MutableList<Int><!> -> {}
@@ -96,7 +96,7 @@ fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collect
}
}
// CASE DESCRIPTION: 'When' with condition as prefix operator expression.
// TESTCASE NUMBER: 11
fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value_2
var mutableValue2 = value_3
@@ -106,7 +106,7 @@ fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) {
}
}
// CASE DESCRIPTION: 'When' with condition as postfix operator expression.
// TESTCASE NUMBER: 12
fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) {
var mutableValue1 = value_2
var mutableValue2 = value_3
@@ -116,14 +116,14 @@ fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) {
}
}
// CASE DESCRIPTION: 'When' with condition as indexing expression.
// TESTCASE NUMBER: 13
fun case_13(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value_1) {
value_2[0], value_3[0][-4][1][-1] -> {}
}
}
// CASE DESCRIPTION: 'When' with condition as call expression.
// TESTCASE NUMBER: 14
fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Unit { return fun() { } }
@@ -133,7 +133,7 @@ fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) {
}
}
// CASE DESCRIPTION: 'When' with condition as property access expression.
// TESTCASE NUMBER: 15
fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value_1) {
value_2.prop_1, value_3?.prop_2 -> {}
@@ -141,7 +141,7 @@ fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) {
}
}
// CASE DESCRIPTION: 'When' with condition as fun literal.
// TESTCASE NUMBER: 16
fun case_16(value_1: () -> Any): Any {
val fun_1 = fun() { return }
@@ -151,7 +151,7 @@ fun case_16(value_1: () -> Any): Any {
}
}
// CASE DESCRIPTION: 'When' with condition as lambda literal.
// TESTCASE NUMBER: 17
fun case_17(value_1: () -> Any) {
val lambda_1 = { 0 }
@@ -161,7 +161,7 @@ fun case_17(value_1: () -> Any) {
}
}
// CASE DESCRIPTION: 'When' with condition as object literal.
// TESTCASE NUMBER: 18
fun case_18(value_1: Any) {
val object_1 = object {
val prop_1 = 1
@@ -175,7 +175,7 @@ fun case_18(value_1: Any) {
}
}
// CASE DESCRIPTION: 'When' with condition as this expression.
// TESTCASE NUMBER: 19
class A {
val prop_1 = 1
val lambda_1 = { 1 }
@@ -190,29 +190,29 @@ class A {
}
}
// CASE DESCRIPTION: 'When' with condition as throw expression.
// TESTCASE NUMBER: 20
fun case_20(value_1: Nothing) {
when (value_1) {
<!UNREACHABLE_CODE!>throw Exception(), throw throw throw Exception() -> {}<!>
}
}
// CASE DESCRIPTION: 'When' with condition as return expression.
// TESTCASE NUMBER: 21
fun case_21(value_1: Nothing) {
fun r_1() {
fun f1() {
when (value_1) {
<!UNREACHABLE_CODE!>return, return return return -> 2<!>
}
}
fun r_2(): List<Int>? {
fun f2(): List<Int>? {
when (value_1) {
<!UNREACHABLE_CODE!>return listOf(0, 1, 2), return null -> 2<!>
}
}
}
// CASE DESCRIPTION: 'When' with condition as continue expression.
// TESTCASE NUMBER: 22
fun case_22(value_1: Nothing) {
loop1@ while (true) {
loop2@ while (true) {
@@ -223,7 +223,7 @@ fun case_22(value_1: Nothing) {
}
}
// CASE DESCRIPTION: 'When' with condition as break expression.
// TESTCASE NUMBER: 23
fun case_23(value_1: Nothing) {
loop1@ while (true) {
loop2@ while (true) {
@@ -234,7 +234,7 @@ fun case_23(value_1: Nothing) {
}
}
// CASE DESCRIPTION: 'When' with condition as mixed Nothing expressions.
// TESTCASE NUMBER: 24
fun case_24(value_1: Nothing?) = when (<!DEBUG_INFO_CONSTANT!>value_1<!>) {
throw Exception()<!UNREACHABLE_CODE!><!>, <!UNREACHABLE_CODE!>return ""<!> -> <!UNREACHABLE_CODE!>""<!>
<!UNREACHABLE_CODE!>null, return return return "", throw throw throw Exception() -> ""<!>
@@ -242,9 +242,9 @@ fun case_24(value_1: Nothing?) = when (<!DEBUG_INFO_CONSTANT!>value_1<!>) {
}
/*
CASE DESCRIPTION: 'When' with condition as mixed Nothing expressions.
DISCUSSION
ISSUES: KT-25948
* TESTCASE NUMBER: 25
* DISCUSSION
* ISSUES: KT-25948
*/
fun case_25(value_1: Boolean) = when (value_1) {
true -> {}
@@ -253,9 +253,9 @@ fun case_25(value_1: Boolean) = when (value_1) {
}
/*
CASE DESCRIPTION: 'When' with two labels in condition: with const value and nullable const value.
UNEXPECTED BEHAVIOUR
ISSUES: KT-26045
* TESTCASE NUMBER: 26
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-26045
*/
fun case_26(value_1: Int?, value_2: _Class, value_3: _Class?) {
when (value_1) {
@@ -1,14 +1,14 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1
DESCRIPTION: 'When' with bound value and else branch.
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 7
* SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
* NUMBER: 1
* DESCRIPTION: 'When' with bound value and else branch.
*/
// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and expression as when condition.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int?) = when (value_1) {
0 -> ""
1 -> ""
@@ -16,7 +16,7 @@ fun case_1(value_1: Int?) = when (value_1) {
else -> ""
}
// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and type test as when condition.
// TESTCASE NUMBER: 2
fun case_2(value_1: Any) = when (value_1) {
is Int -> ""
is Boolean -> ""
@@ -24,8 +24,8 @@ fun case_2(value_1: Any) = when (value_1) {
else -> ""
}
// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and range test as when condition.
fun case_2(value_1: Int) = when (value_1) {
// TESTCASE NUMBER: 3
fun case_3(value_1: Int) = when (value_1) {
in -10..10 -> ""
in 11..1000 -> ""
in 1000..Int.MAX_VALUE -> ""
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 1
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch).
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 1
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch).
*/
// CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' without bound value.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String {
val whenValue = when {
value_1 == 0 -> _ClassLevel2()
@@ -31,7 +31,7 @@ fun case_1(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' with bound value.
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String {
val whenValue = when (value_1) {
0 -> _ClassLevel2()
@@ -51,7 +51,7 @@ fun case_2(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' without bound value.
// TESTCASE NUMBER: 3
fun case_3(value_1: Int): String {
val whenValue = when {
value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
@@ -78,7 +78,7 @@ fun case_3(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' with bound value.
// TESTCASE NUMBER: 4
fun case_4(value_1: Int): String {
val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
@@ -105,7 +105,7 @@ fun case_4(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' without bound value.
// TESTCASE NUMBER: 5
fun case_5(value_1: Int): String {
val whenValue = when {
value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -124,7 +124,7 @@ fun case_5(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with bound value.
// TESTCASE NUMBER: 6
fun case_6(value_1: Int): String {
val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -3,16 +3,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 2
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum).
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 2
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum).
*/
// CASE DESCRIPTION: Checking all types except the correct one in 'when'.
// TESTCASE NUMBER: 1
fun case_1(value_1: _EnumClass): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2()
@@ -32,7 +32,7 @@ fun case_1(value_1: _EnumClass): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: _EnumClass?): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2()
@@ -55,7 +55,7 @@ fun case_2(value_1: _EnumClass?): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 3
fun case_3(value_1: _EnumClass): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -74,7 +74,7 @@ fun case_3(value_1: _EnumClass): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: _EnumClass?): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 3
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value).
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 3
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value).
*/
// CASE DESCRIPTION: Checking all types except the correct one in 'when'.
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean): String {
val whenValue = when (value_1) {
true -> _ClassLevel2()
@@ -27,7 +27,7 @@ fun case_1(value_1: Boolean): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean?): String {
val whenValue = when (value_1) {
true -> _ClassLevel2()
@@ -44,7 +44,7 @@ fun case_2(value_1: Boolean?): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 3
fun case_3(value_1: Boolean): String {
val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -59,7 +59,7 @@ fun case_3(value_1: Boolean): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: Boolean?): String {
val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -77,5 +77,3 @@ fun case_4(value_1: Boolean?): String {
return ""
}
@@ -3,16 +3,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 4
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class).
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 4
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class).
*/
// CASE DESCRIPTION: Checking all types except the correct one in 'when'.
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass): String {
val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2()
@@ -29,7 +29,7 @@ fun case_1(value_1: _SealedClass): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClass?): String {
val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2()
@@ -49,7 +49,7 @@ fun case_2(value_1: _SealedClass?): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClass): String {
val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -65,7 +65,7 @@ fun case_3(value_1: _SealedClass): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: _SealedClass?): String {
val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -84,7 +84,7 @@ fun case_4(value_1: _SealedClass?): String {
return ""
}
// CASE DESCRIPTION: Checking objects except the correct one in 'when'.
// TESTCASE NUMBER: 5
fun case_5(value_1: _SealedClassWithObjects): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2()
@@ -101,7 +101,7 @@ fun case_5(value_1: _SealedClassWithObjects): String {
return ""
}
// CASE DESCRIPTION: Checking objects except the correct one in 'when' with null-check branch.
// TESTCASE NUMBER: 6
fun case_6(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2()
@@ -121,7 +121,7 @@ fun case_6(value_1: _SealedClassWithObjects?): String {
return ""
}
// CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 7
fun case_7(value_1: _SealedClassWithObjects): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -137,7 +137,7 @@ fun case_7(value_1: _SealedClassWithObjects): String {
return ""
}
// CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 8
fun case_8(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -156,7 +156,7 @@ fun case_8(value_1: _SealedClassWithObjects?): String {
return ""
}
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with 'else' branch.
// TESTCASE NUMBER: 9
fun case_9(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value_1) {
is _SealedClassWithObjects -> _ClassLevel2()
@@ -172,4 +172,4 @@ fun case_9(value_1: _SealedClassWithObjects?): String {
checkSubtype<_ClassLevel3>(<!TYPE_MISMATCH!>whenValue<!>)
return ""
}
}
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 1
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 1
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via else branch).
*/
// CASE DESCRIPTION: Checking correctness type (custom types) in 'when' without bound value.
// TESTCASE NUMBER: 1
fun case_1(value_1: Int): String {
val whenValue = when {
value_1 == 0 -> _ClassLevel2()
@@ -26,7 +26,7 @@ fun case_1(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking correctness type (custom types) in 'when' with bound value.
// TESTCASE NUMBER: 2
fun case_2(value_1: Int): String {
val whenValue = when (value_1) {
0 -> _ClassLevel2()
@@ -42,9 +42,9 @@ fun case_2(value_1: Int): String {
}
/*
CASE DESCRIPTION: Checking correctness type (numbers) in 'when' without bound value.
UNEXPECTED BEHAVIOUR
ISSUES: KT-25268
* TESTCASE NUMBER: 3
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25268
*/
fun case_3(value_1: Int): String {
val whenValue = when {
@@ -64,9 +64,9 @@ fun case_3(value_1: Int): String {
}
/*
CASE DESCRIPTION: Checking correctness type (numbers) in 'when' with bound value.
UNEXPECTED BEHAVIOUR
ISSUES: KT-25268
* TESTCASE NUMBER: 4
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25268
*/
fun case_4(value_1: Int): String {
val whenValue = when (value_1) {
@@ -85,7 +85,7 @@ fun case_4(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' without bound value.
// TESTCASE NUMBER: 5
fun case_5(value_1: Int): String {
val whenValue = when {
value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -100,7 +100,7 @@ fun case_5(value_1: Int): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with bound value.
// TESTCASE NUMBER: 6
fun case_6(value_1: Int): String {
val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -3,16 +3,16 @@
// !WITH_ENUM_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 2
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 2
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via enum).
*/
// CASE DESCRIPTION: Checking correct type in 'when'.
// TESTCASE NUMBER: 1
fun case_1(value_1: _EnumClass): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2()
@@ -27,7 +27,7 @@ fun case_1(value_1: _EnumClass): String {
return ""
}
// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: _EnumClass?): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2()
@@ -43,7 +43,7 @@ fun case_2(value_1: _EnumClass?): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 3
fun case_3(value_1: _EnumClass): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -58,7 +58,7 @@ fun case_3(value_1: _EnumClass): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: _EnumClass?): String {
val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -2,16 +2,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 3
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 3
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via boolean bound value).
*/
// CASE DESCRIPTION: Checking correct type in 'when'.
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean): String {
val whenValue = when (value_1) {
true -> _ClassLevel2()
@@ -24,7 +24,7 @@ fun case_1(value_1: Boolean): String {
return ""
}
// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: Boolean?): String {
val whenValue = when (value_1) {
true -> _ClassLevel2()
@@ -39,7 +39,7 @@ fun case_2(value_1: Boolean?): String {
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 3
fun case_3(value_1: Boolean): String {
val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -53,7 +53,7 @@ fun case_3(value_1: Boolean): String {
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: Boolean?): String {
val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -3,16 +3,16 @@
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTIONS: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 4
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class).
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SECTIONS: when-expression
* PARAGRAPH: 9
* SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
* NUMBER: 4
* DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class).
*/
// CASE DESCRIPTION: Checking correct type in 'when'.
// TESTCASE NUMBER: 1
fun case_1(value_1: _SealedClass): String {
val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2()
@@ -26,7 +26,7 @@ fun case_1(value_1: _SealedClass): String {
return ""
}
// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch.
// TESTCASE NUMBER: 2
fun case_2(value_1: _SealedClass?): String {
val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2()
@@ -41,7 +41,7 @@ fun case_2(value_1: _SealedClass?): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'.
// TESTCASE NUMBER: 3
fun case_3(value_1: _SealedClass): String {
val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -55,7 +55,7 @@ fun case_3(value_1: _SealedClass): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch.
// TESTCASE NUMBER: 4
fun case_4(value_1: _SealedClass?): String {
val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -70,7 +70,7 @@ fun case_4(value_1: _SealedClass?): String {
return ""
}
// CASE DESCRIPTION: Checking correct type in 'when' (equality with objects).
// TESTCASE NUMBER: 5
fun case_5(value_1: _SealedClassWithObjects): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2()
@@ -84,7 +84,7 @@ fun case_5(value_1: _SealedClassWithObjects): String {
return ""
}
// CASE DESCRIPTION: Checking correct type in 'when' (equality with objects) with null-check branch.
// TESTCASE NUMBER: 6
fun case_6(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2()
@@ -99,7 +99,7 @@ fun case_6(value_1: _SealedClassWithObjects?): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' (equality with objects).
// TESTCASE NUMBER: 7
fun case_7(value_1: _SealedClassWithObjects): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -113,7 +113,7 @@ fun case_7(value_1: _SealedClassWithObjects): String {
return ""
}
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch (equality with objects).
// TESTCASE NUMBER: 8
fun case_8(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
@@ -128,7 +128,7 @@ fun case_8(value_1: _SealedClassWithObjects?): String {
return ""
}
// CASE DESCRIPTION: Checking correct basic type (Int) in 'when' with.
// TESTCASE NUMBER: 9
fun case_9(value_1: _SealedClassWithObjects): String {
val whenValue = when (value_1) {
<!USELESS_IS_CHECK!>is _SealedClassWithObjects<!> -> 10
@@ -138,4 +138,4 @@ fun case_9(value_1: _SealedClassWithObjects): String {
checkSubtype<Int>(whenValue)
return ""
}
}