From d33f8f951d758537514bd3f76d1d7a31f3a5159f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 11 Aug 2023 18:14:08 +0200 Subject: [PATCH] fixup! Implementation of Lengauer-Tarjan algorithm to find dominators --- test/libyul/DominatorTest.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/libyul/DominatorTest.cpp b/test/libyul/DominatorTest.cpp index 371fc025f..0bc0c7fd2 100644 --- a/test/libyul/DominatorTest.cpp +++ b/test/libyul/DominatorTest.cpp @@ -20,6 +20,9 @@ #include +#include +#include + using namespace solidity::yul; namespace solidity::yul::test @@ -83,6 +86,15 @@ protected: graph->expectedDFSIndices = _expectedDFSIndices; return graph; } + + std::map toDFSIndices(std::map const& _vertexIndices) + { + auto convertIndex = [](std::pair const& _pair) -> std::pair + { + return {_pair.first.name, _pair.second}; + }; + return _vertexIndices | ranges::views::transform(convertIndex) | ranges::to; + } }; BOOST_AUTO_TEST_SUITE(Dominators) @@ -456,8 +468,7 @@ BOOST_FIXTURE_TEST_CASE(immediate_dominator, DominatorFixture) ImmediateDominatorTest::ForEachVertexSuccessorTest > dominatorFinder(*test->entry, test->numVertices); - for (auto const&[v, idx]: dominatorFinder.vertexIndices()) - BOOST_CHECK(test->expectedDFSIndices.at(v.name) == idx); + BOOST_TEST(toDFSIndices(dominatorFinder.vertexIndices()) == test->expectedDFSIndices); BOOST_TEST(dominatorFinder.immediateDominators() == test->expectedIdom); } }