[Spec tests] Add tests for elvis-expression
This commit is contained in:
compiler/tests-spec/testData/codegen/box/linked/expressions/elvis-operator-expression/p-1/pos/2.1.kt
Vendored
+32
@@ -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()
|
||||
Vendored
+23
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user