From 73ecde6cc3caa6332ea9c52f9e489f018c938289 Mon Sep 17 00:00:00 2001 From: "victor.petukhov" Date: Wed, 31 Oct 2018 13:07:22 +0300 Subject: [PATCH] Add `boolean literals` diagnostic spec tests --- .../boolean-literals/p-1/neg/3.1.kt | 24 +++++++ .../boolean-literals/p-1/neg/3.1.txt | 3 + .../boolean-literals/p-1/pos/3.1.kt | 21 ++++++ .../boolean-literals/p-1/pos/3.1.txt | 3 + .../boolean-literals/p-1/pos/3.2.kt | 21 ++++++ .../boolean-literals/p-1/pos/3.2.txt | 3 + .../DiagnosticsTestSpecGenerated.java | 67 +++++++++++++++++++ 7 files changed, 142 insertions(+) create mode 100644 compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.txt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.txt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.txt diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.kt new file mode 100644 index 00000000000..8570030f11b --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.kt @@ -0,0 +1,24 @@ +// !CHECK_TYPE + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [3] These are strong keywords which cannot be used as identifiers unless [escaped][Escaped identifiers]. + * NUMBER: 1 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY + */ + +// TESTCASE NUMBER: 1 +fun case_1() { + true checkType { _() } + false checkType { _() } + + true checkType { _() } + false checkType { _() } + + true checkType { _() } + false checkType { _() } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.txt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.txt new file mode 100644 index 00000000000..d83cc877305 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.txt @@ -0,0 +1,3 @@ +package + +public fun case_1(): kotlin.Unit diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.kt new file mode 100644 index 00000000000..a9f51df63d0 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.kt @@ -0,0 +1,21 @@ +// !CHECK_TYPE + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [3] These are strong keywords which cannot be used as identifiers unless [escaped][Escaped identifiers]. + * NUMBER: 1 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY + */ + +// TESTCASE NUMBER: 1 +fun case_1() { + true checkType { _() } + false checkType { _() } + + checkSubtype(true) + checkSubtype(false) +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.txt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.txt new file mode 100644 index 00000000000..d83cc877305 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.txt @@ -0,0 +1,3 @@ +package + +public fun case_1(): kotlin.Unit diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.kt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.kt new file mode 100644 index 00000000000..11a37a9e989 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.kt @@ -0,0 +1,21 @@ +// !CHECK_TYPE + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SECTIONS: constant-literals, boolean-literals + * PARAGRAPH: 1 + * SENTENCE: [3] These are strong keywords which cannot be used as identifiers unless [escaped][Escaped identifiers]. + * NUMBER: 2 + * DESCRIPTION: The use of Boolean literals as the identifier (with backtick) in the class. + * NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY + */ + +// TESTCASE NUMBER: 1 +fun case_1() { + checkSubtype(true) + checkSubtype(false) + + checkSubtype(true) + checkSubtype(false) +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.txt b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.txt new file mode 100644 index 00000000000..d83cc877305 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.txt @@ -0,0 +1,3 @@ +package + +public fun case_1(): kotlin.Unit diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java index 68a8dabd0e4..656642e75d7 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestSpecGenerated.java @@ -53,6 +53,73 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/constant-literals"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Boolean_literals extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInBoolean_literals() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-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, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInP_1() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-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, TargetBackend.ANY, testDataFilePath); + } + + @TestMetadata("3.1.kt") + public void test3_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg/3.1.kt"); + } + + public void testAllFilesPresentInNeg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-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, TargetBackend.ANY, testDataFilePath); + } + + @TestMetadata("3.1.kt") + public void test3_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.1.kt"); + } + + @TestMetadata("3.2.kt") + public void test3_2() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos/3.2.kt"); + } + + public void testAllFilesPresentInPos() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/constant-literals/boolean-literals/p-1/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + } + } + } + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/constant-literals/integer-literals") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)