[Spec tests] Add tests for range-expression

This commit is contained in:
anastasiia.spaseeva
2019-12-23 13:43:36 +03:00
parent 84cf4c5049
commit 72358aa52a
6 changed files with 212 additions and 0 deletions
@@ -0,0 +1,33 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, range-expression -> paragraph 2 -> sentence 1
* RELEVANT PLACES: expressions, range-expression -> paragraph 1 -> sentence 1
* expressions, range-expression -> paragraph 1 -> sentence 2
* expressions, range-expression -> paragraph 3 -> sentence 1
* NUMBER: 1
* DESCRIPTION: A..B is exactly the same as A.rangeTo(B)
*/
class A(val a: Int) {
var isRangeToCalled = false
operator fun rangeTo(o: A): MutableList<Int> {
isRangeToCalled = true
val x: MutableList<Int> = mutableListOf<Int>()
for (i in a..o.a)
x.add(i)
return x
}
}
fun box(): String {
val a1 = A(0)
val a2 = A(5)
val x = a1..a2
if (a1.isRangeToCalled && x is MutableList<Int>)
return "OK"
return "NOK"
}
@@ -0,0 +1,27 @@
{
"2": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "A..B is exactly the same as A.rangeTo(B)",
"unexpectedBehaviour": false
}
]
}
},
"1": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "A..B is exactly the same as A.rangeTo(B)",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/range-expression/p-2/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}