View | Details | Raw Unified | Return to bug 127766 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java (-37 / +67 lines)
Lines 33-39 Link Here
33
	// All specified tests which does not belong to the class are skipped...
33
	// All specified tests which does not belong to the class are skipped...
34
	static {
34
	static {
35
//		TESTS_NAMES = new String[] { "test000" };
35
//		TESTS_NAMES = new String[] { "test000" };
36
//		TESTS_NUMBERS = new int[] { 127 };
36
//		TESTS_NUMBERS = new int[] { 128 };
37
//		TESTS_RANGE = new int[] { 21, 50 };
37
//		TESTS_RANGE = new int[] { 21, 50 };
38
	}
38
	}
39
	public static Test suite() {
39
	public static Test suite() {
Lines 411-423 Link Here
411
				"}"
411
				"}"
412
			},
412
			},
413
			"----------\n" + 
413
			"----------\n" + 
414
			"1. ERROR in X.java (at line 12)\r\n" + 
414
			"1. ERROR in X.java (at line 12)\n" + 
415
			"	case BLEU :\r\n" + 
415
			"	case BLEU :\n" + 
416
			"	^^^^^^^^^\n" + 
416
			"	^^^^^^^^^\n" + 
417
			"Duplicate case\n" + 
417
			"Duplicate case\n" + 
418
			"----------\n" + 
418
			"----------\n" + 
419
			"2. ERROR in X.java (at line 14)\r\n" + 
419
			"2. ERROR in X.java (at line 14)\n" + 
420
			"	case BLEU :\r\n" + 
420
			"	case BLEU :\n" + 
421
			"	^^^^^^^^^\n" + 
421
			"	^^^^^^^^^\n" + 
422
			"Duplicate case\n" + 
422
			"Duplicate case\n" + 
423
			"----------\n");
423
			"----------\n");
Lines 552-559 Link Here
552
				"}\n"
552
				"}\n"
553
			},
553
			},
554
			"----------\n" + 
554
			"----------\n" + 
555
			"1. ERROR in X.java (at line 4)\r\n" + 
555
			"1. ERROR in X.java (at line 4)\n" + 
556
			"	BLANC(),\r\n" + 
556
			"	BLANC(),\n" + 
557
			"	^^^^^\n" + 
557
			"	^^^^^\n" + 
558
			"The constructor X() is undefined\n" + 
558
			"The constructor X() is undefined\n" + 
559
			"----------\n");
559
			"----------\n");
Lines 1946-1955 Link Here
1946
        this.runNegativeTest(
1946
        this.runNegativeTest(
1947
            new String[] {
1947
            new String[] {
1948
                "X.java",
1948
                "X.java",
1949
                "public enum X {\r\n" + 
1949
                "public enum X {\n" + 
1950
                "    ONE, TWO, THREE;\r\n" + 
1950
                "    ONE, TWO, THREE;\n" + 
1951
                "    abstract int getSquare();\r\n" + 
1951
                "    abstract int getSquare();\n" + 
1952
                "    abstract int getSquare();\r\n" + 
1952
                "    abstract int getSquare();\n" + 
1953
                "}",
1953
                "}",
1954
            },
1954
            },
1955
            "----------\n" + 
1955
            "----------\n" + 
Lines 2149-2156 Link Here
2149
				"interface I { void test(); }\n"
2149
				"interface I { void test(); }\n"
2150
			},
2150
			},
2151
			"----------\n" + 
2151
			"----------\n" + 
2152
			"1. ERROR in X3.java (at line 3)\r\n" + 
2152
			"1. ERROR in X3.java (at line 3)\n" + 
2153
			"	public abstract void test();\r\n" + 
2153
			"	public abstract void test();\n" + 
2154
			"	                     ^^^^^^\n" + 
2154
			"	                     ^^^^^^\n" + 
2155
			"The enum X3 can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2155
			"The enum X3 can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2156
			"----------\n"
2156
			"----------\n"
Lines 2166-2173 Link Here
2166
				"interface I { void test(); }\n"
2166
				"interface I { void test(); }\n"
2167
			},
2167
			},
2168
			"----------\n" + 
2168
			"----------\n" + 
2169
			"1. ERROR in X3a.java (at line 3)\r\n" + 
2169
			"1. ERROR in X3a.java (at line 3)\n" + 
2170
			"	public abstract void test();\r\n" + 
2170
			"	public abstract void test();\n" + 
