[Spec tests] Add test for return expression

This commit is contained in:
anastasiia.spaseeva
2019-12-18 17:36:41 +03:00
parent dcfcc9c7b6
commit 1ea5eb6850
5 changed files with 87 additions and 7 deletions
@@ -0,0 +1,22 @@
// !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-218
* PLACE: expressions, jump-expressions, return-expressions -> paragraph 5 -> sentence 2
* NUMBER: 1
* DESCRIPTION: check returning is not allowed from run{...}
*/
// TESTCASE NUMBER: 1
// UNEXPECTED BEHAVIOUR
// ISSUES : KT-35545
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>case1<!>(a: Boolean) = run { println("d"); return <!TYPE_MISMATCH!>true<!> }
// TESTCASE NUMBER: 2
val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>case2<!>
get() = run { println("d"); return <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>true<!> }
@@ -0,0 +1,14 @@
{
"5": {
"neg": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "check returning is not allowed from run{...}",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -178,7 +178,7 @@
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"casesNumber": 3,
"description": "The else condition must also be in the last when entry of when expression, otherwise it is a compile-time error",
"unexpectedBehaviour": false
}