[SyntaxTree] Split FreeStandingClass tests
authorEduardo Caldas <ecaldas@google.com>
Mon, 24 Aug 2020 10:07:27 +0000 (10:07 +0000)
committerEduardo Caldas <ecaldas@google.com>
Mon, 24 Aug 2020 14:31:45 +0000 (14:31 +0000)
Differential Revision: https://reviews.llvm.org/D86440

clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

index 93f510e..8dbf99c 100644 (file)
@@ -2515,55 +2515,65 @@ UsingDeclaration
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, FreeStandingClasses) {
-  // Free-standing classes, must live inside a SimpleDeclaration.
-  EXPECT_TRUE(treeDumpEqual(
+TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
-struct X;
-struct X {};
-
-struct Y *y1;
-struct Y {} *y2;
+[[struct X;]]
+[[struct Y *y1;]]
+)cpp",
+      {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+`-;
+)txt",
+       R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-SimpleDeclarator
+| |-*
+| `-y1
+`-;
+)txt"}));
+}
 
-struct {} *a1;
+TEST_P(SyntaxTreeTest, FreeStandingClasses_Definition) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+      R"cpp(
+[[struct X {};]]
+[[struct Y {} *y2;]]
+[[struct {} *a1;]]
 )cpp",
-      R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-SimpleDeclarator
-| | |-*
-| | `-y1
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-{
-| |-}
-| |-SimpleDeclarator
-| | |-*
-| | `-y2
-| `-;
-`-SimpleDeclaration
-  |-struct
-  |-{
-  |-}
-  |-SimpleDeclarator
-  | |-*
-  | `-a1
-  `-;
-)txt"));
+      {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+|-{
+|-}
+`-;
+)txt",
+       R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-y2
+`-;
+)txt",
+       R"txt(
+SimpleDeclaration
+|-struct
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-a1
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, StaticMemberFunction) {