From: Samuel Benzaquen Date: Thu, 29 Aug 2013 15:39:26 +0000 (+0000) Subject: Fix tests to be more specific. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b80aad8d30340cdd47ecb6a5bafe46cf5e47cfe9;p=clang Fix tests to be more specific. The environments can inject some declaration in every translation unit, which can match very generic matchers, thus failing the tests. Summary: Fix tests to be more specific. The environments can inject some declaration in every translation unit, which can match very generic matchers, thus failing the tests. Reviewers: aaron.ballman CC: klimek, cfe-commits, revane Differential Revision: http://llvm-reviews.chandlerc.com/D1541 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189587 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index 874a4f35a0..9a24c80cc7 100644 --- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -169,22 +169,16 @@ TEST_F(RegistryTest, PolymorphicMatchers) { EXPECT_FALSE(matches("void f();", Func)); Matcher Anything = constructMatcher("anything").getTypedMatcher(); - Matcher RecordDecl = - constructMatcher("recordDecl", VariantMatcher::SingleMatcher(Anything)) - .getTypedMatcher(); - - EXPECT_TRUE(matches("int a;", Anything)); - EXPECT_TRUE(matches("class A {};", Anything)); - EXPECT_TRUE(matches("void f(){};", Anything)); - // FIXME: A couple of tests have been suppressed. - // I know it'd be bad with _MSC_VER here, though. -#if !defined(_MSC_VER) - EXPECT_FALSE(matches("int a;", RecordDecl)); -#endif - EXPECT_TRUE(matches("class A {};", RecordDecl)); -#if !defined(_MSC_VER) - EXPECT_FALSE(matches("void f(){};", RecordDecl)); -#endif + Matcher RecordDecl = constructMatcher( + "recordDecl", constructMatcher("hasName", std::string("Foo")), + VariantMatcher::SingleMatcher(Anything)).getTypedMatcher(); + + EXPECT_TRUE(matches("int Foo;", Anything)); + EXPECT_TRUE(matches("class Foo {};", Anything)); + EXPECT_TRUE(matches("void Foo(){};", Anything)); + EXPECT_FALSE(matches("int Foo;", RecordDecl)); + EXPECT_TRUE(matches("class Foo {};", RecordDecl)); + EXPECT_FALSE(matches("void Foo(){};", RecordDecl)); } TEST_F(RegistryTest, TemplateArgument) { @@ -263,7 +257,9 @@ TEST_F(RegistryTest, Adaptative) { TEST_F(RegistryTest, VariadicOp) { Matcher D = constructMatcher( - "anyOf", constructMatcher("recordDecl"), + "anyOf", + constructMatcher("recordDecl", + constructMatcher("hasName", std::string("Foo"))), constructMatcher("namedDecl", constructMatcher("hasName", std::string("foo")))) .getTypedMatcher();