[Spec tests] Review fix tests for try-expression and if-expression

This commit is contained in:
anastasiia.spaseeva
2019-12-16 17:19:52 +03:00
parent e865327386
commit bd979a12de
21 changed files with 765 additions and 35 deletions
@@ -0,0 +1,15 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, conditional-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: if-expression: check the correct branch is evaluating
*/
fun box(): String {
if (true) return "OK" else "false branch"
return "NOK"
}
@@ -0,0 +1,16 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, conditional-expression -> paragraph 1 -> sentence 2
* NUMBER: 2
* DESCRIPTION: if-expression: check the correct branch is evaluating
*/
fun box(): String {
if (false) "true" else return "OK"
return "NOK"
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, conditional-expression -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, conditional-expression -> paragraph 4 -> sentence 2
* NUMBER: 3
* DESCRIPTION: if-expression: check the correct branch is evaluating
*/
fun box(): String {
if (false) return "NOK"
return "OK"
}
@@ -0,0 +1,16 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, conditional-expression -> paragraph 1 -> sentence 2
* NUMBER: 4
* DESCRIPTION: if-expression: check the correct branch is evaluating
*/
fun box(): String {
if (false) else return "OK"
return "NOK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, conditional-expression -> paragraph 2 -> sentence 1
* NUMBER: 1
* DESCRIPTION:
*/
fun box(): String {
if (true) else;
return "OK"
}
@@ -0,0 +1,57 @@
{
"1": {
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "if-expression: check the correct branch is evaluating",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "if-expression: check the correct branch is evaluating",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "if-expression: check the correct branch is evaluating",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "if-expression: check the correct branch is evaluating",
"unexpectedBehaviour": false
}
]
}
},
"4": {
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "if-expression: check the correct branch is evaluating",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/conditional-expression/p-1/pos/2.3.kt",
"unexpectedBehaviour": false
}
]
}
},
"2": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -15,7 +15,6 @@ fun box(): String {
var isTryExecuted = false
var isCatched = false
var isFinallyExecuted = false
var isExecutedFully = false
try {
isTryExecuted = true
} catch (e: Exception) {
@@ -23,7 +22,6 @@ fun box(): String {
} finally {
isFinallyExecuted = true
}
isExecutedFully = true
return if (isTryExecuted && !isCatched && isFinallyExecuted && isExecutedFully) "OK"
return if (isTryExecuted && !isCatched && isFinallyExecuted) "OK"
else "NOK"
}
@@ -16,7 +16,6 @@ fun box(): String {
var isTryExecuted = false
var isCatched = false
var isFinallyExecuted = false
var isExecutedFully = false
try {
isTryExecuted = true
throwException(true)
@@ -25,7 +24,6 @@ fun box(): String {
} finally {
isFinallyExecuted = true
}
isExecutedFully = true
return if (isTryExecuted &&isCatched && isFinallyExecuted && isExecutedFully) "OK"
return if (isTryExecuted &&isCatched && isFinallyExecuted) "OK"
else "NOK"
}
@@ -19,7 +19,6 @@ fun box(): String {
var isTryExecuted = false
var isCatched = false
var isFinallyExecuted = false
var isExecutedFully = false
var isTryExpressionPropagated = false
try {
@@ -35,12 +34,10 @@ fun box(): String {
isTryExpressionPropagated = true
}
isExecutedFully = true
return if (isTryExecuted &&
!isCatched &&
isFinallyExecuted &&
isTryExpressionPropagated &&
isExecutedFully
isTryExpressionPropagated
) "OK"
else "NOK"
}