Index: ASTConverterTestAST3_2.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.65 diff -u -r1.65 ASTConverterTestAST3_2.java --- ASTConverterTestAST3_2.java 15 Sep 2005 18:48:55 -0000 1.65 +++ ASTConverterTestAST3_2.java 28 Sep 2005 15:34:55 -0000 @@ -106,7 +106,7 @@ static { // TESTS_NAMES = new String[] {"test0602"}; -// TESTS_NUMBERS = new int[] { 619 }; + TESTS_NUMBERS = new int[] { 620 }; } public static Test suite() { return buildTestSuite(ASTConverterTestAST3_2.class); @@ -6812,4 +6812,78 @@ VariableDeclarationStatement declarationStatement = (VariableDeclarationStatement) statement2; assertEquals("Wrong number of fragments", 4, declarationStatement.fragments().size()); } + /** + * http://dev.eclipse.org/bugs/show_bug.cgi?id=109940 + */ + public void test0620() throws JavaModelException { + ICompilationUnit workingCopy = null; + try { + String contents = + "public class X {\n" + + " public static void main(String[] args) {\n" + + " System.out.println((int) \'\\0\');\n" + + " System.out.println((int) \'\\1\');\n" + + " System.out.println((int) \'\\2\');\n" + + " System.out.println((int) \'\\3\');\n" + + " System.out.println((int) \'\\4\');\n" + + " System.out.println((int) \'\\5\');\n" + + " System.out.println((int) \'\\6\');\n" + + " System.out.println((int) \'\\7\');\n" + + " System.out.println((int) \'\\077\');\n" + + " System.out.println((int) \'\\55\');\n" + + " System.out.println((int) \'\\77\');\n" + + " System.out.println((int) \'\\377\');\n" + + " }\n" + + "}"; + workingCopy = getWorkingCopy("/Converter/src/X.java", false/*resolve*/); + ASTNode node = buildAST( + contents, + workingCopy, + false); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize(unit, 0); + unit.accept(new ASTVisitor() { + public boolean visit(CharacterLiteral characterLiteral) { + try { + final String escapedValue = characterLiteral.getEscapedValue(); + final char charValue = characterLiteral.charValue(); + if (escapedValue.equals("\'\\0\'")) { + assertEquals("Wrong value", 0, charValue); + } else if (escapedValue.equals("\'\\1\'")) { + assertEquals("Wrong value", 1, charValue); + } else if (escapedValue.equals("\'\\2\'")) { + assertEquals("Wrong value", 2, charValue); + } else if (escapedValue.equals("\'\\3\'")) { + assertEquals("Wrong value", 3, charValue); + } else if (escapedValue.equals("\'\\4\'")) { + assertEquals("Wrong value", 4, charValue); + } else if (escapedValue.equals("\'\\5\'")) { + assertEquals("Wrong value", 5, charValue); + } else if (escapedValue.equals("\'\\6\'")) { + assertEquals("Wrong value", 6, charValue); + } else if (escapedValue.equals("\'\\7\'")) { + assertEquals("Wrong value", 7, charValue); + } else if (escapedValue.equals("\'\\077\'")) { + assertEquals("Wrong value", 63, charValue); + } else if (escapedValue.equals("\'\\55\'")) { + assertEquals("Wrong value", 45, charValue); + } else if (escapedValue.equals("\'\\77\'")) { + assertEquals("Wrong value", 63, charValue); + } else if (escapedValue.equals("\'\\377\'")) { + assertEquals("Wrong value", 255, charValue); + } else { + assertTrue("Should not get there", false); + } + } catch(IllegalArgumentException e) { + assertTrue("Should not happen", false); + } + return false; + } + }); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } + } }