[Spec tests] Add tests for boolean-literals (p-1 sentence 2)

This commit is contained in:
anastasiia.spaseeva
2019-12-11 16:41:03 +03:00
parent 744cc54dff
commit fdef51e8b7
4 changed files with 154 additions and 0 deletions
@@ -0,0 +1,63 @@
// !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, boolean-literals -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: checking of type for Boolean values: impossible to use as identifiers
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
val <!SYNTAX!>false<!> : Any = false
val <!SYNTAX!>true<!> : Any = true
}
// TESTCASE NUMBER: 2
fun case2() {
var <!SYNTAX!>false<!> : Any = false
var <!SYNTAX!>true<!> : Any = true
}
// TESTCASE NUMBER: 3
fun case3() {
fun <!SYNTAX!>false<!>() {}
fun <!SYNTAX!>true<!>() {}
}
// TESTCASE NUMBER: 4
fun case4() {
fun <!SYNTAX!>false<!>() = "false"
fun <!SYNTAX!>true<!>() = "true"
}
// TESTCASE NUMBER: 5
fun case5() {
class <!SYNTAX!>false<!> (){}
class <!SYNTAX!>true<!> (){}
}
// TESTCASE NUMBER: 6
fun case6() {
class <!SYNTAX!>false<!> : <!SYNTAX!>true<!>{}
}
interface <!SYNTAX!>true<!>{}
interface <!SYNTAX!>false<!>{}
// TESTCASE NUMBER: 7
fun case7() {
class <!SYNTAX!>false<!> : <!SYNTAX!>false<!>{}
}
@@ -0,0 +1,65 @@
// !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, boolean-literals -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: checking of type for Boolean values: possible to use as identifiers if surround with backticks
* HELPERS: checkType
*/
// TESTCASE NUMBER: 1
fun case1() {
val `false` : Any = false
val `true` : Any = true
}
// TESTCASE NUMBER: 2
fun case2() {
var `false` : Any = false
var `true` : Any = true
}
// TESTCASE NUMBER: 3
fun case3() {
fun `false`() {}
fun `true`() {}
}
// TESTCASE NUMBER: 4
fun case4() {
fun `false`() = "false"
fun `true`() = "true"
}
// TESTCASE NUMBER: 5
fun case5() {
class `false` (){}
class `true` (){}
}
// TESTCASE NUMBER: 6
fun case6() {
class `false` : `true`{}
}
interface `true`{}
interface `false`{}
// TESTCASE NUMBER: 7
fun case7() {
class `true` : `false`{}
}
@@ -1,6 +1,14 @@
{
"1": {
"neg": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 7,
"description": "checking of type for Boolean values: impossible to use as identifiers",
"unexpectedBehaviour": false
}
],
"3": [
{
"specVersion": "0.1-100",
@@ -11,6 +19,14 @@
]
},
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 7,
"description": "checking of type for Boolean values: possible to use as identifiers if surround with backticks",
"unexpectedBehaviour": false
}
],
"3": [
{
"specVersion": "0.1-100",
@@ -523,6 +523,11 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/p-1/neg/2.1.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/p-1/neg/3.1.kt");
@@ -541,6 +546,11 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/p-1/pos/2.1.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/p-1/pos/3.1.kt");