[Spec tests] Add tests for prefix-expressions, unary-minus-expression and unary-minus-expression
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, prefix-expressions, unary-minus-expression -> paragraph 2 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, prefix-expressions, unary-minus-expression -> paragraph 1 -> sentence 2
|
||||
* expressions, prefix-expressions, unary-minus-expression -> paragraph 1 -> sentence 1
|
||||
* expressions, prefix-expressions, unary-minus-expression -> paragraph 3 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: exactly the same as A.unaryMinus() where unaryMinus is a valid operator function available in the current scope.
|
||||
*/
|
||||
|
||||
class A(var a: Int) {
|
||||
var isCalled = false
|
||||
operator fun unaryMinus(): A {
|
||||
isCalled = true
|
||||
return A(a)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A(-1)
|
||||
val a1 = -a
|
||||
if (!a1.isCalled && a.isCalled) {
|
||||
return "OK"
|
||||
}
|
||||
return "NOK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"2": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "exactly the same as A.unaryMinus() where unaryMinus is a valid operator function available in the current scope.",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"pos": {
|
||||
"2": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "exactly the same as A.unaryMinus() where unaryMinus is a valid operator function available in the current scope.",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/prefix-expressions/unary-minus-expression/p-2/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, prefix-expressions, unary-plus-expression -> paragraph 2 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, prefix-expressions, unary-plus-expression -> paragraph 1 -> sentence 1
|
||||
* expressions, prefix-expressions, unary-plus-expression -> paragraph 1 -> sentence 2
|
||||
* expressions, prefix-expressions, unary-plus-expression -> paragraph 3 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: +A is exactly the same as A.unaryPlus() where unaryMinus is a valid operator function available in the current scope.
|
||||
*/
|
||||
|
||||
class A(var a: Int) {
|
||||
var isCalled = false
|
||||
operator fun unaryPlus(): A {
|
||||
isCalled = true
|
||||
return A(a)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A(-1)
|
||||
val a1 = +a
|
||||
if (!a1.isCalled && a.isCalled) {
|
||||
return "OK"
|
||||
}
|
||||
return "NOK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"2": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "+A is exactly the same as A.unaryPlus() where unaryMinus is a valid operator function available in the current scope.",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "+A is exactly the same as A.unaryPlus() where unaryMinus is a valid operator function available in the current scope.",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/prefix-expressions/unary-plus-expression/p-2/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user