[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,41 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, range-expression -> paragraph 4 -> sentence 1
* RELEVANT PLACES: expressions, range-expression -> paragraph 4 -> sentence 2
* NUMBER: 1
* DESCRIPTION: The return type of range operator is not restricted.
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
class Case1() {
operator fun rangeTo(o: Case1): Nothing?{
TODO()
}
}
fun case1() {
val x = Case1() .. Case1()
<!DEBUG_INFO_CONSTANT, DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_CONSTANT!>x<!> checkType { check<Nothing?>() }
}
// TESTCASE NUMBER: 2
class Case2() {
operator fun rangeTo(o: Case2): Any?{
TODO()
}
}
fun case2() {
val x = Case2() .. Case2()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x checkType { check<Any?>() }
}
@@ -0,0 +1,23 @@
{
"4": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "The return type of range operator is not restricted.",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "The return type of range operator is not restricted.",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/range-expression/p-4/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}