From 6943fa5a50160dedd68ca69e6e77f8f1df029e5b Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 27 Jul 2007 10:00:14 +0000 Subject: [PATCH] Additional testcase for binding resolution. --- .../tests/IndexCBindingResolutionTest.java | 25 ++++++++- .../tests/IndexCPPBindingResolutionTest.java | 55 +++++++++++++------ 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java index 429db591fd4..f39c379ca03 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -348,4 +349,26 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase public void _testEnumeratorInStructScope() {fail("todo");} public void _testEnumeratorInUnionScope() {fail("todo");} public void _testMemberAccess() {fail("todo");} + + // // header file + // struct myStruct { + // int a; + // }; + // union myUnion { + // int b; + // }; + + // // referencing content + // struct myStruct; + // union myUnion; + // void test() { + // struct myStruct* u; + // union myUnion* v; + // u->a= 1; // since we include the definition, we may use the type. + // v->b= 1; // since we include the definition, we may use the type. + // } + public void testTypeDefinitionWithFwdDeclaration() { + getBindingFromASTName("a= 1", 1); + getBindingFromASTName("b= 1", 1); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index 1bc78030cb9..f6a706ab17d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -1136,6 +1137,28 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti assertEquals(1, getIndex().findNames(binding2, IIndex.FIND_DEFINITIONS).length); } + // // header file + // struct myStruct { + // int a; + // }; + // union myUnion { + // int b; + // }; + + // // referencing content + // struct myStruct; + // union myUnion; + // void test() { + // struct myStruct* u; + // union myUnion* v; + // u->a= 1; // since we include the definition, we may use the type. + // v->b= 1; // since we include the definition, we may use the type. + // } + public void testTypeDefinitionWithFwdDeclaration() { + getBindingFromASTName("a= 1", 1); + getBindingFromASTName("b= 1", 1); + } + /* CPP assertion helpers */ /* ##################################################################### */ @@ -1227,19 +1250,19 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti * @param cqn * @param qn may be null */ - static protected void assertPTM(IType type, String cqn, String qn) { - try { - assertTrue(type instanceof ICPPPointerToMemberType); - ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type; - ICPPClassType classType = ptmt.getMemberOfClass(); - assertQNEquals(cqn, classType); - if(qn!=null) { - assert(ptmt.getType() instanceof ICPPBinding); - ICPPBinding tyBinding = (ICPPBinding) ptmt.getType(); - assertQNEquals(qn, tyBinding); - } - } catch(DOMException de) { - fail(de.getMessage()); - } - } + static protected void assertPTM(IType type, String cqn, String qn) { + try { + assertTrue(type instanceof ICPPPointerToMemberType); + ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type; + ICPPClassType classType = ptmt.getMemberOfClass(); + assertQNEquals(cqn, classType); + if(qn!=null) { + assert(ptmt.getType() instanceof ICPPBinding); + ICPPBinding tyBinding = (ICPPBinding) ptmt.getType(); + assertQNEquals(qn, tyBinding); + } + } catch(DOMException de) { + fail(de.getMessage()); + } + } }