2171
			"	                     ^^^^^^\n" + 
2171
			"	                     ^^^^^^\n" + 
2172
			"The enum X3a can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2172
			"The enum X3a can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2173
			"----------\n"
2173
			"----------\n"
Lines 2194-2201 Link Here
2194
				"interface I { void test(); }\n"
2194
				"interface I { void test(); }\n"
2195
			},
2195
			},
2196
			"----------\n" + 
2196
			"----------\n" + 
2197
			"1. ERROR in X3c.java (at line 2)\r\n" + 
2197
			"1. ERROR in X3c.java (at line 2)\n" + 
2198
			"	A() { void random() {} };\r\n" + 
2198
			"	A() { void random() {} };\n" + 
2199
			"	    ^\n" + 
2199
			"	    ^\n" + 
2200
			"The type new X3c(){} must implement the inherited abstract method X3c.test()\n" + 
2200
			"The type new X3c(){} must implement the inherited abstract method X3c.test()\n" + 
2201
			"----------\n"
2201
			"----------\n"
Lines 2214-2221 Link Here
2214
				"}\n"
2214
				"}\n"
2215
			},
2215
			},
2216
			"----------\n" + 
2216
			"----------\n" + 
2217
			"1. ERROR in X4.java (at line 3)\r\n" + 
2217
			"1. ERROR in X4.java (at line 3)\n" + 
2218
			"	public abstract void test();\r\n" + 
2218
			"	public abstract void test();\n" + 
2219
			"	                     ^^^^^^\n" + 
2219
			"	                     ^^^^^^\n" + 
2220
			"The enum X4 can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2220
			"The enum X4 can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2221
			"----------\n"
2221
			"----------\n"
Lines 2230-2237 Link Here
2230
				"}\n"
2230
				"}\n"
2231
			},
2231
			},
2232
			"----------\n" + 
2232
			"----------\n" + 
2233
			"1. ERROR in X4a.java (at line 3)\r\n" + 
2233
			"1. ERROR in X4a.java (at line 3)\n" + 
2234
			"	public abstract void test();\r\n" + 
2234
			"	public abstract void test();\n" + 
2235
			"	                     ^^^^^^\n" + 
2235
			"	                     ^^^^^^\n" + 
2236
			"The enum X4a can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2236
			"The enum X4a can only define the abstract method test() if it also defines enum constants with corresponding implementations\n" + 
2237
			"----------\n"
2237
			"----------\n"
Lines 2256-2263 Link Here
2256
				"}\n"
2256
				"}\n"
2257
			},
2257
			},
2258
			"----------\n" + 
2258
			"----------\n" + 
2259
			"1. ERROR in X4c.java (at line 2)\r\n" + 
2259
			"1. ERROR in X4c.java (at line 2)\n" + 
2260
			"	A() { void random() {} };\r\n" + 
2260
			"	A() { void random() {} };\n" + 
2261
			"	    ^\n" + 
2261
			"	    ^\n" + 
2262
			"The type new X4c(){} must implement the inherited abstract method X4c.test()\n" + 
2262
			"The type new X4c(){} must implement the inherited abstract method X4c.test()\n" + 
2263
			"----------\n"
2263
			"----------\n"
Lines 2276-2283 Link Here
2276
				"interface I { void test(); }\n"
2276
				"interface I { void test(); }\n"
2277
			},
2277
			},
2278
			"----------\n" + 
2278
			"----------\n" + 
2279
			"1. ERROR in X5.java (at line 1)\r\n" + 
2279
			"1. ERROR in X5.java (at line 1)\n" + 
2280
			"	public enum X5 implements I {\r\n" + 
2280
			"	public enum X5 implements I {\n" + 
2281
			"	            ^^\n" + 
2281
			"	            ^^\n" + 
2282
			"The type X5 must implement the inherited abstract method I.test()\n" + 
2282
			"The type X5 must implement the inherited abstract method I.test()\n" + 
2283
			"----------\n"
2283
			"----------\n"
Lines 2292-2299 Link Here
2292
				"interface I { void test(); }\n"
2292
				"interface I { void test(); }\n"
2293
			},
2293
			},
2294
			"----------\n" + 
2294
			"----------\n" + 
2295
			"1. ERROR in X5a.java (at line 1)\r\n" + 
2295
			"1. ERROR in X5a.java (at line 1)\n" + 
2296
			"	public enum X5a implements I {\r\n" + 
