[PATCH] D42063: [clangd] Avoid combinatorial explosion in CodeCompleteTests.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 04:22:58 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL322547: [clangd] Avoid combinatorial explosion in CodeCompleteTests. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42063?vs=129836&id=129936#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42063

Files:
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -255,26 +255,26 @@
 }
 
 TEST(CompletionTest, CompletionOptions) {
-  clangd::CodeCompleteOptions Opts;
-  for (bool IncludeMacros : {true, false}) {
-    Opts.IncludeMacros = IncludeMacros;
-    for (bool IncludeGlobals : {true, false}) {
-      Opts.IncludeGlobals = IncludeGlobals;
-      for (bool IncludeBriefComments : {true, false}) {
-        Opts.IncludeBriefComments = IncludeBriefComments;
-        for (bool EnableSnippets : {true, false}) {
-          Opts.EnableSnippets = EnableSnippets;
-          for (bool IncludeCodePatterns : {true, false}) {
-            Opts.IncludeCodePatterns = IncludeCodePatterns;
-            for (bool IncludeIneligibleResults : {true, false}) {
-              Opts.IncludeIneligibleResults = IncludeIneligibleResults;
-              TestAfterDotCompletion(Opts);
-              TestGlobalScopeCompletion(Opts);
-            }
-          }
-        }
-      }
-    }
+  auto Test = [&](const clangd::CodeCompleteOptions &Opts) {
+    TestAfterDotCompletion(Opts);
+    TestGlobalScopeCompletion(Opts);
+  };
+  // We used to test every combination of options, but that got too slow (2^N).
+  auto Flags = {
+    &clangd::CodeCompleteOptions::IncludeMacros,
+    &clangd::CodeCompleteOptions::IncludeGlobals,
+    &clangd::CodeCompleteOptions::IncludeBriefComments,
+    &clangd::CodeCompleteOptions::EnableSnippets,
+    &clangd::CodeCompleteOptions::IncludeCodePatterns,
+    &clangd::CodeCompleteOptions::IncludeIneligibleResults,
+  };
+  // Test default options.
+  Test({});
+  // Test with one flag flipped.
+  for (auto &F : Flags) {
+    clangd::CodeCompleteOptions O;
+    O.*F ^= true;
+    Test(O);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42063.129936.patch
Type: text/x-patch
Size: 1940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180116/21f75a2c/attachment.bin>


More information about the cfe-commits mailing list