Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdaniel2007-11-21 11:01:50 +0000
committermdaniel2007-11-21 11:01:50 +0000
commit6498f02423137f9292b34e601b633d22e6c4b5d9 (patch)
tree6f9a4ca1b33a1db3f8e7e5baf783259cffed0206 /org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
parenta4064954d1a82b3602f2e6599e710f740f145ab4 (diff)
downloadeclipse.jdt.core-6498f02423137f9292b34e601b633d22e6c4b5d9.tar.gz
eclipse.jdt.core-6498f02423137f9292b34e601b633d22e6c4b5d9.tar.xz
eclipse.jdt.core-6498f02423137f9292b34e601b633d22e6c4b5d9.zip
HEAD - tests cases for 210518
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java204
1 files changed, 204 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 090438bf58..3726cbc32e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -5515,6 +5515,210 @@ public void test152() {
"1 problem (1 warning)",
true);
}
+// -warn option - regression tests
+public void test152_warn_options() {
+ // check defaults
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -proc:none -d \"" + OUTPUT_DIR + "\"",
+// + " -warn:none -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
+ " s.toString();\n" +
+ " ^\n" +
+ "Null pointer access: The variable s can only be null at this location\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " String u;\n" +
+ " ^\n" +
+ "The local variable u is never read\n" +
+ "----------\n" +
+ "2 problems (2 warnings)",
+ true);
+ // observe -warn options variations
+ this.runConformTest(
+ new String[] { },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:none -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "",
+ false);
+}
+// -warn option - regression tests
+public void test153_warn_options() {
+ // same source as 152, skip default checks
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:null -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
+ " s.toString();\n" +
+ " ^\n" +
+ "Null pointer access: The variable s can only be null at this location\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
+// -warn option - regression tests
+public void test154_warn_options() {
+ // same source as 152, skip default checks
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:none -warn:null -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
+ " s.toString();\n" +
+ " ^\n" +
+ "Null pointer access: The variable s can only be null at this location\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
+// -warn option - regression tests
+public void test155_warn_options() {
+ // same source as 152, skip default checks
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:unused -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " String u;\n" +
+ " ^\n" +
+ "The local variable u is never read\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518
+// bad behavior for -warn:null -warn:unused
+public void _test156_warn_options() {
+ // same source as 152, skip default checks
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:null -warn:unused -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " String u;\n" +
+ " ^\n" +
+ "The local variable u is never read\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518
+// variant
+public void test157_warn_options() {
+ // same source as 152, skip default checks
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:null -warn:+unused -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
+ " s.toString();\n" +
+ " ^\n" +
+ "Null pointer access: The variable s can only be null at this location\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " String u;\n" +
+ " ^\n" +
+ "The local variable u is never read\n" +
+ "----------\n" +
+ "2 problems (2 warnings)",
+ true);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518
+// variant
+public void test158_warn_options() {
+ // same source as 152, skip default checks
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo() {\n" +
+ " String s = null;\n" +
+ " s.toString();\n" +
+ " String u;\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -warn:null -warn:+unused -warn:-null -proc:none -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " String u;\n" +
+ " ^\n" +
+ "The local variable u is never read\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ true);
+}
public static Class testClass() {
return BatchCompilerTest.class;
}

Back to the top