[Spec tests] Add codegen tests for logical-disjunction-expression (paragraph 1)
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 2
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
val aval = A()
|
||||
val x = aval.a(false) ||
|
||||
aval.b(false) ||
|
||||
aval.c(true) ||
|
||||
aval.d(true)
|
||||
|
||||
if (aval.a && aval.b && aval.c && !aval.d && x)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
|
||||
|
||||
class A (var a: Boolean = false,
|
||||
var b: Boolean = false,
|
||||
var c: Boolean = false,
|
||||
var d: Boolean = false){
|
||||
|
||||
fun a(a: Boolean): Boolean { this.a = true; return a }
|
||||
|
||||
fun b(a: Boolean): Boolean { this.b = true; return a }
|
||||
|
||||
fun c(a: Boolean): Boolean { this.c = true; return a }
|
||||
|
||||
fun d(a: Boolean): Boolean { this.d = true; return a }
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 2
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 1
|
||||
* NUMBER: 2
|
||||
* DESCRIPTION: operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
val x: Boolean
|
||||
try {
|
||||
x = false || false || true || throw MyException()
|
||||
} catch (e: MyException) {
|
||||
return "NOK"
|
||||
}
|
||||
if (x)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
|
||||
class MyException : Exception() {}
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 2
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 1
|
||||
* NUMBER: 3
|
||||
* DESCRIPTION: operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
val x: Boolean = false
|
||||
try {
|
||||
x = (throw MyException()) || true
|
||||
} catch (e: MyException) {
|
||||
if (!x)
|
||||
return "OK"
|
||||
}
|
||||
return "NOK"
|
||||
}
|
||||
|
||||
class MyException : Exception() {}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"1": {
|
||||
"pos": {
|
||||
"2": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.3.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.2.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user