2296
			"	public enum X5a implements I {\n" + 
2297
			"	            ^^^\n" + 
2297
			"	            ^^^\n" + 
2298
			"The type X5a must implement the inherited abstract method I.test()\n" + 
2298
			"The type X5a must implement the inherited abstract method I.test()\n" + 
2299
			"----------\n"
2299
			"----------\n"
Lines 2321-2328 Link Here
2321
				"interface I { void test(); }\n"
2321
				"interface I { void test(); }\n"
2322
			},
2322
			},
2323
			"----------\n" + 
2323
			"----------\n" + 
2324
			"1. ERROR in X5c.java (at line 2)\r\n" + 
2324
			"1. ERROR in X5c.java (at line 2)\n" + 
2325
			"	A() { void random() {} };\r\n" + 
2325
			"	A() { void random() {} };\n" + 
2326
			"	    ^\n" + 
2326
			"	    ^\n" + 
2327
			"The type new X5c(){} must implement the inherited abstract method I.test()\n" + 
2327
			"The type new X5c(){} must implement the inherited abstract method I.test()\n" + 
2328
			"----------\n"
2328
			"----------\n"
Lines 3730-3737 Link Here
3730
		this.runConformTest(
3730
		this.runConformTest(
3731
			new String[] {
3731
			new String[] {
3732
				"com/annot/Foo.java",
3732
				"com/annot/Foo.java",
3733
				"package com.annot;\r\n" + 
3733
				"package com.annot;\n" + 
3734
				"\r\n" + 
3734
				"\n" + 
3735
				"import static com.annot.TestType.*;\n" +
3735
				"import static com.annot.TestType.*;\n" +
3736
				"\n" +
3736
				"\n" +
3737
				"public class Foo {\n" +
3737
				"public class Foo {\n" +
Lines 4281-4292 Link Here
4281
		this.runConformTest(
4281
		this.runConformTest(
4282
			new String[] {
4282
			new String[] {
4283
				"X.java",
4283
				"X.java",
4284
				"public enum X {\r\n" + 
4284
				"public enum X {\n" + 
4285
				"	VALUE {\r\n" + 
4285
				"	VALUE {\n" + 
4286
				"		void foo() {\r\n" + 
4286
				"		void foo() {\n" + 
4287
				"		};\r\n" + 
4287
				"		};\n" + 
4288
				"	};\r\n" + 
4288
				"	};\n" + 
4289
				"	abstract void foo();\r\n" + 
4289
				"	abstract void foo();\n" + 
4290
				"    public static void main(String[] args) {\n" + 
4290
				"    public static void main(String[] args) {\n" + 
4291
				"      System.out.println(\"[\"+X.values().length+\"]\");\n" + 
4291
				"      System.out.println(\"[\"+X.values().length+\"]\");\n" + 
4292
				"    }\n" + 
4292
				"    }\n" + 
Lines 4346-4349 Link Here
4346
			assertTrue("Must not have field ENUM$VALUES", false);
4346
			assertTrue("Must not have field ENUM$VALUES", false);
4347
		}
4347
		}
4348
	}
4348
	}
4349
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=127766
4350
	public void test128() {
4351
		Map options = this.getCompilerOptions();
4352
		options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
4353
		options.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.IGNORE);
4354
4355
		this.runNegativeTest(
4356
	         new String[] {
4357
	        		 "X.java",
4358
	        		 "public class X {\n" + 
4359
	        		 "	public static void main( String[] args) {\n" + 
4360
	        		 "		Enum e = new Enum(\"foo\", 2) {\n" + 
4361
	        		 "			public int compareTo( Object o) {\n" + 
4362
	        		 "				return 0;\n" + 
4363
	        		 "			}\n" + 
4364
	        		 "		};\n" + 
4365
	        		 "		System.out.println(e);\n" + 
4366
	        		 "	}\n" + 
4367
	        		 "}",
4368
	         },
4369
	         "----------\n" + 
4370
	         "1. ERROR in X.java (at line 3)\n" + 
4371
	         "	Enum e = new Enum(\"foo\", 2) {\n" + 
4372
	         "	             ^^^^\n" + 
4373
	         "The type new Enum(){} may not subclass Enum explicitly\n" + 
4374
	         "----------\n",
4375
	         null,
4376
	         true,
4377
	         options);
4378
 	}
4349
}
4379
}

Return to bug 127766