### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.97 diff -u -r1.97 ASTConverterTestAST3_2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 21 Jun 2006 14:39:51 -0000 1.97 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 24 Jun 2006 21:21:53 -0000 @@ -107,7 +107,7 @@ static { // TESTS_NAMES = new String[] {"test0602"}; -// TESTS_NUMBERS = new int[] { 647 }; +// TESTS_NUMBERS = new int[] { 652 }; } public static Test suite() { return buildModelTestSuite(ASTConverterTestAST3_2.class); @@ -7946,4 +7946,63 @@ workingCopy.discardWorkingCopy(); } } + /** + * http://dev.eclipse.org/bugs/show_bug.cgi?id=148224 + */ + public void test0652() throws JavaModelException { + ICompilationUnit workingCopy = null; + try { + String contents = + "public class X {\n" + + " int i;\n" + + "}"; + workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); + ASTNode node = buildAST( + contents, + workingCopy, + false, + true); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize(unit, 0); + node = getASTNode(unit, 0, 0); + assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType()); + FieldDeclaration declaration = (FieldDeclaration) node; + Type type = declaration.getType(); + ITypeBinding typeBinding = type.resolveBinding(); + assertTrue("Not a primitive type", typeBinding.isPrimitive()); + assertEquals("Not int", "int", typeBinding.getName()); + AST localAst = unit.getAST(); + try { + localAst.resolveArrayType(typeBinding, -1); + assertTrue("Should throw an exception", false); + } catch(IllegalArgumentException exception) { + // ignore + } + try { + localAst.resolveArrayType(typeBinding, 0); + assertTrue("Should throw an exception", false); + } catch(IllegalArgumentException exception) { + // ignore + } + try { + localAst.resolveArrayType(typeBinding, 256); + assertTrue("Should throw an exception", false); + } catch(IllegalArgumentException exception) { + // ignore + } + ITypeBinding binding = localAst.resolveArrayType(typeBinding, 2); + assertEquals("Wrong dimensions", 2, binding.getDimensions()); + assertTrue("Not an array type binding", binding.isArray()); + ITypeBinding componentType = binding.getComponentType(); + assertTrue("Not an array type binding", componentType.isArray()); + assertEquals("Wrong dimensions", 1, componentType.getDimensions()); + componentType = componentType.getComponentType(); + assertFalse("An array type binding", componentType.isArray()); + assertEquals("Wrong dimensions", 0, componentType.getDimensions()); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } + } } \ No newline at end of file