mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Add --show-initial-population option
This commit is contained in:
@@ -70,6 +70,7 @@ class AlgorithmRunnerFixture
|
||||
protected:
|
||||
// NOTE: Regexes here should not contain spaces because we strip them before matching
|
||||
regex RoundSummaryRegex{R"(-+ROUND\d+-+)"};
|
||||
regex InitialPopulationHeaderRegex{"-+INITIALPOPULATION-+"};
|
||||
|
||||
string individualPattern(Individual const& individual) const
|
||||
{
|
||||
@@ -133,6 +134,7 @@ BOOST_FIXTURE_TEST_CASE(run_should_call_runNextRound_once_per_round, AlgorithmRu
|
||||
BOOST_FIXTURE_TEST_CASE(run_should_print_round_summary_after_each_round, AlgorithmRunnerFixture)
|
||||
{
|
||||
m_options.maxRounds = 1;
|
||||
m_options.showInitialPopulation = false;
|
||||
AlgorithmRunner runner(m_population, {}, m_options, m_output);
|
||||
RandomisingAlgorithm algorithm;
|
||||
|
||||
@@ -148,6 +150,33 @@ BOOST_FIXTURE_TEST_CASE(run_should_print_round_summary_after_each_round, Algorit
|
||||
BOOST_TEST(m_output.peek() == EOF);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(run_should_print_initial_population_if_requested, AlgorithmRunnerFixture)
|
||||
{
|
||||
m_options.maxRounds = 0;
|
||||
m_options.showInitialPopulation = true;
|
||||
RandomisingAlgorithm algorithm;
|
||||
|
||||
AlgorithmRunner runner(m_population, {}, m_options, m_output);
|
||||
runner.run(algorithm);
|
||||
|
||||
BOOST_TEST(nextLineMatches(m_output, InitialPopulationHeaderRegex));
|
||||
for (auto const& individual: m_population.individuals())
|
||||
BOOST_TEST(nextLineMatches(m_output, regex(individualPattern(individual))));
|
||||
BOOST_TEST(m_output.peek() == EOF);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(run_should_not_print_initial_population_if_not_requested, AlgorithmRunnerFixture)
|
||||
{
|
||||
m_options.maxRounds = 0;
|
||||
m_options.showInitialPopulation = false;
|
||||
RandomisingAlgorithm algorithm;
|
||||
|
||||
AlgorithmRunner runner(m_population, {}, m_options, m_output);
|
||||
runner.run(algorithm);
|
||||
|
||||
BOOST_TEST(m_output.peek() == EOF);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(run_should_save_initial_population_to_file_if_autosave_file_specified, AlgorithmRunnerAutosaveFixture)
|
||||
{
|
||||
m_options.maxRounds = 0;
|
||||
|
||||
Reference in New Issue
Block a user