1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-04-18 12:39:03 -07:00
parent 103f577926
commit bbc8a48c8c
2 changed files with 81 additions and 83 deletions

View file

@ -1265,6 +1265,29 @@ public class AST2CPPTests extends AST2TestBase {
assertInstances(collector, x2, 1);
}
// class A { A(void); A(const A &); };
public void testConstructors() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
ICPPConstructor[] ctors = A.getConstructors();
assertNotNull(ctors);
assertEquals(ctors.length, 2);
assertEquals(0, ctors[0].getParameters().length);
assertEquals(1, ctors[1].getParameters().length);
IType t = ctors[1].getParameters()[0].getType();
assertTrue(t instanceof ICPPReferenceType);
assertTrue(((ICPPReferenceType) t).getType() instanceof IQualifierType);
IQualifierType qt = (IQualifierType) ((ICPPReferenceType) t).getType();
assertTrue(qt.isConst());
assertSame(qt.getType(), A);
}
// class A {};
public void testImplicitConstructors() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
@ -1289,27 +1312,32 @@ public class AST2CPPTests extends AST2TestBase {
assertSame(qt.getType(), A);
}
// class A { A(void); A(const A &); };
public void testConstructors() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
// template<typename T> struct C {
// C(const C<T>& c) {}
// };
// struct D {
// typedef const D& TD;
// D(TD c) {}
// };
// struct E {
// E();
// };
// typedef E F;
// F::E() {}
public void testImplicitConstructors_360223() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
ICPPClassType c= bh.assertNonProblem("C", 0);
ICPPConstructor[] ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
ICPPConstructor[] ctors = A.getConstructors();
c= bh.assertNonProblem("D", 0);
ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
assertNotNull(ctors);
assertEquals(ctors.length, 2);
assertEquals(0, ctors[0].getParameters().length);
assertEquals(1, ctors[1].getParameters().length);
IType t = ctors[1].getParameters()[0].getType();
assertTrue(t instanceof ICPPReferenceType);
assertTrue(((ICPPReferenceType) t).getType() instanceof IQualifierType);
IQualifierType qt = (IQualifierType) ((ICPPReferenceType) t).getType();
assertTrue(qt.isConst());
assertSame(qt.getType(), A);
IBinding ctor= bh.assertNonProblem("E() {}", 1);
assertTrue(ctor instanceof ICPPConstructor);
}
// class A { ~A(); };
@ -9636,34 +9664,6 @@ public class AST2CPPTests extends AST2TestBase {
parseAndCheckBindings();
}
// template<typename T> struct C {
// C(const C<T>& c) {}
// };
// struct D {
// typedef const D& TD;
// D(TD c) {}
// };
// struct E {
// E();
// };
// typedef E F;
// F::E(){}
public void testImplicitCtors_360223() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
ICPPClassType c= bh.assertNonProblem("C", 0);
ICPPConstructor[] ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
c= bh.assertNonProblem("D", 0);
ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
IBinding ctor= bh.assertNonProblem("E(){}", 1);
assertTrue(ctor instanceof ICPPConstructor);
}
// struct S;
// struct S {
// S();

View file

@ -28,7 +28,6 @@ import org.eclipse.cdt.core.parser.IToken;
*/
@SuppressWarnings("nls")
public enum OverloadableOperator {
GT(">"),
LT("<"),
NOT("!"),
@ -87,7 +86,6 @@ public enum OverloadableOperator {
return rep;
}
/**
* Returns true if the given name equals 'operator new'
* or 'operator new[]'.