Lines 37-43
Link Here
|
37 |
super(name); |
37 |
super(name); |
38 |
} |
38 |
} |
39 |
static { |
39 |
static { |
40 |
// TESTS_NAMES = new String[] { "testAddExternalLibFolder6" }; |
40 |
// TESTS_NAMES = new String[] { "testBug360164" }; |
41 |
} |
41 |
} |
42 |
public static Test suite() { |
42 |
public static Test suite() { |
43 |
TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class); |
43 |
TestSuite suite = (TestSuite) buildModelTestSuite(JavaProjectTests.class); |
Lines 2389-2392
Link Here
|
2389 |
deleteProject("JavaProjectTestsInvalidProject"); |
2389 |
deleteProject("JavaProjectTestsInvalidProject"); |
2390 |
} |
2390 |
} |
2391 |
} |
2391 |
} |
|
|
2392 |
// Bug 360164 - Compile error in XSDImpl |
2393 |
// test that we can tolerate if a 1.4 project refers to an enum inside a library. |
2394 |
public void testBug360164() throws IOException, CoreException { |
2395 |
String libPath = getWorkspacePath()+"JavaProjectTests/bin/bug360164.jar"; |
2396 |
try { |
2397 |
this.createJavaProject("P", new String[] {"src"}, new String[] {"JCL_LIB", libPath}, "bin", JavaCore.VERSION_1_4); |
2398 |
IFile file = createFile("/P/src/X.java", |
2399 |
"import p360164.Provider;\n" + |
2400 |
"import p360164.MyEnum;\n" + |
2401 |
"public class X {\n" + |
2402 |
" int foo(Provider p) {\n" + |
2403 |
" MyEnum e = p.getE();\n" + |
2404 |
" switch (e.getValue()) {\n" + |
2405 |
" case MyEnum.ONE_COMPAT: return 1;\n" + |
2406 |
" case MyEnum.TWO_COMPAT: return 2;\n" + |
2407 |
" }\n" + |
2408 |
" return 0;\n" + |
2409 |
" }\n" + |
2410 |
"}" |
2411 |
); |
2412 |
ICompilationUnit unit = (ICompilationUnit)JavaCore.create(file); |
2413 |
ProblemRequestor problemRequestor = new ProblemRequestor(); |
2414 |
WorkingCopyOwner owner = newWorkingCopyOwner(problemRequestor); |
2415 |
unit.getWorkingCopy(owner, null); |
2416 |
assertProblems("Unexpected problems", |
2417 |
"----------\n" + |
2418 |
"----------\n", |
2419 |
problemRequestor); |
2420 |
} finally { |
2421 |
this.deleteProject("P"); |
2422 |
} |
2423 |
} |
2424 |
// Bug 360164 - Compile error in XSDImpl |
2425 |
// test that we still report the missing superclass when resolving non-local methods |
2426 |
public void testBug360164a() throws IOException, CoreException { |
2427 |
String libPath = getWorkspacePath()+"JavaProjectTests/bin/bug360164.jar"; |
2428 |
try { |
2429 |
this.createJavaProject("P", new String[] {"src"}, new String[] {"JCL_LIB", libPath}, "bin", JavaCore.VERSION_1_4); |
2430 |
IFile file = createFile("/P/src/X.java", |
2431 |
"import p360164.Provider;\n" + |
2432 |
"import p360164.MyEnum;\n" + |
2433 |
"public class X {\n" + |
2434 |
" String foo(Provider p) {\n" + |
2435 |
" MyEnum e = p.getE();\n" + |
2436 |
" return e.toString();\n" + |
2437 |
" }\n" + |
2438 |
"}" |
2439 |
); |
2440 |
ICompilationUnit unit = (ICompilationUnit)JavaCore.create(file); |
2441 |
ProblemRequestor problemRequestor = new ProblemRequestor(); |
2442 |
WorkingCopyOwner owner = newWorkingCopyOwner(problemRequestor); |
2443 |
unit.getWorkingCopy(owner, null); |
2444 |
assertProblems("Unexpected problems", |
2445 |
"----------\n" + |
2446 |
"1. ERROR in /P/src/X.java\n" + |
2447 |
"The type java.lang.Enum cannot be resolved. It is indirectly referenced from required .class files\n" + |
2448 |
"----------\n", |
2449 |
problemRequestor); |
2450 |
} finally { |
2451 |
this.deleteProject("P"); |
2452 |
} |
2453 |
} |
2454 |
// Bug 360317 - [compiler] report switch over enum in 1.4- mode |
2455 |
public void testBug360317() throws IOException, CoreException { |
2456 |
// use the setup from testBug360164(): |
2457 |
String libPath = getWorkspacePath()+"JavaProjectTests/bin/bug360164.jar"; |
2458 |
try { |
2459 |
this.createJavaProject("P", new String[] {"src"}, new String[] {"JCL_LIB", libPath}, "bin", JavaCore.VERSION_1_4); |
2460 |
String sourceX = "import p360164.Provider;\n" + |
2461 |
"import p360164.MyEnum;\n" + |
2462 |
"public class X {\n" + |
2463 |
" int foo(Provider p) {\n" + |
2464 |
" MyEnum e = p.getE();\n" + |
2465 |
" switch (e) {\n" + |
2466 |
" case ONE: return 1;\n" + |
2467 |
" case TWO: return 2;\n" + |
2468 |
" }\n" + |
2469 |
" return 0;\n" + |
2470 |
" }\n" + |
2471 |
"}"; |
2472 |
IFile file = createFile("/P/src/X.java", sourceX); |
2473 |
ICompilationUnit unit = (ICompilationUnit)JavaCore.create(file); |
2474 |
ProblemRequestor problemRequestor = new ProblemRequestor(); |
2475 |
problemRequestor.initialize(sourceX.toCharArray()); |
2476 |
WorkingCopyOwner owner = newWorkingCopyOwner(problemRequestor); |
2477 |
unit.getWorkingCopy(owner, null); |
2478 |
assertProblems("Unexpected problems", |
2479 |
"----------\n" + |
2480 |
"1. ERROR in /P/src/X.java (at line 6)\n" + |
2481 |
" switch (e) {\n" + |
2482 |
" ^\n" + |
2483 |
"Cannot switch on an enum value for source level below 1.5. Only convertible int values are permitted\n" + |
2484 |
"----------\n", |
2485 |
problemRequestor); |
2486 |
} finally { |
2487 |
this.deleteProject("P"); |
2488 |
} |
2489 |
} |
2392 |
} |
2490 |
} |