[clangd] Eliminate direct usage of isAvailable() matcher. NFC
authorSam McCall <sam.mccall@gmail.com>
Fri, 6 May 2022 14:34:06 +0000 (16:34 +0200)
committerSam McCall <sam.mccall@gmail.com>
Fri, 6 May 2022 14:35:12 +0000 (16:35 +0200)
This prepares to replace the implementation of EXPECT_[UN]AVAILABLE with
something more efficient.

clang-tools-extra/clangd/unittests/tweaks/DumpRecordLayoutTests.cpp
clang-tools-extra/clangd/unittests/tweaks/SwapIfBranchesTests.cpp

index 7f7f629..fb0eda2 100644 (file)
@@ -22,10 +22,10 @@ TWEAK_TEST(DumpRecordLayout);
 
 TEST_F(DumpRecordLayoutTest, Test) {
   EXPECT_AVAILABLE("^s^truct ^X ^{ int x; ^};");
-  EXPECT_THAT("struct X { int ^a; };", Not(isAvailable()));
-  EXPECT_THAT("struct ^X;", Not(isAvailable()));
-  EXPECT_THAT("template <typename T> struct ^X { T t; };", Not(isAvailable()));
-  EXPECT_THAT("enum ^X {};", Not(isAvailable()));
+  EXPECT_UNAVAILABLE("struct X { int ^a; };");
+  EXPECT_UNAVAILABLE("struct ^X;");
+  EXPECT_UNAVAILABLE("template <typename T> struct ^X { T t; };");
+  EXPECT_UNAVAILABLE("enum ^X {};");
 
   EXPECT_THAT(apply("struct ^X { int x; int y; };"),
               AllOf(StartsWith("message:"), HasSubstr("0 |   int x")));
index b22da9d..0bfada8 100644 (file)
@@ -27,19 +27,17 @@ TEST_F(SwapIfBranchesTest, Test) {
   EXPECT_AVAILABLE("^i^f^^(^t^r^u^e^) { return; } ^e^l^s^e^ { return; }");
   EXPECT_UNAVAILABLE("if (true) {^return ^;^ } else { ^return^;^ }");
   // Available in subexpressions of the condition;
-  EXPECT_THAT("if(2 + [[2]] + 2) { return; } else {return;}", isAvailable());
+  EXPECT_AVAILABLE("if(2 + [[2]] + 2) { return; } else {return;}");
   // But not as part of the branches.
-  EXPECT_THAT("if(2 + 2 + 2) { [[return]]; } else { return; }",
-              Not(isAvailable()));
+  EXPECT_UNAVAILABLE("if(2 + 2 + 2) { [[return]]; } else { return; }");
   // Range covers the "else" token, so available.
-  EXPECT_THAT("if(2 + 2 + 2) { return[[; } else {return;]]}", isAvailable());
+  EXPECT_AVAILABLE("if(2 + 2 + 2) { return[[; } else {return;]]}");
   // Not available in compound statements in condition.
-  EXPECT_THAT("if([]{return [[true]];}()) { return; } else { return; }",
-              Not(isAvailable()));
+  EXPECT_UNAVAILABLE("if([]{return [[true]];}()) { return; } else { return; }");
   // Not available if both sides aren't braced.
-  EXPECT_THAT("^if (1) return; else { return; }", Not(isAvailable()));
+  EXPECT_UNAVAILABLE("^if (1) return; else { return; }");
   // Only one if statement is supported!
-  EXPECT_THAT("[[if(1){}else{}if(2){}else{}]]", Not(isAvailable()));
+  EXPECT_UNAVAILABLE("[[if(1){}else{}if(2){}else{}]]");
 }
 
 } // namespace