[Spec tests] Add tests for KT_35565 (local-property-declaration)

This commit is contained in:
anastasiia.spaseeva
2019-12-19 14:15:56 +03:00
parent 31df799103
commit d4a83d535c
4 changed files with 130 additions and 3 deletions
@@ -0,0 +1,41 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -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-218
* PLACE: declarations, property-declaration, local-property-declaration -> paragraph 1 -> sentence 1
* RELEVANT PLACES: declarations, property-declaration, property-initialization -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: All non-abstract properties must be definitely initialized before their first use.
*/
/*
* TESTCASE NUMBER: 1
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-35565
*/
fun case1() {
val x1: String
val x: Boolean
try {
val x0: Boolean = (throw Exception()) || true
!x // UNINITIALIZED_VARIABLE should be
val a: Int = x1.toInt() // UNINITIALIZED_VARIABLE should be
} catch (e: Exception) {
}
}
/*
* TESTCASE NUMBER: 2
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-35565
*/
fun case2() {
val x: Boolean = false
try {
x = (throw Exception()) || true //VAL_REASSIGNMENT should be
} catch (e: Exception) {
}
}
@@ -0,0 +1,14 @@
{
"1": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "All non-abstract properties must be definitely initialized before their first use.",
"unexpectedBehaviour": true
}
]
}
}
}
@@ -0,0 +1,15 @@
{
"1": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "All non-abstract properties must be definitely initialized before their first use.",
"path": "compiler/tests-spec/testData/diagnostics/linked/declarations/property-declaration/local-property-declaration/p-1/neg/1.1.kt",
"unexpectedBehaviour": true
}
]
}
}
}