[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,23 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, constant-literals, character-literals -> paragraph 4 -> sentence 2
* NUMBER: 1
* DESCRIPTION: character literal codepoint is equal to the unicode symbol codes
*/
fun box(): String {
val a = '\u0000'
val c = ' ' //u+0020
val cMax = '￿' //u+ffff
val aMax = '\uffff'
if (a.toShort() == 0x0000.toShort()
&& c.toShort() == 0x0020.toShort()
&& cMax.toShort() == 0xffff.toShort()
&& aMax.toShort() == 0xffff.toShort())
return "OK"
return "NOK"
}
@@ -0,0 +1,14 @@
{
"4": {
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "character literal codepoint is equal to the unicode symbol codes",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -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
}
]
}
}
}
@@ -568,6 +568,122 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Character_literals extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInCharacter_literals() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_1 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_1() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/neg/1.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/neg"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/pos/1.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-1/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_4 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_4() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/neg/1.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/neg"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/pos/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/pos/1.2.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/character-literals/p-4/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -423,6 +423,50 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Character_literals extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInCharacter_literals() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals/p-4")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_4 extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_4() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals/p-4"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals/p-4/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals/p-4/pos/2.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/character-literals/p-4/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/constant-literals/integer-literals")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)