diff --git a/kythe/cxx/verifier/BUILD b/kythe/cxx/verifier/BUILD index c151e25eab..54c62d998c 100644 --- a/kythe/cxx/verifier/BUILD +++ b/kythe/cxx/verifier/BUILD @@ -61,7 +61,6 @@ cc_library( deps = [ ":assertions_to_souffle", ":lexparse", - ":lib", "//third_party/souffle:parse_transform", "@com_github_google_glog//:glog", "@com_google_absl//absl/strings", @@ -93,7 +92,6 @@ cc_library( ], deps = [ ":lexparse", - ":lib", "@com_google_absl//absl/strings", ], ) @@ -106,6 +104,7 @@ cc_test( deps = [ ":assertions_to_souffle", ":lexparse", + ":lib", ":pretty_printer", "//third_party:gtest", "//third_party:gtest_main", @@ -164,6 +163,7 @@ cc_library( deps = [ ":lexparse", ":pretty_printer", + ":souffle_interpreter", "//kythe/cxx/common:file_utils", "//kythe/cxx/common:kythe_uri", "//kythe/cxx/common:scope_guard", diff --git a/kythe/cxx/verifier/assertion_ast.h b/kythe/cxx/verifier/assertion_ast.h index 5dcdb071b6..b226a73ea2 100644 --- a/kythe/cxx/verifier/assertion_ast.h +++ b/kythe/cxx/verifier/assertion_ast.h @@ -352,6 +352,25 @@ struct GoalGroup { std::vector goals; ///< Grouped goals, implicitly conjoined. }; +/// \brief A database of fact-shaped AstNodes. +using Database = std::vector; + +/// \brief Multimap from anchor offsets to anchor VName tuples. +using AnchorMap = std::multimap, AstNode*>; + +/// An EVar whose assignment is interesting to display. +struct Inspection { + enum class Kind { + EXPLICIT, ///< The user requested this inspection (with "?"). + IMPLICIT ///< This inspection was added by default. + }; + std::string label; ///< A label for user reference. + EVar* evar; ///< The EVar to inspect. + Kind kind; ///< Whether this inspection was added by default. + Inspection(const std::string& label, EVar* evar, Kind kind) + : label(label), evar(evar), kind(kind) {} +}; + } // namespace verifier } // namespace kythe diff --git a/kythe/cxx/verifier/assertions.h b/kythe/cxx/verifier/assertions.h index aa09954f9a..c998b69769 100644 --- a/kythe/cxx/verifier/assertions.h +++ b/kythe/cxx/verifier/assertions.h @@ -32,9 +32,6 @@ class AssertionParserImpl; namespace kythe { namespace verifier { -/// \brief A database of fact-shaped AstNodes. -using Database = std::vector; - class Verifier; /// \brief Parses logic programs. @@ -80,19 +77,6 @@ class AssertionParser { /// \brief All of the goal groups in this `AssertionParser`. std::vector& groups() { return groups_; } - /// An EVar whose assignment is interesting to display. - struct Inspection { - enum class Kind { - EXPLICIT, ///< The user requested this inspection (with "?"). - IMPLICIT ///< This inspection was added by default. - }; - std::string label; ///< A label for user reference. - EVar* evar; ///< The EVar to inspect. - Kind kind; ///< Whether this inspection was added by default. - Inspection(const std::string& label, EVar* evar, Kind kind) - : label(label), evar(evar), kind(kind) {} - }; - /// \brief All of the inspections in this `AssertionParser`. std::vector& inspections() { return inspections_; } @@ -333,9 +317,6 @@ class AssertionParser { /// The current file's corpus. Symbol corpus_; }; - -/// Multimap from anchor offsets to anchor VName tuples. -using AnchorMap = std::multimap, AstNode*>; } // namespace verifier } // namespace kythe diff --git a/kythe/cxx/verifier/assertions_to_souffle.cc b/kythe/cxx/verifier/assertions_to_souffle.cc index 3ef9d9f75e..f341459467 100644 --- a/kythe/cxx/verifier/assertions_to_souffle.cc +++ b/kythe/cxx/verifier/assertions_to_souffle.cc @@ -37,7 +37,7 @@ result() :- true bool SouffleProgram::Lower(const SymbolTable& symbol_table, const std::vector& goal_groups) { code_ = emit_prelude_ ? std::string(kGlobalDecls) : ""; - CHECK_EQ(0, goal_groups.size()) << "(unimplemented)"; + CHECK_LE(goal_groups.size(), 1) << "(unimplemented)"; absl::StrAppend(&code_, ".\n"); return true; } diff --git a/kythe/cxx/verifier/souffle_interpreter.cc b/kythe/cxx/verifier/souffle_interpreter.cc index 2099354173..96982358b1 100644 --- a/kythe/cxx/verifier/souffle_interpreter.cc +++ b/kythe/cxx/verifier/souffle_interpreter.cc @@ -24,7 +24,6 @@ #include "glog/logging.h" #include "interpreter/Engine.h" #include "kythe/cxx/verifier/assertions_to_souffle.h" -#include "kythe/cxx/verifier/verifier.h" #include "souffle/RamTypes.h" #include "souffle/io/IOSystem.h" #include "third_party/souffle/parse_transform.h" @@ -176,11 +175,11 @@ class KytheWriteStreamFactory : public souffle::WriteStreamFactory { }; } // anonymous namespace -SouffleResult RunSouffle( - const SymbolTable& symbol_table, const std::vector& goal_groups, - const Database& database, const AnchorMap& anchors, - const std::vector& inspections, - std::function inspect) { +SouffleResult RunSouffle(const SymbolTable& symbol_table, + const std::vector& goal_groups, + const Database& database, const AnchorMap& anchors, + const std::vector& inspections, + std::function inspect) { SouffleResult result{}; SouffleProgram program; if (!program.Lower(symbol_table, goal_groups)) { diff --git a/kythe/cxx/verifier/souffle_interpreter.h b/kythe/cxx/verifier/souffle_interpreter.h index cf3e217680..ef4ea9f2d5 100644 --- a/kythe/cxx/verifier/souffle_interpreter.h +++ b/kythe/cxx/verifier/souffle_interpreter.h @@ -17,7 +17,7 @@ #ifndef KYTHE_CXX_VERIFIER_SOUFFLE_INTERPRETER_H_ #define KYTHE_CXX_VERIFIER_SOUFFLE_INTERPRETER_H_ -#include "kythe/cxx/verifier/assertions.h" +#include "kythe/cxx/verifier/assertion_ast.h" namespace kythe::verifier { struct SouffleResult { @@ -37,11 +37,11 @@ struct SouffleResult { /// provided list of inspections; a false return value stops iterating through /// inspection results and fails the solution, while a true result continues. /// \return a `SouffleResult` describing how the run went. -SouffleResult RunSouffle( - const SymbolTable& symbol_table, const std::vector& goal_groups, - const Database& database, const AnchorMap& anchors, - const std::vector& inspections, - std::function inspect); +SouffleResult RunSouffle(const SymbolTable& symbol_table, + const std::vector& goal_groups, + const Database& database, const AnchorMap& anchors, + const std::vector& inspections, + std::function inspect); } // namespace kythe::verifier #endif // defined(KYTHE_CXX_VERIFIER_SOUFFLE_INTERPRETER_H_) diff --git a/kythe/cxx/verifier/souffle_interpreter_test.cc b/kythe/cxx/verifier/souffle_interpreter_test.cc index a1453ded8f..6348951617 100644 --- a/kythe/cxx/verifier/souffle_interpreter_test.cc +++ b/kythe/cxx/verifier/souffle_interpreter_test.cc @@ -25,10 +25,9 @@ TEST(SouffleInterpreterTest, SmokeTest) { Database db; AnchorMap anchors; std::vector groups; - std::vector inspections; - auto result = - RunSouffle(symbols, groups, db, anchors, inspections, - [](const AssertionParser::Inspection&) { return true; }); + std::vector inspections; + auto result = RunSouffle(symbols, groups, db, anchors, inspections, + [](const Inspection&) { return true; }); ASSERT_TRUE(result.success); } } // namespace kythe::verifier diff --git a/kythe/cxx/verifier/verifier.cc b/kythe/cxx/verifier/verifier.cc index bbd321996c..37ae2d4b71 100644 --- a/kythe/cxx/verifier/verifier.cc +++ b/kythe/cxx/verifier/verifier.cc @@ -30,6 +30,7 @@ #include "google/protobuf/util/json_util.h" #include "kythe/cxx/common/kythe_uri.h" #include "kythe/cxx/common/scope_guard.h" +#include "kythe/cxx/verifier/souffle_interpreter.h" #include "kythe/proto/common.pb.h" #include "kythe/proto/storage.pb.h" @@ -336,8 +337,6 @@ static bool FastLookupFactLessThan(AstNode* a, AstNode* b) { // look at deferring to a pre-existing system. class Solver { public: - using Inspection = AssertionParser::Inspection; - Solver(Verifier* context, Database& database, AnchorMap& anchors, std::function& inspect) : context_(*context), @@ -960,24 +959,31 @@ void Verifier::DumpErrorGoal(size_t group, size_t index) { } bool Verifier::VerifyAllGoals( - std::function inspect) { + std::function inspect) { if (use_fast_solver_) { - return true; - } - if (!PrepareDatabase()) { - return false; + auto result = RunSouffle(symbol_table_, parser_.groups(), facts_, anchors_, + parser_.inspections(), [&](const Inspection& i) { + return inspect(this, i); + }); + highest_goal_reached_ = result.highest_goal_reached; + highest_group_reached_ = result.highest_group_reached; + return result.success; + } else { + if (!PrepareDatabase()) { + return false; + } + Solver solver(this, facts_, anchors_, inspect); + bool result = solver.Solve(); + highest_goal_reached_ = solver.highest_goal_reached(); + highest_group_reached_ = solver.highest_group_reached(); + return result; } - Solver solver(this, facts_, anchors_, inspect); - bool result = solver.Solve(); - highest_goal_reached_ = solver.highest_goal_reached(); - highest_group_reached_ = solver.highest_group_reached(); - return result; } bool Verifier::VerifyAllGoals() { return VerifyAllGoals([this](Verifier* context, - const Solver::Inspection& inspection) { - if (inspection.kind == Solver::Inspection::Kind::EXPLICIT) { + const Inspection& inspection) { + if (inspection.kind == Inspection::Kind::EXPLICIT) { FileHandlePrettyPrinter printer(saving_assignments_ ? stderr : stdout); printer.Print(inspection.label); printer.Print(": "); diff --git a/kythe/cxx/verifier/verifier.h b/kythe/cxx/verifier/verifier.h index f2626ca71c..b1da9c4a3e 100644 --- a/kythe/cxx/verifier/verifier.h +++ b/kythe/cxx/verifier/verifier.h @@ -89,8 +89,7 @@ class Verifier { /// \param inspect function to call on any inspection request /// \return true if all goals could be satisfied. bool VerifyAllGoals( - std::function - inspect); + std::function inspect); /// \brief Attempts to satisfy all goals from all loaded rule files and facts. /// \return true if all goals could be satisfied. diff --git a/kythe/cxx/verifier/verifier_unit_test.cc b/kythe/cxx/verifier/verifier_unit_test.cc index 55fede08f7..9fae91314f 100644 --- a/kythe/cxx/verifier/verifier_unit_test.cc +++ b/kythe/cxx/verifier/verifier_unit_test.cc @@ -1207,8 +1207,7 @@ fact_value: "" bool evar_unset = false; ASSERT_TRUE(v.PrepareDatabase()); ASSERT_TRUE(v.VerifyAllGoals( - [&call_count, &evar_unset]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { + [&call_count, &evar_unset](Verifier* cxt, const Inspection& inspection) { ++call_count; if (inspection.label == "Root" && !inspection.evar->current()) { evar_unset = true; @@ -1234,8 +1233,7 @@ fact_value: "" bool evar_unset = false; ASSERT_TRUE(v.PrepareDatabase()); ASSERT_TRUE(v.VerifyAllGoals( - [&call_count, &evar_unset]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { + [&call_count, &evar_unset](Verifier* cxt, const Inspection& inspection) { ++call_count; if (inspection.label == "Root" && !inspection.evar->current()) { evar_unset = true; @@ -1268,8 +1266,7 @@ fact_value: "" bool evar_set = false; ASSERT_TRUE(v.PrepareDatabase()); ASSERT_FALSE(v.VerifyAllGoals( - [&call_count, &evar_set](Verifier* cxt, - const AssertionParser::Inspection& inspection) { + [&call_count, &evar_set](Verifier* cxt, const Inspection& inspection) { ++call_count; if (inspection.label == "Root" && inspection.evar->current()) { if (Identifier* identifier = @@ -1307,8 +1304,7 @@ fact_value: "" bool evar_set = false; ASSERT_TRUE(v.PrepareDatabase()); ASSERT_FALSE(v.VerifyAllGoals( - [&call_count, &evar_set](Verifier* cxt, - const AssertionParser::Inspection& inspection) { + [&call_count, &evar_set](Verifier* cxt, const Inspection& inspection) { ++call_count; if (inspection.label == "Root" && inspection.evar->current()) { if (Identifier* identifier = @@ -1338,8 +1334,7 @@ fact_value: "" bool evar_set = false; ASSERT_TRUE(v.PrepareDatabase()); ASSERT_FALSE(v.VerifyAllGoals( - [&call_count, &evar_set](Verifier* cxt, - const AssertionParser::Inspection& inspection) { + [&call_count, &evar_set](Verifier* cxt, const Inspection& inspection) { ++call_count; if (inspection.label == "Root" && inspection.evar->current()) { if (Identifier* identifier = @@ -1842,8 +1837,8 @@ fact_name: "/" fact_value: "" })")); ASSERT_TRUE(v.PrepareDatabase()); - ASSERT_FALSE(v.VerifyAllGoals( - [](Verifier* cxt, const AssertionParser::Inspection&) { return false; })); + ASSERT_FALSE( + v.VerifyAllGoals([](Verifier* cxt, const Inspection&) { return false; })); } TEST(VerifierUnitTest, EvarsAreSharedAcrossInputFiles) { @@ -1863,8 +1858,7 @@ fact_value: "" EVar* seen_evar = nullptr; int seen_count = 0; ASSERT_TRUE(v.VerifyAllGoals( - [&seen_evar, &seen_count](Verifier* cxt, - const AssertionParser::Inspection& inspection) { + [&seen_evar, &seen_count](Verifier* cxt, const Inspection& inspection) { if (inspection.label == "SomeAnchor") { ++seen_count; if (seen_evar == nullptr) { @@ -1890,8 +1884,8 @@ fact_name: "/" fact_value: "" })")); ASSERT_TRUE(v.PrepareDatabase()); - ASSERT_TRUE(v.VerifyAllGoals( - [](Verifier* cxt, const AssertionParser::Inspection&) { return true; })); + ASSERT_TRUE( + v.VerifyAllGoals([](Verifier* cxt, const Inspection&) { return true; })); } TEST(VerifierUnitTest, InspectionHappensMoreThanOnceAndThatsOk) { @@ -1907,8 +1901,8 @@ fact_value: "" })")); ASSERT_TRUE(v.PrepareDatabase()); size_t inspect_count = 0; - ASSERT_TRUE(v.VerifyAllGoals( - [&inspect_count](Verifier* cxt, const AssertionParser::Inspection&) { + ASSERT_TRUE( + v.VerifyAllGoals([&inspect_count](Verifier* cxt, const Inspection&) { ++inspect_count; return true; })); @@ -1932,7 +1926,7 @@ fact_value: "" bool evar_init_to_correct_vname = false; ASSERT_TRUE(v.VerifyAllGoals( [&call_count, &key_was_someanchor, &evar_init_to_correct_vname]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { + Verifier* cxt, const Inspection& inspection) { ++call_count; // Check for equivalence to `App(#vname, (#"", #"", 1, #"", #""))` key_was_someanchor = (inspection.label == "SomeAnchor"); @@ -1978,7 +1972,7 @@ fact_value: "" AstNode* another_node = nullptr; ASSERT_TRUE(v.VerifyAllGoals( [&some_anchor, &some_node, &another_anchor, &another_node]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { + Verifier* cxt, const Inspection& inspection) { if (AstNode* node = inspection.evar->current()) { if (inspection.label == "SomeAnchor") { some_anchor = node; @@ -2016,10 +2010,10 @@ fact_value: "42" bool key_was_ordinal = false; bool evar_init = false; bool evar_init_to_correct_ordinal = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&call_count, &key_was_ordinal, &evar_init, - &evar_init_to_correct_ordinal]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { + ASSERT_TRUE( + v.VerifyAllGoals([&call_count, &key_was_ordinal, &evar_init, + &evar_init_to_correct_ordinal]( + Verifier* cxt, const Inspection& inspection) { ++call_count; key_was_ordinal = (inspection.label == "Ordinal"); if (AstNode* node = inspection.evar->current()) { @@ -2050,10 +2044,10 @@ fact_name: "/" bool key_was_ordinal = false; bool evar_init = false; bool evar_init_to_correct_ordinal = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&call_count, &key_was_ordinal, &evar_init, - &evar_init_to_correct_ordinal]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { + ASSERT_TRUE( + v.VerifyAllGoals([&call_count, &key_was_ordinal, &evar_init, + &evar_init_to_correct_ordinal]( + Verifier* cxt, const Inspection& inspection) { ++call_count; key_was_ordinal = (inspection.label == "Ordinal"); if (AstNode* node = inspection.evar->current()) { @@ -2091,24 +2085,23 @@ fact_value: "" bool root = false; bool path = false; bool language = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&signature, &root, &path, &language]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - std::string ident_content = - cxt->symbol_table()->text(ident->symbol()); - if (ident_content == inspection.label) { - if (inspection.label == "Signature") signature = true; - if (inspection.label == "Root") root = true; - if (inspection.label == "Path") path = true; - if (inspection.label == "Language") language = true; - } - } - return true; + ASSERT_TRUE(v.VerifyAllGoals([&signature, &root, &path, &language]( + Verifier* cxt, + const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + std::string ident_content = cxt->symbol_table()->text(ident->symbol()); + if (ident_content == inspection.label) { + if (inspection.label == "Signature") signature = true; + if (inspection.label == "Root") root = true; + if (inspection.label == "Path") path = true; + if (inspection.label == "Language") language = true; } - return false; - })); + } + return true; + } + return false; + })); EXPECT_TRUE(signature); EXPECT_TRUE(root); EXPECT_TRUE(path); @@ -2135,23 +2128,22 @@ fact_value: "" bool signature = false; bool path = false; bool language = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&signature, &path, &language]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - std::string ident_content = - cxt->symbol_table()->text(ident->symbol()); - if (ident_content == inspection.label) { - if (inspection.label == "Signature") signature = true; - if (inspection.label == "Path") path = true; - if (inspection.label == "Language") language = true; - } - } - return true; + ASSERT_TRUE(v.VerifyAllGoals([&signature, &path, &language]( + Verifier* cxt, + const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + std::string ident_content = cxt->symbol_table()->text(ident->symbol()); + if (ident_content == inspection.label) { + if (inspection.label == "Signature") signature = true; + if (inspection.label == "Path") path = true; + if (inspection.label == "Language") language = true; } - return false; - })); + } + return true; + } + return false; + })); EXPECT_TRUE(signature); EXPECT_TRUE(path); EXPECT_TRUE(language); @@ -2174,15 +2166,14 @@ edge_kind: "/kythe/edge/is" target { root:"3" } })")); ASSERT_TRUE(v.PrepareDatabase()); - ASSERT_TRUE(v.VerifyAllGoals( - [](Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - return cxt->symbol_table()->text(ident->symbol()) == "2"; - } - } - return false; - })); + ASSERT_TRUE(v.VerifyAllGoals([](Verifier* cxt, const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + return cxt->symbol_table()->text(ident->symbol()) == "2"; + } + } + return false; + })); } TEST(VerifierUnitTest, EqualityConstraintWorksOnAnchors) { @@ -2212,11 +2203,9 @@ fact_name: "/" fact_value: "" })")); ASSERT_TRUE(v.PrepareDatabase()); - ASSERT_TRUE(v.VerifyAllGoals( - [](Verifier* cxt, const AssertionParser::Inspection& inspection) { - return (inspection.label == "Tx" && - inspection.evar->current() != nullptr); - })); + ASSERT_TRUE(v.VerifyAllGoals([](Verifier* cxt, const Inspection& inspection) { + return (inspection.label == "Tx" && inspection.evar->current() != nullptr); + })); } // It's possible to match Tx against {root:7}: @@ -2311,15 +2300,14 @@ edge_kind: "/kythe/edge/is" target { root:"3" } })")); ASSERT_TRUE(v.PrepareDatabase()); - ASSERT_TRUE(v.VerifyAllGoals( - [](Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - return cxt->symbol_table()->text(ident->symbol()) == "3"; - } - } - return false; - })); + ASSERT_TRUE(v.VerifyAllGoals([](Verifier* cxt, const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + return cxt->symbol_table()->text(ident->symbol()) == "3"; + } + } + return false; + })); } TEST(VerifierUnitTest, EqualityConstraintFails) { @@ -2426,25 +2414,24 @@ fact_value: "" bool root = false; bool path = false; bool language = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&signature, &corpus, &root, &path, &language]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - std::string ident_content = - cxt->symbol_table()->text(ident->symbol()); - if (ident_content == inspection.label) { - if (inspection.label == "Signature") signature = true; - if (inspection.label == "Corpus") corpus = true; - if (inspection.label == "Root") root = true; - if (inspection.label == "Path") path = true; - if (inspection.label == "Language") language = true; - } - } - return true; + ASSERT_TRUE(v.VerifyAllGoals([&signature, &corpus, &root, &path, &language]( + Verifier* cxt, + const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + std::string ident_content = cxt->symbol_table()->text(ident->symbol()); + if (ident_content == inspection.label) { + if (inspection.label == "Signature") signature = true; + if (inspection.label == "Corpus") corpus = true; + if (inspection.label == "Root") root = true; + if (inspection.label == "Path") path = true; + if (inspection.label == "Language") language = true; } - return false; - })); + } + return true; + } + return false; + })); EXPECT_TRUE(signature); EXPECT_TRUE(corpus); EXPECT_TRUE(root); @@ -2474,27 +2461,25 @@ fact_value: "" bool root = false; bool path = false; bool language = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&signature, &corpus, &root, &path, &language]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - std::string ident_content = - cxt->symbol_table()->text(ident->symbol()); - if ((inspection.label != "Path" && - ident_content == inspection.label) || - (inspection.label == "_" && ident_content == "Path")) { - if (inspection.label == "Signature") signature = true; - if (inspection.label == "Corpus") corpus = true; - if (inspection.label == "Root") root = true; - if (inspection.label == "_") path = true; - if (inspection.label == "Language") language = true; - } - } - return true; + ASSERT_TRUE(v.VerifyAllGoals([&signature, &corpus, &root, &path, &language]( + Verifier* cxt, + const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + std::string ident_content = cxt->symbol_table()->text(ident->symbol()); + if ((inspection.label != "Path" && ident_content == inspection.label) || + (inspection.label == "_" && ident_content == "Path")) { + if (inspection.label == "Signature") signature = true; + if (inspection.label == "Corpus") corpus = true; + if (inspection.label == "Root") root = true; + if (inspection.label == "_") path = true; + if (inspection.label == "Language") language = true; } - return false; - })); + } + return true; + } + return false; + })); EXPECT_TRUE(signature); EXPECT_TRUE(corpus); EXPECT_TRUE(root); @@ -2523,24 +2508,23 @@ fact_value: "" bool root = false; bool path = false; bool language = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&signature, &corpus, &root, &language]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - std::string ident_content = - cxt->symbol_table()->text(ident->symbol()); - if (ident_content == inspection.label) { - if (inspection.label == "Signature") signature = true; - if (inspection.label == "Corpus") corpus = true; - if (inspection.label == "Root") root = true; - if (inspection.label == "Language") language = true; - } - } - return true; + ASSERT_TRUE(v.VerifyAllGoals([&signature, &corpus, &root, &language]( + Verifier* cxt, + const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + std::string ident_content = cxt->symbol_table()->text(ident->symbol()); + if (ident_content == inspection.label) { + if (inspection.label == "Signature") signature = true; + if (inspection.label == "Corpus") corpus = true; + if (inspection.label == "Root") root = true; + if (inspection.label == "Language") language = true; } - return false; - })); + } + return true; + } + return false; + })); EXPECT_TRUE(signature); EXPECT_TRUE(corpus); EXPECT_TRUE(root); @@ -2568,28 +2552,25 @@ fact_value: "" bool root = false; bool path = false; bool language = false; - ASSERT_TRUE(v.VerifyAllGoals( - [&signature, &corpus, &root, &path, &language]( - Verifier* cxt, const AssertionParser::Inspection& inspection) { - if (AstNode* node = inspection.evar->current()) { - if (Identifier* ident = node->AsIdentifier()) { - std::string ident_content = - cxt->symbol_table()->text(ident->symbol()); - if ((inspection.label != "Path" && - ident_content == inspection.label) || - (inspection.label == "Path" && - ident == cxt->empty_string_id())) { - if (inspection.label == "Signature") signature = true; - if (inspection.label == "Corpus") corpus = true; - if (inspection.label == "Root") root = true; - if (inspection.label == "Path") path = true; - if (inspection.label == "Language") language = true; - } - } - return true; + ASSERT_TRUE(v.VerifyAllGoals([&signature, &corpus, &root, &path, &language]( + Verifier* cxt, + const Inspection& inspection) { + if (AstNode* node = inspection.evar->current()) { + if (Identifier* ident = node->AsIdentifier()) { + std::string ident_content = cxt->symbol_table()->text(ident->symbol()); + if ((inspection.label != "Path" && ident_content == inspection.label) || + (inspection.label == "Path" && ident == cxt->empty_string_id())) { + if (inspection.label == "Signature") signature = true; + if (inspection.label == "Corpus") corpus = true; + if (inspection.label == "Root") root = true; + if (inspection.label == "Path") path = true; + if (inspection.label == "Language") language = true; } - return false; - })); + } + return true; + } + return false; + })); EXPECT_TRUE(signature); EXPECT_TRUE(corpus); EXPECT_TRUE(root);