[SyntaxTree][Synthesis] Improve testing `createLeaf`
authorEduardo Caldas <ecaldas@google.com>
Thu, 17 Sep 2020 15:39:18 +0000 (15:39 +0000)
committerEduardo Caldas <ecaldas@google.com>
Mon, 21 Sep 2020 06:11:46 +0000 (06:11 +0000)
The new test shows that `createLeaf` depends on the C++ version.

Differential Revision: https://reviews.llvm.org/D87896

clang/unittests/Tooling/Syntax/SynthesisTest.cpp

index a882714..8d9fb70 100644 (file)
@@ -51,6 +51,19 @@ TEST_P(SynthesisTest, Leaf_Punctuation) {
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Punctuation_CXX) {
+  if (!GetParam().isCXX())
+    return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::coloncolon);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'::' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Keyword) {
   buildTree("", GetParam());
 
@@ -61,6 +74,19 @@ TEST_P(SynthesisTest, Leaf_Keyword) {
   )txt"));
 }
 
+TEST_P(SynthesisTest, Leaf_Keyword_CXX11) {
+  if (!GetParam().isCXX11OrLater())
+    return;
+
+  buildTree("", GetParam());
+
+  auto *Leaf = createLeaf(*Arena, tok::kw_nullptr);
+
+  EXPECT_TRUE(treeDumpEqual(Leaf, R"txt(
+'nullptr' Detached synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Leaf_Identifier) {
   buildTree("", GetParam());