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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java (+39 lines)
Lines 424-427 Link Here
424
		}
424
		}
425
		super.tearDown();
425
		super.tearDown();
426
	}
426
	}
427
	
428
	protected void executeClass(
429
			String sourceFile, 
430
			String expectedSuccessOutputString, 
431
			String[] classLib,
432
			boolean shouldFlushOutputDirectory, 
433
			String[] vmArguments, 
434
			Map customOptions,
435
			ICompilerRequestor clientRequestor) {
436
437
		// Compute class name by removing ".java" and replacing slashes with dots
438
		String className = sourceFile.substring(0, sourceFile.length() - 5).replace('/', '.').replace('\\', '.');
439
		if (className.endsWith(PACKAGE_INFO_NAME)) return;
440
441
		if (vmArguments != null) {
442
			if (this.verifier != null) {
443
				this.verifier.shutDown();
444
			}
445
			this.verifier = new TestVerifier(false);
446
			this.createdVerifier = true;
447
		}
448
		boolean passed = 
449
			this.verifier.verifyClassFiles(
450
				sourceFile, 
451
				className, 
452
				expectedSuccessOutputString,
453
				this.classpaths, 
454
				null, 
455
				vmArguments);
456
		assertTrue(this.verifier.failureReason, // computed by verifyClassFiles(...) action
457
				passed);
458
		if (vmArguments != null) {
459
			if (this.verifier != null) {
460
				this.verifier.shutDown();
461
			}
462
			this.verifier = new TestVerifier(false);
463
			this.createdVerifier = true;
464
		}
465
	}
