[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
@@ -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
}
]
}
}
}