From 4c15ba6484ab99dfb4fd371a02ef86c58ade9c72 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 27 Apr 2008 20:49:18 +0000 Subject: [PATCH] Added a failing test case for bug 201204. --- .../parser/tests/ast2/AST2TemplateTests.java | 99 +++++++++++-------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index daedea13dae..a4d216ad4fc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -2000,6 +2000,65 @@ public class AST2TemplateTests extends AST2BaseTest { assertTrue( col.getName(2).resolveBinding() instanceof ICPPSpecialization ); } + // template + // struct Closure { + // Closure(T* obj, void (T::*method)()) {} + // }; + // + // template + // Closure* makeClosure(T* obj, void (T::*method)()) { + // return new Closure(obj, method); + // } + // + // struct A { + // void m1() {} + // void m2() { + // makeClosure(this, &A::m1); + // } + // }; + public void _testBug201204() throws Exception { + BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); + ICPPFunction fn= bh.assertNonProblem("makeClosure(this", 11, ICPPFunction.class); + } + + // class A {}; + // + // template class C { + // public: + // inline C(T& aRef) {} + // inline operator T&() {} + // }; + // + // void foo(A a) {} + // void bar(C ca) {} + // + // void main2() { + // const A a= *new A(); + // const C ca= *new C(*new A()); + // + // foo(a); + // bar(ca); + // } + public void testBug214646() throws Exception { + BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); + + IBinding b0= bh.assertNonProblem("foo(a)", 3); + IBinding b1= bh.assertNonProblem("bar(ca)", 3); + + assertInstance(b0, ICPPFunction.class); + assertInstance(b1, ICPPFunction.class); + + ICPPFunction f0= (ICPPFunction) b0, f1= (ICPPFunction) b1; + assertEquals(1, f0.getParameters().length); + assertEquals(1, f1.getParameters().length); + + assertInstance(f0.getParameters()[0].getType(), ICPPClassType.class); + assertFalse(f0 instanceof ICPPTemplateInstance); + assertFalse(f0 instanceof ICPPTemplateDefinition); + assertInstance(f1.getParameters()[0].getType(), ICPPClassType.class); + assertInstance(f1.getParameters()[0].getType(), ICPPTemplateInstance.class); + } + // // Brian W.'s example from bugzilla#167098 // template // class D { //CPPClassTemplate @@ -2180,7 +2239,7 @@ public class AST2TemplateTests extends AST2BaseTest { } } - // template + // template // class A { // public: // typedef _Tp a; @@ -2209,44 +2268,6 @@ public class AST2TemplateTests extends AST2BaseTest { } } - // class A {}; - // - // template class C { - // public: - // inline C(T& aRef) {} - // inline operator T&() {} - // }; - // - // void foo(A a) {} - // void bar(C ca) {} - // - // void main2() { - // const A a= *new A(); - // const C ca= *new C(*new A()); - // - // foo(a); - // bar(ca); - // } - public void testBug214646() throws Exception { - BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); - - IBinding b0= bh.assertNonProblem("foo(a)", 3); - IBinding b1= bh.assertNonProblem("bar(ca)", 3); - - assertInstance(b0, ICPPFunction.class); - assertInstance(b1, ICPPFunction.class); - - ICPPFunction f0= (ICPPFunction) b0, f1= (ICPPFunction) b1; - assertEquals(1, f0.getParameters().length); - assertEquals(1, f1.getParameters().length); - - assertInstance(f0.getParameters()[0].getType(), ICPPClassType.class); - assertFalse(f0 instanceof ICPPTemplateInstance); - assertFalse(f0 instanceof ICPPTemplateDefinition); - assertInstance(f1.getParameters()[0].getType(), ICPPClassType.class); - assertInstance(f1.getParameters()[0].getType(), ICPPTemplateInstance.class); - } - // class A {}; // class B {}; // template