From b8c65f150fe7b798b530b548e76a6e0f338d44a3 Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Tue, 22 Jun 2004 21:48:31 +0000 Subject: [PATCH] tests to show that bug 68235 is not our problem --- .../parser/tests/CompleteParseASTTest.java | 33 ++++++++++++++++++- .../resources/search/classDecl.cpp | 18 ++++++++++ .../core/search/tests/OtherPatternTests.java | 32 ++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index 9a5ced55dec..f7c587308d5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.ASTUtil; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; +import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; import org.eclipse.cdt.core.parser.ast.IASTClassReference; @@ -1967,7 +1968,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testTypeIDSignature() throws Exception { - IASTVariable v = (IASTVariable) parse( "int * v = (int*)0;").getDeclarations().next(); + IASTVariable v = (IASTVariable) parse( "int * v = (int*)0;").getDeclarations().next();//$NON-NLS-1$ IASTTypeId typeId = v.getInitializerClause().getAssigmentExpression().getTypeId(); assertEquals( typeId.getFullSignature(), "int *"); //$NON-NLS-1$ } @@ -1991,4 +1992,34 @@ public class CompleteParseASTTest extends CompleteParseBaseTest assertAllReferences( 2, createTaskList( new Task( f1, 1, false, false), new Task( t ) ) ); } + public void testBug68235() throws Exception{ + Writer writer = new StringWriter(); + writer.write( " struct xTag { int x; }; "); + writer.write( " typedef xTag xType; "); + writer.write( " typedef struct yTag { int x; } yType; "); + writer.write( " class C1 { xType x; yType y; }; "); + + Iterator i = parse( writer.toString() ).getDeclarations(); + + IASTClassSpecifier xTag = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + IASTTypedefDeclaration xType = (IASTTypedefDeclaration) i.next(); + IASTSimpleTypeSpecifier typeSpec = (IASTSimpleTypeSpecifier) xType.getAbstractDeclarator().getTypeSpecifier(); + assertEquals( typeSpec.getTypeSpecifier(), xTag ); + + IASTTypedefDeclaration yType = (IASTTypedefDeclaration) i.next(); + IASTClassSpecifier yTag = (IASTClassSpecifier) yType.getAbstractDeclarator().getTypeSpecifier(); + + IASTClassSpecifier C1 = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + assertFalse( i.hasNext() ); + i = getDeclarations( C1 ); + + IASTField x = (IASTField) i.next(); + IASTField y = (IASTField) i.next(); + assertFalse( i.hasNext() ); + + IASTSimpleTypeSpecifier simple = (IASTSimpleTypeSpecifier) x.getAbstractDeclaration().getTypeSpecifier(); + assertEquals( simple.getTypeSpecifier(), xType ); + simple = (IASTSimpleTypeSpecifier) y.getAbstractDeclaration().getTypeSpecifier(); + assertEquals( simple.getTypeSpecifier(), yType ); + } } diff --git a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp index 50954fd50b8..f2fa14f0168 100644 --- a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp @@ -82,3 +82,21 @@ void DeclsAndDefns::forwardMethod(){ } int DeclsAndDefns::staticField = 5; +namespace bug68235{ + struct xTag { + int x; + }; + typedef xTag xType; + + typedef struct yTag { + int x; + } yType; + + class C1{ + public: + xType x; + yType y; + C1(); + ~C1(); + }; +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java index 10000e9ea3b..a55f869c678 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java @@ -368,4 +368,36 @@ public class OtherPatternTests extends BaseSearchTest { assertTrue( match1.equals( match2 ) ); } + + public void testBug68235(){ + ICSearchPattern pattern = SearchEngine.createSearchPattern( "bug68235::xTag", STRUCT, DECLARATIONS, true ); + search( workspace, pattern, scope, resultCollector ); + Set matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 1 ); + + pattern = SearchEngine.createSearchPattern( "bug68235::yTag", STRUCT, DECLARATIONS, true ); + search( workspace, pattern, scope, resultCollector ); + matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 1 ); + + pattern = SearchEngine.createSearchPattern( "bug68235::xType", TYPEDEF, DECLARATIONS, true ); + search( workspace, pattern, scope, resultCollector ); + matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 1 ); + + pattern = SearchEngine.createSearchPattern( "bug68235::yType", TYPEDEF, DECLARATIONS, true ); + search( workspace, pattern, scope, resultCollector ); + matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 1 ); + + pattern = SearchEngine.createSearchPattern( "bug68235::xType", TYPEDEF, REFERENCES, true ); + search( workspace, pattern, scope, resultCollector ); + matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 1 ); + + pattern = SearchEngine.createSearchPattern( "bug68235::yType", TYPEDEF, REFERENCES, true ); + search( workspace, pattern, scope, resultCollector ); + matches = resultCollector.getSearchResults(); + assertEquals( matches.size(), 1 ); + } }