Index: src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java,v retrieving revision 1.10 diff -u -r1.10 CreateMembersTests.java --- src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java 3 May 2005 14:08:59 -0000 1.10 +++ src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java 17 May 2005 15:35:02 -0000 @@ -34,7 +34,7 @@ // Names of tests to run: can be "testBugXXXX" or "BugXXXX") // TESTS_PREFIX = "testCombineAccessRestrictions"; // TESTS_NAMES = new String[] {"test004"}; -// TESTS_NUMBERS = new int[] { 23, 28, 38 }; +// TESTS_NUMBERS = new int[] { 5, 6 }; // TESTS_RANGE = new int[] { 21, 38 }; } public static Test suite() { @@ -148,5 +148,54 @@ JavaCore.setOptions(oldOptions); } } - + + public void test005() throws JavaModelException { + Hashtable oldOptions = JavaCore.getOptions(); + try { + Hashtable options = new Hashtable(oldOptions); + options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + JavaCore.setOptions(options); + ICompilationUnit compilationUnit = getCompilationUnit("CreateMembers", "src", "", "E2.java"); + assertNotNull("No compilation unit", compilationUnit); + IType[] types = compilationUnit.getTypes(); + assertNotNull("No types", types); + assertEquals("Wrong size", 1, types.length); + IType type = types[0]; + type.createField("int i;", null, true, null); + String expectedSource = + "public enum E2 {\n" + + " A, B, C;\n\n" + + " int i;\n" + + "}"; + assertSourceEquals("Unexpected source", expectedSource, type.getSource()); + } finally { + JavaCore.setOptions(oldOptions); + } + } + + public void test006() throws JavaModelException { + Hashtable oldOptions = JavaCore.getOptions(); + try { + Hashtable options = new Hashtable(oldOptions); + options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + JavaCore.setOptions(options); + ICompilationUnit compilationUnit = getCompilationUnit("CreateMembers", "src", "", "E3.java"); + assertNotNull("No compilation unit", compilationUnit); + IType[] types = compilationUnit.getTypes(); + assertNotNull("No types", types); + assertEquals("Wrong size", 1, types.length); + IType type = types[0]; + type.createType("class DD {}", null, true, null); + String expectedSource = + "public enum E3 {\n" + + " A, B, C;\n\n" + + " class DD {}\n" + + "}"; + assertSourceEquals("Unexpected source", expectedSource, type.getSource()); + } finally { + JavaCore.setOptions(oldOptions); + } + } } Index: workspace/CreateMembers/src/E2.java =================================================================== RCS file: workspace/CreateMembers/src/E2.java diff -N workspace/CreateMembers/src/E2.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/CreateMembers/src/E2.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +public enum E2 { + A, B, C +} Index: workspace/CreateMembers/src/E3.java =================================================================== RCS file: workspace/CreateMembers/src/E3.java diff -N workspace/CreateMembers/src/E3.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/CreateMembers/src/E3.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +public enum E3 { + A, B, C +}