[Spec tests] Add tests for character-literals

This commit is contained in:
anastasiia.spaseeva
2019-12-12 18:57:32 +03:00
parent 8187405dbd
commit 3aa3f0c50c
10 changed files with 3534 additions and 0 deletions
@@ -0,0 +1,45 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, constant-literals, character-literals -> paragraph 1 -> sentence 1
* RELEVANT PLACES: expressions, constant-literals, character-literals -> paragraph 1 -> sentence 2
* expressions, constant-literals, character-literals -> paragraph 2 -> sentence 1
* expressions, constant-literals, character-literals -> paragraph 2 -> sentence 2
* expressions, constant-literals, character-literals -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: A character literal defines a constant holding a unicode character value
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
val c = <!EMPTY_CHARACTER_LITERAL!>''<!>
}
// TESTCASE NUMBER: 2
fun case2() {
val c2: Char = <!EMPTY_CHARACTER_LITERAL!>''<!><!SYNTAX!>'<!>
val c3: Char = '<!ILLEGAL_ESCAPE!>\<!>'
}
// TESTCASE NUMBER: 3
fun case3() {
val c1: Char = <!TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL!>'B a'<!>
val c2: Char = <!TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL!>' '<!>
val c3: Char = <!TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL!>'Ba'<!>
}
// TESTCASE NUMBER: 4
fun case4() {
val cOutOfRaneMin = <!TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL!>'𐀀'<!> //u+10000
val cOutOfRangeAroundMax = <!TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL!>'󠇿󠇿󟿿'<!> //u+Dfffff
}
@@ -0,0 +1,30 @@
// !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, constant-literals, character-literals -> paragraph 1 -> sentence 1
* RELEVANT PLACES: expressions, constant-literals, character-literals -> paragraph 1 -> sentence 2
* expressions, constant-literals, character-literals -> paragraph 2 -> sentence 1
* expressions, constant-literals, character-literals -> paragraph 2 -> sentence 2
* expressions, constant-literals, character-literals -> paragraph 4 -> sentence 1
* expressions, constant-literals, character-literals -> paragraph 6 -> sentence 1
* NUMBER: 1
* DESCRIPTION: A character literal defines a constant holding a unicode character value
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
val c = ' ' //u+0020
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char")!>c<!>
c checkType { check<Char>()}
val cMax = '￿' //u+ffff
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char")!>cMax<!>
cMax checkType { check<Char>()}
}
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, constant-literals, character-literals -> paragraph 4 -> sentence 1
* RELEVANT PLACES: expressions, constant-literals, character-literals -> paragraph 5 -> sentence 1
* NUMBER: 1
* DESCRIPTION: to define a character the unicode codepoint escaped symbol \u could be used with followed by exactly four hexadecimal digits.
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
//less then four hex digits
val c0 = '<!ILLEGAL_ESCAPE!>\u<!>'
val c1 = '<!ILLEGAL_ESCAPE!>\uf<!>'
val c2 = '<!ILLEGAL_ESCAPE!>\u1f<!>'
val c3 = '<!ILLEGAL_ESCAPE!>\u1wf<!>'
//more then four hex digits
val c4 = '<!ILLEGAL_ESCAPE!>\u1wF2f<!>'
}
// TESTCASE NUMBER: 2
fun case2() {
//not hex
val c1 = '<!ILLEGAL_ESCAPE!>\u000g<!>'
val c2 = '<!ILLEGAL_ESCAPE!>\u000G<!>'
}
@@ -0,0 +1,31 @@
// !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, constant-literals, character-literals -> paragraph 4 -> sentence 1
* RELEVANT PLACES: expressions, constant-literals, character-literals -> paragraph 6 -> sentence 1
* NUMBER: 1
* DESCRIPTION: to define a character the unicode codepoint escaped symbol \u could be used with followed by exactly four hexadecimal digits.
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
val cMin = '\u0000'
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char")!>cMin<!>
cMin checkType { check<Char>()}
val cMax = '\uffff'
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char")!>cMax<!>
cMax checkType { check<Char>()}
val cMax1 = '\uFFFF'
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char")!>cMax1<!>
cMax1 checkType { check<Char>()}
}
@@ -0,0 +1,107 @@
{
"1": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 4,
"description": "A character literal defines a constant holding a unicode character value",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 4,
"description": "A character literal defines a constant holding a unicode character value",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 1,
"description": "A character literal defines a constant holding a unicode character value",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 1,
"description": "A character literal defines a constant holding a unicode character value",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
},
"4": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "to define a character the unicode codepoint escaped symbol \\u could be used with followed by exactly four hexadecimal digits.",
"unexpectedBehaviour": false
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 512,
"description": "to define a character the unicode code point escaped symbol \\u could be used with followed by exactly four hexadecimal digits",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 1,
"description": "to define a character the unicode codepoint escaped symbol \\u could be used with followed by exactly four hexadecimal digits.",
"unexpectedBehaviour": false
}
]
}
},
"5": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "to define a character the unicode codepoint escaped symbol \\u could be used with followed by exactly four hexadecimal digits.",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/neg/1.1.kt",
"unexpectedBehaviour": false
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 512,
"description": "to define a character the unicode code point escaped symbol \\u could be used with followed by exactly four hexadecimal digits",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/pos/1.2.kt",
"unexpectedBehaviour": false
}
]
}
},
"6": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 1,
"description": "to define a character the unicode codepoint escaped symbol \\u could be used with followed by exactly four hexadecimal digits.",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}