[Spec tests] Add tests for elvis-expression

This commit is contained in:
anastasiia.spaseeva
2019-12-23 12:41:17 +03:00
parent 479fa0e7b8
commit 84cf4c5049
6 changed files with 200 additions and 0 deletions
@@ -0,0 +1,32 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, elvis-operator-expression -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, elvis-operator-expression -> paragraph 1 -> sentence 1
* expressions, elvis-operator-expression -> paragraph 2 -> sentence 1
* NUMBER: 1
* DESCRIPTION: Check Elvis evaluation
*/
fun box(): String {
val x : Boolean? = null ?: getNull() ?: A().b ?: getTrue() ?: false
try {
val y = null ?: throw ExcA()
} catch (e: ExcA) {
if (x == true) return "OK"
}
return "NOK"
}
fun getTrue() = true
fun getNull(): Boolean? = null
class A(val b: Boolean? = null)
class ExcA() : Exception()
@@ -0,0 +1,23 @@
{
"1": {
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "Check Elvis evaluation",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "Check Elvis evaluation",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/elvis-operator-expression/p-1/pos/2.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}