From 9711fda3538a5680147239e93e58bcbf730176f5 Mon Sep 17 00:00:00 2001 From: "anastasiia.spaseeva" Date: Fri, 14 Feb 2020 14:42:38 +0300 Subject: [PATCH] [Spec tests] Add tests for property-like callables prioritization --- .../p-2/pos/10.1.kt | 57 +++++++++++++++++++ .../p-2/pos/8.1.kt | 54 ++++++++++++++++++ .../p-2/pos/9.1.kt | 53 +++++++++++++++++ .../testsMap.json | 44 ++++++++++++++ .../DiagnosticsTestSpecGenerated.java | 54 ++++++++++++++++++ 5 files changed, 262 insertions(+) create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/10.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/8.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/9.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/testsMap.json diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/10.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/10.1.kt new file mode 100644 index 00000000000..7c7dc962e00 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/10.1.kt @@ -0,0 +1,57 @@ +// !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-268 + * PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 10 + * NUMBER: 1 + * DESCRIPTION: An enum entry named foo at its declaration site prio + */ + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1, 2 + +package libPackage + +fun foo() {} + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package testPackage +import libPackage.foo as foo + +class Case1() { + enum class A { + zoo, boo; + + fun f() { + foo() + } + + operator fun invoke() {} + } +} + + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package testPackage +import libPackage.foo as zoo + +class Case2() { + companion object zoo { + fun f() { + zoo() + } + } + + fun f() { + zoo() + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/8.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/8.1.kt new file mode 100644 index 00000000000..b3272db4172 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/8.1.kt @@ -0,0 +1,54 @@ +// !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-268 + * PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 8 + * RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 9 + * overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 10 + * NUMBER: 1 + * DESCRIPTION: A companion object of a classifier type named foo at its declaration site + */ + +// FILE: Case1.kt +package testPackage + +// TESTCASE NUMBER: 1 + +class Case1() { + companion object foo { + operator fun invoke() {} + + fun f() { + foo() + foo.invoke() + } + } +} + + +// FILE: LibCase2.kt +package libPackage +fun zoo() {} + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 +package testPackage +import libPackage.zoo as foo + +class Case2() { + companion object foo{ + operator fun invoke() {} + + fun f() { + foo() + } + } + + fun f() { + foo() + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/9.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/9.1.kt new file mode 100644 index 00000000000..5d9bcc3a0ce --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/9.1.kt @@ -0,0 +1,53 @@ +// !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-268 + * PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 9 + * RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 10 + * NUMBER: 1 + * DESCRIPTION: An enum entry named foo at its declaration site prio + */ + +// FILE: Case1.kt +package testPackage + +// TESTCASE NUMBER: 1 + +class Case1() { + enum class A { + foo, boo; + + fun f() { + foo() + foo.invoke() + } + + operator fun invoke() {} + } +} + + +// FILE: LibCase2.kt +package libPackage +fun zoo() {} + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 +package testPackage +import libPackage.zoo as foo + +class Case2() { + enum class A { + foo, boo, zoo; + + fun f() { + foo() + } + + operator fun invoke() {} + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/testsMap.json new file mode 100644 index 00000000000..617ec819b50 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/testsMap.json @@ -0,0 +1,44 @@ +{ + "2": { + "pos": { + "8": [ + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "A companion object of a classifier type named foo at its declaration site", + "unexpectedBehaviour": false + } + ], + "9": [ + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "A companion object of a classifier type named foo at its declaration site", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/8.1.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "An enum entry named foo at its declaration site prio", + "unexpectedBehaviour": false + } + ], + "10": [ + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "An enum entry named foo at its declaration site prio", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/9.1.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "An enum entry named foo at its declaration site prio", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java index df5a8668343..70963950d80 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java @@ -3504,6 +3504,60 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } } } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Callables_and_invoke_convention extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCallables_and_invoke_convention() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class P_2 extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInP_2() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/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("10.1.kt") + public void test10_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/10.1.kt"); + } + + @TestMetadata("8.1.kt") + public void test8_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/8.1.kt"); + } + + @TestMetadata("9.1.kt") + public void test9_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos/9.1.kt"); + } + + public void testAllFilesPresentInPos() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + } + } } @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/statements")