diff options
author | Stephan Herrmann | 2012-07-19 18:01:10 +0000 |
---|---|---|
committer | Stephan Herrmann | 2012-07-19 18:01:10 +0000 |
commit | 1460a60664f8a2b21be34bd44fc54cb43542552d (patch) | |
tree | 809e828a6eff605663f9bce4086d2c148dd958a3 /org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler | |
parent | 358a2887de068bfb25d0f8055a7a46655762336c (diff) | |
download | org.eclipse.objectteams-1460a60664f8a2b21be34bd44fc54cb43542552d.tar.gz org.eclipse.objectteams-1460a60664f8a2b21be34bd44fc54cb43542552d.tar.xz org.eclipse.objectteams-1460a60664f8a2b21be34bd44fc54cb43542552d.zip |
Update to d14fcf9bcec95873f54edd756055ca864aab7a2b from jdt.core.
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler')
7 files changed, 311 insertions, 395 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java index fff996055..36dfbda2e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java @@ -81,7 +81,7 @@ public void runComplianceParserTest( this.runNegativeTest(testFiles, expected15ProblemLog); } else if(this.complianceLevel == ClassFileConstants.JDK1_6) { this.runNegativeTest(testFiles, expected16ProblemLog); - } else if(this.complianceLevel < ClassFileConstants.JDK1_7) { + } else if(this.complianceLevel < ClassFileConstants.JDK1_8) { this.runNegativeTest(testFiles, expected17ProblemLog); } } @@ -2872,4 +2872,45 @@ public void test0062() { expectedProblemLog ); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=381358 +public void test0063() { + if (this.complianceLevel <= ClassFileConstants.JDK1_4 || this.complianceLevel >= ClassFileConstants.JDK1_8) { + return; + } + String[] testFiles = new String[] { + "X.java", + "interface I {\n" + + " int foo(int p);\n" + + "}\n" + + "public class X<T> {\n" + + " I i = X<String>::foo;\n" + + " I i2 = (p) -> 10;\n" + + " public static int foo(int p) {\n" + + " return p;\n" + + " }\n" + + "}\n" + }; + + String expectedProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " I i = X<String>::foo;\n" + + " ^^^^^^^^^^^^^^\n" + + "Method references are allowed only at source level 1.8 or above\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " I i2 = (p) -> 10;\n" + + " ^^^^^^^^^\n" + + "Lambda expressions are allowed only at source level 1.8 or above\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expectedProblemLog, + expectedProblemLog, + expectedProblemLog, + expectedProblemLog, + expectedProblemLog + ); +} } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java index ab933a1df..744c33f9f 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java @@ -703,4 +703,17 @@ public class LambdaExpressionSyntaxTest extends AbstractSyntaxTreeTest { "}\n"; checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "testNestedLambda01", expectedUnitToString); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385132 + public void test385132() throws IOException { + String source = "->"; + String expectedErrorString = + "----------\n" + + "1. ERROR in test385132 (at line 1)\n" + + " ->\n" + + " ^^\n" + + "Syntax error on token \"->\", delete this token\n" + + "----------\n"; + + checkParse(CHECK_PARSER , source.toCharArray(), expectedErrorString, "test385132", null); + } } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java index 212eb3df0..3870ac95d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java @@ -761,7 +761,7 @@ public class ReferenceExpressionSyntaxTest extends AbstractSyntaxTreeTest { " super();\n" + " }\n" + " public static void main(String[] args) {\n" + - " I i = X::<String>clone;\n" + + " I i = X[]::<String>clone;\n" + " i.copy(new X[10]);\n" + " }\n" + "}\n"; @@ -908,4 +908,148 @@ public class ReferenceExpressionSyntaxTest extends AbstractSyntaxTreeTest { "}\n"; checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385132 + public void test385132() throws IOException { + String source = "::"; + String expectedErrorString = + "----------\n" + + "1. ERROR in test385132 (at line 1)\n" + + " ::\n" + + " ^^\n" + + "Syntax error on token \"::\", delete this token\n" + + "----------\n"; + + checkParse(CHECK_PARSER , source.toCharArray(), expectedErrorString, "test385132", null); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs. + public void test385374() throws IOException { + String source = + "interface I {\n" + + " void foo();\n" + + "}\n" + + "@interface TypeAnnotation {\n" + + "}\n" + + "\n" + + "class X<T> {\n" + + " // Primitive array form\n" + + " I x1 = @TypeAnnotation int []::clone;\n" + + " // Primitive array form with dimension annotations.\n" + + " I x2 = @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" + + " // Primitive array form with dimension annotations and type parameter annotations.\n" + + " I x3 = @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " // Reference type name form\n" + + " I x4 = @TypeAnnotation X::clone;\n" + + " // Reference type name array form\n" + + " I x5 = @TypeAnnotation X []::clone;\n" + + " // Reference type name array form with dimension annotations.\n" + + " I x6 = @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" + + " // Reference type name array form with dimension annotations and type parameter annotations.\n" + + " I x7 = @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " // Generic type array form with dimension annotations and type parameter annotations.\n" + + " I x8 = @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " // Qualified generic type array form with dimension annotations and type parameter annotations.\n" + + " I x9 = @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + "}\n"; + + String expectedUnitToString = + "interface I {\n" + + " void foo();\n" + + "}\n" + + "@interface TypeAnnotation {\n" + + "}\n" + + "class X<T> {\n" + + " I x1 = @TypeAnnotation int[]::clone;\n" + + " I x2 = @TypeAnnotation int @ArrayAnnotation [] @ArrayAnnotation []::clone;\n" + + " I x3 = @TypeAnnotation int @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" + + " I x4 = @TypeAnnotation X::clone;\n" + + " I x5 = @TypeAnnotation X[]::clone;\n" + + " I x6 = @TypeAnnotation X @ArrayAnnotation [] @ArrayAnnotation []::clone;\n" + + " I x7 = @TypeAnnotation X @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" + + " I x8 = @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" + + " I x9 = @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" + + " X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test385374", expectedUnitToString); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs - make sure illegal modifiers are rejected + public void test385374a() throws IOException { + String source = + "interface I {\n" + + " void foo();\n" + + "}\n" + + "@interface TypeAnnotation {\n" + + "}\n" + + "\n" + + "class X<T> {\n" + + " // Primitive array form\n" + + " I x1 = public @TypeAnnotation int []::clone;\n" + + " // Primitive array form with dimension annotations.\n" + + " I x2 = @TypeAnnotation public int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" + + " // Primitive array form with dimension annotations and type parameter annotations.\n" + + " I x3 = public @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " // Reference type name form\n" + + " I x4 = @TypeAnnotation public X::clone;\n" + + " // Reference type name array form\n" + + " I x5 = public @TypeAnnotation X []::clone;\n" + + " // Reference type name array form with dimension annotations.\n" + + " I x6 = @TypeAnnotation public X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" + + " // Reference type name array form with dimension annotations and type parameter annotations.\n" + + " I x7 = public @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " // Generic type array form with dimension annotations and type parameter annotations.\n" + + " I x8 = public @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " // Qualified generic type array form with dimension annotations and type parameter annotations.\n" + + " I x9 = public @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + "}\n"; + + String expectedErrorString = + "----------\n" + + "1. ERROR in test385374a (at line 9)\n" + + " I x1 = public @TypeAnnotation int []::clone;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "2. ERROR in test385374a (at line 11)\n" + + " I x2 = @TypeAnnotation public int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "3. ERROR in test385374a (at line 13)\n" + + " I x3 = public @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "4. ERROR in test385374a (at line 15)\n" + + " I x4 = @TypeAnnotation public X::clone;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "5. ERROR in test385374a (at line 17)\n" + + " I x5 = public @TypeAnnotation X []::clone;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "6. ERROR in test385374a (at line 19)\n" + + " I x6 = @TypeAnnotation public X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "7. ERROR in test385374a (at line 21)\n" + + " I x7 = public @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "8. ERROR in test385374a (at line 23)\n" + + " I x8 = public @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n" + + "9. ERROR in test385374a (at line 25)\n" + + " I x9 = public @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, modifiers are illegal here\n" + + "----------\n"; + checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), expectedErrorString, "test385374a", null); + } } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java index f1c04805e..aeca3f5cc 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -2169,194 +2169,13 @@ public class JavadocTest_1_3 extends JavadocTest { * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=86769" */ public void testBug86769() { - this.reportMissingJavadocComments = CompilerOptions.ERROR; - runNegativeTest( - new String[] { - "E.java", - "public enum E {\n" + - " A,\n" + - " DC{\n" + - " public void foo() {}\n" + - " };\n" + - " E() {}\n" + - " public void foo() {}\n" + - " private enum Epriv {\n" + - " Apriv,\n" + - " Cpriv {\n" + - " public void foo() {}\n" + - " };\n" + - " Epriv() {}\n" + - " public void foo() {}\n" + - " }\n" + - " enum Edef {\n" + - " Adef,\n" + - " Cdef {\n" + - " public void foo() {}\n" + - " };\n" + - " Edef() {}\n" + - " public void foo() {}\n" + - " }\n" + - " protected enum Epro {\n" + - " Apro,\n" + - " Cpro {\n" + - " public void foo() {}\n" + - " };\n" + - " Epro() {}\n" + - " public void foo() {}\n" + - " }\n" + - " public enum Epub {\n" + - " Apub,\n" + - " Cpub {\n" + - " public void foo() {}\n" + - " };\n" + - " Epub() {}\n" + - " public void foo() {}\n" + - " }\n" + - "}\n" - }, - "----------\n" + - "1. ERROR in E.java (at line 1)\n" + - " public enum E {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "2. ERROR in E.java (at line 1)\n" + - " public enum E {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "3. ERROR in E.java (at line 5)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "4. ERROR in E.java (at line 5)\n" + - " };\n" + - " E() {}\n" + - " public void foo() {}\n" + - " private enum Epriv {\n" + - " Apriv,\n" + - " Cpriv {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Syntax error on token(s), misplaced construct(s)\n" + - "----------\n" + - "5. WARNING in E.java (at line 8)\n" + - " private enum Epriv {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "6. ERROR in E.java (at line 8)\n" + - " private enum Epriv {\n" + - " ^^^^^\n" + - "Syntax error on token \"Epriv\", = expected after this token\n" + - "----------\n" + - "7. ERROR in E.java (at line 12)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "8. WARNING in E.java (at line 16)\n" + - " enum Edef {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "9. ERROR in E.java (at line 16)\n" + - " enum Edef {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "10. ERROR in E.java (at line 16)\n" + - " enum Edef {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "11. ERROR in E.java (at line 20)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "12. WARNING in E.java (at line 24)\n" + - " protected enum Epro {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "13. ERROR in E.java (at line 24)\n" + - " protected enum Epro {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "14. ERROR in E.java (at line 24)\n" + - " protected enum Epro {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "15. ERROR in E.java (at line 28)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "16. WARNING in E.java (at line 32)\n" + - " public enum Epub {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "17. ERROR in E.java (at line 32)\n" + - " public enum Epub {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "18. ERROR in E.java (at line 32)\n" + - " public enum Epub {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "19. ERROR in E.java (at line 36)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "20. ERROR in E.java (at line 40)\n" + - " }\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" - ); + + /* Deleted a completely meaningless test that could only serve as a torture test for the parser. + The test is still run in 1.5+ modes where it makes sense to run it - The test here was a nuisance + failing every time there is some serious grammar change that alters the semi-random behavior in + Diagnose Parser. + */ + return; } /** diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java index f656e05fe..8253c4c75 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -2203,194 +2203,13 @@ public class JavadocTest_1_4 extends JavadocTest { * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=86769" */ public void testBug86769() { - this.reportMissingJavadocComments = CompilerOptions.ERROR; - runNegativeTest( - new String[] { - "E.java", - "public enum E {\n" + - " A,\n" + - " DC{\n" + - " public void foo() {}\n" + - " };\n" + - " E() {}\n" + - " public void foo() {}\n" + - " private enum Epriv {\n" + - " Apriv,\n" + - " Cpriv {\n" + - " public void foo() {}\n" + - " };\n" + - " Epriv() {}\n" + - " public void foo() {}\n" + - " }\n" + - " enum Edef {\n" + - " Adef,\n" + - " Cdef {\n" + - " public void foo() {}\n" + - " };\n" + - " Edef() {}\n" + - " public void foo() {}\n" + - " }\n" + - " protected enum Epro {\n" + - " Apro,\n" + - " Cpro {\n" + - " public void foo() {}\n" + - " };\n" + - " Epro() {}\n" + - " public void foo() {}\n" + - " }\n" + - " public enum Epub {\n" + - " Apub,\n" + - " Cpub {\n" + - " public void foo() {}\n" + - " };\n" + - " Epub() {}\n" + - " public void foo() {}\n" + - " }\n" + - "}\n" - }, - "----------\n" + - "1. ERROR in E.java (at line 1)\n" + - " public enum E {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "2. ERROR in E.java (at line 1)\n" + - " public enum E {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "3. ERROR in E.java (at line 5)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "4. ERROR in E.java (at line 5)\n" + - " };\n" + - " E() {}\n" + - " public void foo() {}\n" + - " private enum Epriv {\n" + - " Apriv,\n" + - " Cpriv {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Syntax error on token(s), misplaced construct(s)\n" + - "----------\n" + - "5. WARNING in E.java (at line 8)\n" + - " private enum Epriv {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "6. ERROR in E.java (at line 8)\n" + - " private enum Epriv {\n" + - " ^^^^^\n" + - "Syntax error on token \"Epriv\", = expected after this token\n" + - "----------\n" + - "7. ERROR in E.java (at line 12)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "8. WARNING in E.java (at line 16)\n" + - " enum Edef {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "9. ERROR in E.java (at line 16)\n" + - " enum Edef {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "10. ERROR in E.java (at line 16)\n" + - " enum Edef {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "11. ERROR in E.java (at line 20)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "12. WARNING in E.java (at line 24)\n" + - " protected enum Epro {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "13. ERROR in E.java (at line 24)\n" + - " protected enum Epro {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "14. ERROR in E.java (at line 24)\n" + - " protected enum Epro {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "15. ERROR in E.java (at line 28)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "16. WARNING in E.java (at line 32)\n" + - " public enum Epub {\n" + - " ^^^^\n" + - "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" + - "----------\n" + - "17. ERROR in E.java (at line 32)\n" + - " public enum Epub {\n" + - " ^^^^\n" + -//{ObjectTeams: our grammar prefers class, so expect "class E implements ..." -/* orig: - "Syntax error on token \"enum\", interface expected\n" + - :giro */ - "Syntax error on token \"enum\", class expected\n" + -// orig: - "----------\n" + - "18. ERROR in E.java (at line 32)\n" + - " public enum Epub {\n" + - " ^\n" + -/* - "Syntax error on token \"{\", extends expected\n" + - :giro */ - "Syntax error on token \"{\", implements expected\n" + -// SH} - "----------\n" + - "19. ERROR in E.java (at line 36)\n" + - " };\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" + - "20. ERROR in E.java (at line 40)\n" + - " }\n" + - " ^\n" + - "Syntax error on token \"}\", delete this token\n" + - "----------\n" - ); + + /* Deleted a completely meaningless test that could only serve as a torture test for the parser. + The test is still run in 1.5+ modes where it makes sense to run it - The test here was a nuisance + failing every time there is some serious grammar change that alters the semi-random behavior in + Diagnose Parser. + */ + return; } /** diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java index c869a4e89..46144a5cd 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java @@ -106,7 +106,7 @@ public void test003() { "----------\n"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383046, syntax error reported incorrectly on syntactically valid lambda expression -public void _test004() { +public void test004() { this.runNegativeTest( new String[] { "X.java", @@ -115,14 +115,14 @@ public void _test004() { "}\n" + "public class X {\n" + " IX i = () -> 42;\n" + - " int\n" + + " int x\n" + "}\n", }, "----------\n" + "1. ERROR in X.java (at line 6)\n" + - " int\n" + - " ^^^\n" + - "Syntax error on token \"int\", delete this token\n" + + " int x\n" + + " ^\n" + + "Syntax error, insert \";\" to complete FieldDeclaration\n" + "----------\n"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383085 super::identifier not accepted. @@ -146,7 +146,7 @@ public void test005() { "----------\n"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383046, syntax error reported incorrectly on *syntactically* valid reference expression -public void _test006() { +public void test006() { this.runNegativeTest( new String[] { "X.java", @@ -155,14 +155,14 @@ public void _test006() { "}\n" + "public class X {\n" + " IX i = Outer<One, Two>.Inner<Three, Four>.Deeper<Five, Six<String>>.Leaf::<Blah, Blah>method;\n" + - " int\n" + + " int x\n" + "}\n", }, "----------\n" + "1. ERROR in X.java (at line 6)\n" + - " int\n" + - " ^^^\n" + - "Syntax error on token \"int\", delete this token\n" + + " int x\n" + + " ^\n" + + "Syntax error, insert \";\" to complete FieldDeclaration\n" + "----------\n"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383096, NullPointerException with a wrong lambda code snippet diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java index 2df5b54bd..d98743905 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java @@ -644,7 +644,7 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest { "Marker2 cannot be resolved to a type\n" + "----------\n"); } - public void _test031() throws Exception { + public void test031() throws Exception { this.runNegativeTest( new String[] { "Marker.java", @@ -655,6 +655,13 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest { "X.java", "public class X<@Marker T> {}", }, + /* TODO(Srikanth/Jay) when JSR308 enabled runtime becomes available for testing, the first error message should be deleted. */ + "----------\n" + + "1. ERROR in Marker.java (at line 3)\n" + + " @Target(TYPE_USE)\n" + + " ^^^^^^^^\n" + + "TYPE_USE cannot be resolved to a variable\n" + + "----------\n" + "----------\n" + "1. ERROR in X.java (at line 1)\n" + " public class X<@Marker T> {}\n" + @@ -662,7 +669,7 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest { "The annotation @Marker is disallowed for this location\n" + "----------\n"); } - public void _test032() throws Exception { + public void test032() throws Exception { this.runNegativeTest( new String[] { "Marker.java", @@ -674,10 +681,10 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest { "1. ERROR in X.java (at line 1)\n" + " public class X<@Marker T> {}\n" + " ^^^^^^^\n" + - "The annotation @Marker is disallowed for this location\n" + + "Only annotation types that explicitly specify TYPE_PARAMETER as a possible target element type can be applied here\n" + "----------\n"); } - public void _test033() throws Exception { + public void test033() throws Exception { this.runNegativeTest( new String[] { "Marker.java", @@ -691,7 +698,7 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest { "1. ERROR in X.java (at line 1)\n" + " public class X extends @Marker Y {}\n" + " ^^^^^^^\n" + - "The annotation @Marker is disallowed for this location\n" + + "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" + "----------\n"); } // check locations @@ -953,4 +960,77 @@ public class NegativeTypeAnnotationTest extends AbstractRegressionTest { "The annotation @Marker is disallowed for this location\n" + "----------\n"); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385111 + // [1.8][compiler] Compiler fails to flag undefined annotation type. + public void test0385111() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "public class X {\n" + + " public void foo(String fileName) {\n" + + " List<String> l = new @MissingTypeNotIgnored ArrayList<String>();\n" + + " List<String> l1 = new @MissingTypeIgnored ArrayList<>();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " List<String> l = new @MissingTypeNotIgnored ArrayList<String>();\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "MissingTypeNotIgnored cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " List<String> l1 = new @MissingTypeIgnored ArrayList<>();\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "MissingTypeIgnored cannot be resolved to a type\n" + + "----------\n"); + } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385111 + // Test to exercise assorted cleanup along with bug fix. + public void test0385111a() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public void foo(String fileName) {\n" + + " try (@Annot X x = null; @Annot X x2 = null) {\n"+ + " } catch (@Annot NullPointerException | @Annot UnsupportedOperationException e) {\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " try (@Annot X x = null; @Annot X x2 = null) {\n" + + " ^^^^^\n" + + "Annot cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " try (@Annot X x = null; @Annot X x2 = null) {\n" + + " ^\n" + + "The resource type X does not implement java.lang.AutoCloseable\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " try (@Annot X x = null; @Annot X x2 = null) {\n" + + " ^^^^^\n" + + "Annot cannot be resolved to a type\n" + + "----------\n" + + "4. ERROR in X.java (at line 3)\n" + + " try (@Annot X x = null; @Annot X x2 = null) {\n" + + " ^\n" + + "The resource type X does not implement java.lang.AutoCloseable\n" + + "----------\n" + + "5. ERROR in X.java (at line 4)\n" + + " } catch (@Annot NullPointerException | @Annot UnsupportedOperationException e) {\n" + + " ^^^^^\n" + + "Annot cannot be resolved to a type\n" + + "----------\n" + + "6. ERROR in X.java (at line 4)\n" + + " } catch (@Annot NullPointerException | @Annot UnsupportedOperationException e) {\n" + + " ^^^^^\n" + + "Annot cannot be resolved to a type\n" + + "----------\n"); + } } |