427
}
466
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java (-4 / +255 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[] { 106 };
36
//		TESTS_NUMBERS = new int[] { 105 };
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 1554-1561 Link Here
1554
	
1554
	
1555
	// TODO (philippe) check one cannot redefine Enum incorrectly
1555
	// TODO (philippe) check one cannot redefine Enum incorrectly
1556
	
1556
	
1557
	// TODO (philippe) check binary compatibility (removing referenced enum constants in switch)
1558
	
1559
	// TODO (philippe) check enum syntax recovery
1557
	// TODO (philippe) check enum syntax recovery
1560
	/**
1558
	/**
1561
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78914 - variation
1559
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78914 - variation
Lines 3235-3239 Link Here
3235
				"}  \n",
3233
				"}  \n",
3236
            },
3234
            },
3237
            "ENUM1");
3235
            "ENUM1");
3238
    }    
3236
    }
3237
    
3238
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88395
3239
	public void test105() {
3240
		this.runConformTest(
3241
				new String[] {
3242
					"pack/X.java",
3243
					"package pack;\n" +
3244
					"import static pack.Color.*;\n" +
3245
					"public class X {\n" +
3246
					"    public static void main(String[] args) {\n" +
3247
					"        Color c = BLACK;\n" +
3248
					"        switch(c) {\n" +
3249
					"        case BLACK:\n" +
3250
					"            System.out.print(\"Black\");\n" +
3251
					"            break;\n" +
3252
					"        case WHITE:\n" +
3253
					"            System.out.print(\"White\");\n" +
3254
					"            break;\n" +
3255
					"        }\n" +
3256
					"    }\n" +
3257
					"}",
3258
					"pack/Color.java",
3259
					"package pack;\n" + 
3260
					"enum Color {WHITE, BLACK}"
3261
				},
3262
				"Black"
3263
			);
3264
		
3265
		this.runConformTest(
3266
			new String[] {
3267
				"pack/Color.java",
3268
				"package pack;\n" + 
3269
				"enum Color {BLACK, WHITE}"
3270
			},
3271
			"",
3272
			null,
3273
			false,
3274
			null
3275
		);
3276
		
3277
		this.executeClass(
3278
			"pack/X.java",
3279
			"Black",
3280
			null,
3281
			false,
3282
			null,
3283
			null,
3284
			null);	
3285
	}
3286
	
3287
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88395
3288
	public void test106() {
3289
		this.runConformTest(
3290
				new String[] {
3291
					"pack/X.java",
3292
					"package pack;\n" +
3293
					"import static pack.Color.*;\n" +
3294
					"public class X {\n" +
3295
					"    public static void main(String[] args) {\n" +
3296
					"        Color c = BLACK;\n" +
3297
					"        switch(c) {\n" +
3298
					"        }\n" +
3299
					"		 System.out.print(\"SUCCESS\");\n" +
3300
					"    }\n" +
3301
					"}",
3302
					"pack/Color.java",
3303
					"package pack;\n" + 
3304
					"enum Color {WHITE, BLACK}"
3305
				},
3306
				"SUCCESS"
3307
			);
3308
		
3309
		this.runConformTest(
3310
			new String[] {
3311
				"pack/Color.java",
3312
				"package pack;\n" + 
3313
				"enum Color {BLACK, WHITE}"
3314
			},
3315
			"",
3316
			null,
3317
			false,
3318
			null
3319
		);
3320
		
3321
		this.executeClass(
3322
			"pack/X.java",
3323
			"SUCCESS",
3324
			null,
3325
			false,
3326
			null,
3327
			null,
3328
			null);	
3329
	}
3330
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88395
3331
	public void test107() {
3332
		this.runConformTest(
3333
				new String[] {
3334
					"pack/X.java",
3335
					"package pack;\n" +
3336
					"import static pack.Color.*;\n" +
3337
					"public class X {\n" +
3338
					"    public static void main(String[] args) {\n" +
3339
					"        Color c = BLACK;\n" +
3340
					"        switch(c) {\n" +
3341
					"        case BLACK:\n" +
3342
					"            System.out.print(\"Black\");\n" +
3343
					"            break;\n" +
3344
					"        case WHITE:\n" +
3345
					"            System.out.print(\"White\");\n" +
3346
					"            break;\n" +
3347
					"        }\n" +
3348
					"        switch(c) {\n" +
3349
					"        case BLACK:\n" +
3350
					"            System.out.print(\"Black\");\n" +
3351
					"            break;\n" +
3352
					"        case WHITE:\n" +
3353
					"            System.out.print(\"White\");\n" +
3354
					"            break;\n" +
3355
					"        }\n" +
3356
					"    }\n" +
3357
					"}",
3358
					"pack/Color.java",
3359
					"package pack;\n" + 
3360
					"enum Color {WHITE, BLACK}"
3361
				},
3362
				"BlackBlack"
3363
			);
3364
		
3365
		this.runConformTest(
3366
			new String[] {
3367
				"pack/Color.java",
3368
				"package pack;\n" + 
3369
				"enum Color { BLACK }"
3370
			},
3371
			"",
3372
			null,
3373
			false,
3374
			null
3375
		);
3376
		
3377
		this.executeClass(
3378
			"pack/X.java",
3379
			"BlackBlack",
3380
			null,
3381
			false,
3382
			null,
3383
			null,
3384
			null);	
3385
	}
3386
	
3387
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88395
3388
	public void test108() {
3389
		this.runConformTest(
3390
				new String[] {
3391
					"pack/X.java",
3392
					"package pack;\n" +
3393
					"import static pack.Color.*;\n" +
3394
					"public class X {\n" +
3395
					"    public static void main(String[] args) {\n" +
3396
					"        Color c = BLACK;\n" +
3397
					"        switch(c) {\n" +
3398
					"        case BLACK:\n" +
3399
					"            System.out.print(\"Black\");\n" +
3400
					"            break;\n" +
3401
					"        case WHITE:\n" +
3402
					"            System.out.print(\"White\");\n" +
3403
					"            break;\n" +
3404
					"        }\n" +
3405
					"    }\n" +
3406
					"}",
3407
					"pack/Color.java",
3408
					"package pack;\n" + 
3409
					"enum Color {WHITE, BLACK}"
3410
				},
3411
				"Black"
3412
			);
3413
		
3414
		this.runConformTest(
3415
			new String[] {
3416
				"pack/Color.java",
3417
				"package pack;\n" + 
3418
				"enum Color {RED, GREEN, YELLOW, BLACK, WHITE}"
3419
			},
3420
			"",
3421
			null,
3422
			false,
3423
			null
3424
		);
3425
		
3426
		this.executeClass(
3427
			"pack/X.java",
3428
			"Black",
3429
			null,
3430
			false,
3431
			null,
3432
			null,
3433
			null);	
3434
	}
3435
	
3436
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88395
3437
	public void test109() {
3438
		this.runConformTest(
3439
				new String[] {
3440
					"pack/X.java",
3441
					"package pack;\n" +
3442
					"import static pack.Color.*;\n" +
3443
					"public class X {\n" +
3444
					"    public static void main(String[] args) {\n" +
3445
					"		Color c = null;\n" +
3446
					"		 try {\n" +
3447
					"        	c = BLACK;\n" +
3448
					"		} catch(NoSuchFieldError e) {\n" +
3449
					"			System.out.print(\"SUCCESS\");\n" +
3450
					"			return;\n" +
3451
					"		}\n" +
3452
					"      	switch(c) {\n" +
3453
					"       	case BLACK:\n" +
3454
					"          	System.out.print(\"Black\");\n" +
3455
					"          	break;\n" +
3456
					"       	case WHITE:\n" +
3457
					"          	System.out.print(\"White\");\n" +
3458
					"          	break;\n" +
3459
					"      	}\n" +
3460
					"    }\n" +
3461
					"}",
3462
					"pack/Color.java",
3463
					"package pack;\n" + 
3464
					"enum Color {WHITE, BLACK}"
3465
				},
3466
				"Black"
3467
			);
3468
		
3469
		this.runConformTest(
3470
			new String[] {
3471
				"pack/Color.java",
3472
				"package pack;\n" + 
3473
				"enum Color {RED, GREEN, YELLOW, WHITE}"
3474
			},
3475
			"",
3476
			null,
3477
			false,
3478
			null
3479
		);
3480
		
3481
		this.executeClass(
3482
			"pack/X.java",
3483
			"SUCCESS",
3484
			null,
3485
			false,
3486
			null,
3487
			null,
3488
			null);	
3489
	}
3239
}
3490
}

Return to bug 88395