[Spec tests] Add tests for expressions and statements

This commit is contained in:
anastasiia.spaseeva
2020-01-10 17:00:43 +03:00
committed by Victor Petukhov
parent 5f4a94a1b3
commit 5986ffae1e
108 changed files with 4221 additions and 26 deletions
@@ -8,6 +8,7 @@
* SPEC VERSION: 0.1-218
* PLACE: expressions, additive-expression -> paragraph 4 -> sentence 1
* RELEVANT PLACES: expressions, additive-expression -> paragraph 4 -> sentence 2
* overloadable-operators -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: The return type of these functions is not restricted.
* HELPERS: checkType
@@ -1,24 +1,4 @@
{
"3": {
"pos": {
"1": [
{
"specVersion": "0.1-220",
"casesNumber": 0,
"description": "Class vs package",
"path": "compiler/testData/diagnostics/tests/callableReference/classVsPackage.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-220",
"casesNumber": 0,
"description": "Bare type",
"path": "compiler/testData/diagnostics/tests/callableReference/bareType.kt",
"unexpectedBehaviour": false
}
]
}
},
"11": {
"pos": {
"3": [
@@ -31,5 +11,18 @@
}
]
}
},
"3": {
"pos": {
"1": [
{
"specVersion": "0.1-220",
"casesNumber": 0,
"description": "Bare type",
"path": "compiler/testData/diagnostics/tests/callableReference/bareType.kt",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,28 @@
{
"9": {
"pos": {
"2": [
{
"specVersion": "0.1-220",
"casesNumber": 0,
"description": "Correct info after array like call",
"path": "compiler/testData/diagnostics/tests/callableReference/correctInfoAfterArrayLikeCall.kt",
"unexpectedBehaviour": false
}
]
}
},
"8": {
"pos": {
"1": [
{
"specVersion": "0.1-220",
"casesNumber": 0,
"description": "Correct info after array like call",
"path": "compiler/testData/diagnostics/tests/callableReference/correctInfoAfterArrayLikeCall.kt",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -7,6 +7,7 @@
*
* SPEC VERSION: 0.1-220
* PLACE: expressions, comparison-expressions -> paragraph 1 -> sentence 2
* RELEVANT PLACES: overloadable-operators -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: <, >, <= and >= operators are overloadable
*/
@@ -7,6 +7,7 @@
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, comparison-expressions -> paragraph 4 -> sentence 1
* RELEVANT PLACES: overloadable-operators -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: The compareTo operator function must have return type kotlin.Int
*/
@@ -7,6 +7,7 @@
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, comparison-expressions -> paragraph 5 -> sentence 1
* RELEVANT PLACES: overloadable-operators -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: All comparison expressions always have type kotlin.Boolean.
* HELPERS: checkType
@@ -0,0 +1,38 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-222
* PLACE: expressions, jump-expressions, break-expression -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: A break expression is a jump expression allowed only within loop bodies.
*/
// TESTCASE NUMBER: 1
fun case1() {
val inputList = listOf(1, 2, 3)
inputList.forEach {
listOf("1.", "2.", "3.").forEach {
if (true) <!NOT_A_LOOP_LABEL!>break<!LABEL_NAME_CLASH!>@forEach<!><!>
}
}
}
// TESTCASE NUMBER: 2
fun case2() {
val inputList = listOf(1, 2, 3)
inputList.forEach {
listOf("1.", "2.", "3.").forEach {
if (true) <!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>
}
}
}
// TESTCASE NUMBER: 3
fun case3() {
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>
}
@@ -0,0 +1,14 @@
{
"1": {
"neg": {
"1": [
{
"specVersion": "0.1-222",
"casesNumber": 3,
"description": "A break expression is a jump expression allowed only within loop bodies.",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,38 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-222
* PLACE: expressions, jump-expressions, continue-expression -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: A continue expression is a jump expression allowed only within loop bodies.
*/
// TESTCASE NUMBER: 1
fun case1() {
val inputList = listOf(1, 2, 3)
inputList.forEach {
listOf("1.", "2.", "3.").forEach {
if (true) <!NOT_A_LOOP_LABEL!>continue<!LABEL_NAME_CLASH!>@forEach<!><!>
}
}
}
// TESTCASE NUMBER: 2
fun case2() {
val inputList = listOf(1, 2, 3)
inputList.forEach {
listOf("1.", "2.", "3.").forEach {
if (true) <!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
}
}
}
// TESTCASE NUMBER: 3
fun case3() {
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
}
@@ -0,0 +1,14 @@
{
"1": {
"neg": {
"1": [
{
"specVersion": "0.1-222",
"casesNumber": 3,
"description": "A continue expression is a jump expression allowed only within loop bodies.",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,63 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-222
* PLACE: expressions, jump-expressions, return-expressions -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION:
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
val x = fooCase1()
x checkType { check<Case1>() }
}
class Case1
fun fooCase1(): Case1 = TODO()
// TESTCASE NUMBER: 2
fun case2() {
val x = fooCase2()
x checkType { check<Case1>() }
}
fun fooCase2(): Case1 {
val x = ""
return Case1()
<!UNREACHABLE_CODE!>val y = ""<!>
}
// TESTCASE NUMBER: 3
fun case3() {
val x = object : Case13 {
override fun fooCase3(): Int {
return 1
<!UNREACHABLE_CODE!>"str"<!>
<!UNREACHABLE_CODE!>3<!>
}
}.fooCase3()
x checkType { check<Int>() }
}
interface Case13 {
fun fooCase3(): Int
}
// TESTCASE NUMBER: 4
fun case4() {
val x = fooCase4()
x checkType { check<kotlin.Unit>() }
}
fun fooCase4() {
return
}
@@ -1,4 +1,16 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-222",
"casesNumber": 4,
"description": "",
"unexpectedBehaviour": false
}
]
}
},
"5": {
"neg": {
"2": [
@@ -10,6 +10,7 @@
* DESCRIPTION: Non-exhaustive when using nullable boolean values.
*/
// TESTCASE NUMBER: 1
fun case_1(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> ""
@@ -0,0 +1,33 @@
{
"4": {
"neg": {
"1": [
{
"specVersion": "0.1-220",
"casesNumber": 1,
"description": "\u003c, \u003e, \u003c\u003d and \u003e\u003d operators are overloadable",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/comparison-expressions/p-1/neg/2.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 4,
"description": "The compareTo operator function must have return type kotlin.Int",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/comparison-expressions/p-4/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 4,
"description": "All comparison expressions always have type kotlin.Boolean.",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/comparison-expressions/p-5/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: statements, assignments, operator-assignments -> paragraph 2 -> sentence 1
* RELEVANT PLACES: statements, assignments, operator-assignments -> paragraph 2 -> sentence 2
* statements, assignments, operator-assignments -> paragraph 2 -> sentence 3
* statements, assignments, operator-assignments -> paragraph 3 -> sentence 1
* NUMBER: 1
* DESCRIPTION: An operator assignment A+=B
*/
class B(var a: Int) {
operator fun plus(value: Int): B {
a= a + value
return this
}
operator fun plusAssign(value: Int): Unit {
a= a + value
}
}
// TESTCASE NUMBER: 1
fun case1() {
var b = B(1)
b <!ASSIGN_OPERATOR_AMBIGUITY!>+=<!> 1
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: statements, assignments, operator-assignments -> paragraph 2 -> sentence 1
* RELEVANT PLACES: statements, assignments, operator-assignments -> paragraph 2 -> sentence 2
* statements, assignments, operator-assignments -> paragraph 2 -> sentence 3
* statements, assignments, operator-assignments -> paragraph 3 -> sentence 1
* NUMBER: 1
* DESCRIPTION: An operator assignment A+=B
*/
class B(var a: Int) {
operator fun plus(value: Int): B {
a= a + value
return this
}
operator fun plusAssign(value: Int): Unit {
a= a + value
}
}
// TESTCASE NUMBER: 1
fun case1() {
val b = B(1)
b += 1
}
@@ -0,0 +1,42 @@
{
"2": {
"neg": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 1,
"description": "An operator assignment A+\u003dB",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-253",
"casesNumber": 1,
"description": "An operator assignment A+\u003dB",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/assignments/operator-assignments/p-2/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 1,
"description": "An operator assignment A+\u003dB",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-253",
"casesNumber": 1,
"description": "An operator assignment A+\u003dB",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/assignments/operator-assignments/p-2/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,69 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-222
* PLACE: statements, assignments -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: Both left-hand and right-hand sides of an assignment must be expressions
*/
/*
* TESTCASE NUMBER: 1
* NOTE: right-hand side of an assignment must be expression
*/
fun case1() {
val x = <!EXPRESSION_EXPECTED!>for (<!SYNTAX!><!>) { }<!>
val y = <!EXPRESSION_EXPECTED!>for (<!NAME_SHADOWING!>x<!> in 1..2) { }<!>
val a = <!EXPRESSION_EXPECTED!>while (<!SYNTAX!><!>) { }<!>
val b = <!EXPRESSION_EXPECTED!>while (false) { }<!>
val c = <!EXPRESSION_EXPECTED!>while (<!SYNTAX!><!>) <!>;
}
/*
* TESTCASE NUMBER: 2
* NOTE: right-hand side of an assignment must be expression
*/
fun case2() {
var x = <!EXPRESSION_EXPECTED!>for (<!SYNTAX!><!>) { }<!>
var y = <!EXPRESSION_EXPECTED!>for (<!NAME_SHADOWING!>x<!> in 1..2) { }<!>
var a = <!EXPRESSION_EXPECTED!>while (<!SYNTAX!><!>) { }<!>
var b = <!EXPRESSION_EXPECTED!>while (false) { }<!>
var c = <!EXPRESSION_EXPECTED!>while (<!SYNTAX!><!>) <!>;
}
/*
* TESTCASE NUMBER: 3
* NOTE: right-hand side of an assignment must be expression
*/
fun case3() {
var x :Any?
var y :Any?
var a :Any?
var b :Any?
var c :Any?
x = <!EXPRESSION_EXPECTED!>for (<!SYNTAX!><!>) { }<!>
y = <!EXPRESSION_EXPECTED!>for (<!NAME_SHADOWING!>x<!> in 1..2) { }<!>
a = <!EXPRESSION_EXPECTED!>while (<!SYNTAX!><!>) { }<!>
b = <!EXPRESSION_EXPECTED!>while (false) { }<!>
c = <!EXPRESSION_EXPECTED!>while (<!SYNTAX!><!>) <!>;
}
/*
* TESTCASE NUMBER: 4
* NOTE: left-hand side of an assignment must be expression
*/
fun case4() {
<!EXPRESSION_EXPECTED!>for (x in 1..2) {}<!> <!UNREACHABLE_CODE!>=<!> TODO();
<!UNREACHABLE_CODE!><!EXPRESSION_EXPECTED!>while (false) { }<!> = TODO()<!>
}
@@ -0,0 +1,41 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-222
* PLACE: statements, assignments -> paragraph 2 -> sentence 1
* RELEVANT PLACES: statements, assignments -> paragraph 3 -> sentence 1
* statements, assignments, simple-assignments -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: Check the expression is not assignable if an identifier referring to an unmutable property
*/
/*
* TESTCASE NUMBER: 1
* NOTE: an identifier referring to a unmutable property
*/
fun case1() {
val x : Any
x = "0"
<!VAL_REASSIGNMENT!>x<!> = 1
x = 2.0
val y : Any = 0
<!VAL_REASSIGNMENT!>y<!> = "0"
y = 1.0
}
/*
* TESTCASE NUMBER: 2
* NOTE: an identifier referring to a unmutable property
*/
fun case2() {
val x : Any
mutableListOf(0).forEach({ <!CAPTURED_VAL_INITIALIZATION!>x<!> = it })
val y : Any = 1
mutableListOf(1).forEach({ <!VAL_REASSIGNMENT!>y<!> = it })
}
@@ -0,0 +1,59 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNSAFE_CALL -UNREACHABLE_CODE -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-222
* PLACE: statements, assignments -> paragraph 2 -> sentence 1
* RELEVANT PLACES: statements, assignments -> paragraph 3 -> sentence 2
* statements, assignments, simple-assignments -> paragraph 1 -> sentence 2
* NUMBER: 2
* DESCRIPTION: Check the expression is not assignable if a navigation expression referring to an unmutable property
*/
/*
* TESTCASE NUMBER: 1
* NOTE: a navigation expression referring to a unmutable property
*/
fun case1() {
val x : Case1? = Case1()
<!VAL_REASSIGNMENT!>x.x<!> = "0"
<!VAL_REASSIGNMENT!>x?.x<!> = "0"
<!VARIABLE_EXPECTED!>x::x<!> = TODO()
}
class Case1{
val x : Any?
get() { TODO() }
}
/*
* TESTCASE NUMBER: 2
* NOTE: an identifier referring to a ununmutable property
*/
fun case2() {
val x : Case2? = Case2(null)
<!VAL_REASSIGNMENT!>x.x<!> = "0"
<!VAL_REASSIGNMENT!>x?.x<!> = "0"
<!VARIABLE_EXPECTED!>x::x<!> = TODO()
}
class Case2(val x: Any?) {}
/*
* TESTCASE NUMBER: 3
* NOTE: an identifier referring to a ununmutable property
*/
fun case3() {
val x : Case3? = Case3()
<!VAL_REASSIGNMENT!>x.x<!> = "0"
<!VAL_REASSIGNMENT!>x?.x<!> = "0"
<!VARIABLE_EXPECTED!>x::x<!> = TODO()
}
class Case3() {
val x: Any? = null
}
@@ -0,0 +1,15 @@
{
"1": {
"neg": {
"2": [
{
"specVersion": "0.1-222",
"casesNumber": 4,
"description": "Both left-hand and right-hand sides of an assignment must be expressions",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/assignments/p-1/neg/2.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -1,7 +1,44 @@
{
"1": {
"neg": {
"2": [
{
"specVersion": "0.1-222",
"casesNumber": 4,
"description": "Both left-hand and right-hand sides of an assignment must be expressions",
"unexpectedBehaviour": false
}
]
}
},
"2": {
"neg": {
"1": [
{
"specVersion": "0.1-222",
"casesNumber": 3,
"description": "Check the expression is not assignable if a navigation expression referring to an unmutable property",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-222",
"casesNumber": 2,
"description": "Check the expression is not assignable if an identifier referring to an unmutable property",
"unexpectedBehaviour": false
}
]
}
},
"3": {
"neg": {
"2": [
{
"specVersion": "0.1-222",
"casesNumber": 3,
"description": "Check the expression is not assignable if a navigation expression referring to an unmutable property",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/assignments/p-2/neg/1.2.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-213",
"casesNumber": 2,
@@ -16,6 +53,15 @@
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-decrement-expression/p-4/neg/1.1.kt",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-222",
"casesNumber": 2,
"description": "Check the expression is not assignable if an identifier referring to an unmutable property",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/assignments/p-2/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
@@ -0,0 +1,33 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNREACHABLE_CODE
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: statements, loop-statements, do-while-loop-statement -> paragraph 1 -> sentence 1
* RELEVANT PLACES: statements, loop-statements, do-while-loop-statement -> paragraph 3 -> sentence 1
* statements, loop-statements, do-while-loop-statement -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: do-while-loop statement body contains zero statements
*/
// TESTCASE NUMBER: 1
fun case1() {
do {
} while (true)
}
// TESTCASE NUMBER: 2
fun case2() {
do {
} while (false)
}
// TESTCASE NUMBER: 3
fun case3() {
do {
} while (TODO())
}
@@ -0,0 +1,34 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: statements, loop-statements, do-while-loop-statement -> paragraph 3 -> sentence 1
* RELEVANT PLACES: statements, loop-statements, do-while-loop-statement -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: condition expression is not a subtype of kotlin.Boolean.
*/
// TESTCASE NUMBER: 1
fun case1() {
do {
} while (<!TYPE_MISMATCH, TYPE_MISMATCH!>"boo"<!>)
}
// TESTCASE NUMBER: 2
fun case2() {
val condition: Any = true
do {
} while (<!TYPE_MISMATCH, TYPE_MISMATCH!>condition<!>)
}
// TESTCASE NUMBER: 3
fun case3() {
val condition: Boolean? = true
do {
} while (<!TYPE_MISMATCH, TYPE_MISMATCH!>condition<!>)
}
@@ -0,0 +1,48 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 3,
"description": "do-while-loop statement body contains zero statements",
"unexpectedBehaviour": false
}
]
},
"neg": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 3,
"description": "condition expression is not a subtype of kotlin.Boolean.",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/do-while-loop-statement/p-3/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
}
},
"3": {
"pos": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 3,
"description": "do-while-loop statement body contains zero statements",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/do-while-loop-statement/p-1/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
},
"neg": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 3,
"description": "condition expression is not a subtype of kotlin.Boolean.",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNREACHABLE_CODE
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: statements, loop-statements, while-loop-statement -> paragraph 1 -> sentence 1
* RELEVANT PLACES: statements, loop-statements, while-loop-statement -> paragraph 3 -> sentence 1
* NUMBER: 1
* DESCRIPTION: while-loop statement body contains zero statements
*/
// TESTCASE NUMBER: 1
fun case1() {
while (true) {
}
}
// TESTCASE NUMBER: 2
fun case2() {
while (false) {
}
}
// TESTCASE NUMBER: 3
fun case3() {
while (TODO()) {
}
}
@@ -0,0 +1,29 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: statements, loop-statements, while-loop-statement -> paragraph 3 -> sentence 1
* RELEVANT PLACES: statements, loop-statements, while-loop-statement -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: condition expression is not a subtype of kotlin.Boolean.
* HELPERS: checkType
*/
// FILE: KotlinClass.kt
// TESTCASE NUMBER: 1
fun case1() {
val condition: Any = true
while (<!TYPE_MISMATCH!>condition<!> && <!TYPE_MISMATCH!>"true"<!>) {
}
}
// TESTCASE NUMBER: 2
fun case2() {
val condition: Boolean? = true
while (<!TYPE_MISMATCH, TYPE_MISMATCH!>condition<!>) {
}
}
@@ -0,0 +1,48 @@
{
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 3,
"description": "while-loop statement body contains zero statements",
"unexpectedBehaviour": false
}
]
},
"neg": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 2,
"description": "condition expression is not a subtype of kotlin.Boolean.",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/while-loop-statement/p-3/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
}
},
"3": {
"pos": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 3,
"description": "while-loop statement body contains zero statements",
"path": "compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/while-loop-statement/p-1/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
},
"neg": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 2,
"description": "condition expression is not a subtype of kotlin.Boolean.",
"unexpectedBehaviour": false
}
]
}
}
}