Index: src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java,v retrieving revision 1.20 diff -u -r1.20 AssignmentTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 9 May 2005 16:57:55 -0000 1.20 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 10 Aug 2005 16:27:21 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; +import java.util.HashMap; import java.util.Map; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; @@ -26,8 +27,17 @@ Map options = super.getCompilerOptions(); options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR); options.put(CompilerOptions.OPTION_ReportNoEffectAssignment, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportUnhandledWarningToken, CompilerOptions.ERROR); return options; } + // Static initializer to specify tests subset using TESTS_* static variables + // All specified tests which does not belong to the class are skipped... + static { +// TESTS_NAMES = new String[] { "test000" }; +// TESTS_NUMBERS = new int[] { 38 }; +// TESTS_RANGE = new int[] { 38, -1 }; + } + public static Test suite() { if (false) { @@ -37,9 +47,10 @@ ts.addTest(new AssignmentTest("test221")); return new RegressionTestSetup(ts, COMPLIANCE_1_4); } - return setupSuite(testClass()); + return buildTestSuite(testClass()); } + /* * no effect assignment bug * http://bugs.eclipse.org/bugs/show_bug.cgi?id=27235 @@ -1391,6 +1402,78 @@ }, ""); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773 +public void test038() { + Map options = new HashMap(1); + options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.WARNING); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(final int i, int j) {\n" + + " i = 0; // error (only) on this one\n" + + " j = 0; // warning on this one\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " i = 0; // error (only) on this one\n" + + " ^\n" + + "The final local variable i cannot be assigned. It must be blank and not using a compound assignment\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " j = 0; // warning on this one\n" + + " ^\n" + + "The parameter j should not be assigned\n" + + "----------\n", null, true, options); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773 +public void test039() { + Map options = new HashMap(1); + options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.WARNING); + // toggle to 1.5 to use annotations + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " @SuppressWarnings(\"parameter-assignment\")\n" + + " void foo(int i) {\n" + + " i = 0; // keep quiet\n" + + " zork++; // error\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " zork++; // error\n" + + " ^^^^\n" + + "zork cannot be resolved\n" + + "----------\n", null, true, options); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773 +public void test040() { + Map options = new HashMap(1); + options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.WARNING); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(int i) {\n" + + " int i; // error: hide parameter\n" + + " i = 0; // ok: local assigned\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " int i; // error: hide parameter\n" + + " ^\n" + + "Duplicate local variable i\n" + + "----------\n", null, true, options); +} public static Class testClass() { return AssignmentTest.class; } Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v retrieving revision 1.20.2.1 diff -u -r1.20.2.1 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 25 Jul 2005 15:15:32 -0000 1.20.2.1 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 10 Aug 2005 16:27:21 -0000 @@ -1991,6 +1991,42 @@ "", true); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773 +public void test034() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(int i, final int j) {\n" + + " i = 0; // warning\n" + + " j = 0; // error\n" + + " }\n" + + "}\n", + }, + "\"" + OUTPUT_DIR + File.separator + "X.java\"" + + " -1.5 " + + " -cp \"" + OUTPUT_DIR + "\"" + + " -warn:+parameter-assignment" + + " -proceedOnError" + + " -d \"" + OUTPUT_DIR + "\"", + "", + "----------\n" + + "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + + " (at line 3)\n" + + " i = 0; // warning\n" + + " ^\n" + + "The parameter i should not be assigned\n" + + "----------\n" + + "----------\n" + + "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + + " (at line 4)\n" + + " j = 0; // error\n" + + " ^\n" + + "The final local variable j cannot be assigned. It must be blank and not using a compound assignment\n" + + "----------\n" + + "2 problems (1 error, 1 warning)", + true); +} public static Class testClass() { return BatchCompilerTest.class; }