mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
tests to show that bug 68235 is not our problem
This commit is contained in:
parent
112cf2a908
commit
b8c65f150f
3 changed files with 82 additions and 1 deletions
|
@ -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.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
import org.eclipse.cdt.core.parser.ast.ASTUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
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.IASTAbstractTypeSpecifierDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||||
|
@ -1967,7 +1968,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
public void testTypeIDSignature() throws Exception
|
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();
|
IASTTypeId typeId = v.getInitializerClause().getAssigmentExpression().getTypeId();
|
||||||
assertEquals( typeId.getFullSignature(), "int *"); //$NON-NLS-1$
|
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 ) ) );
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,3 +82,21 @@ void DeclsAndDefns::forwardMethod(){ }
|
||||||
int DeclsAndDefns::staticField = 5;
|
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();
|
||||||
|
};
|
||||||
|
}
|
|
@ -368,4 +368,36 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
|
|
||||||
assertTrue( match1.equals( match2 ) );
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue