mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Common: Add wholeChromosomeReplacement() mutation and countDifferences()
This commit is contained in:
@@ -24,6 +24,12 @@
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
using namespace solidity::yul;
|
||||
using namespace solidity::phaser;
|
||||
|
||||
function<Mutation> phaser::test::wholeChromosomeReplacement(Chromosome _newChromosome)
|
||||
{
|
||||
return [_newChromosome = move(_newChromosome)](Chromosome const&) { return _newChromosome; };
|
||||
}
|
||||
|
||||
vector<size_t> phaser::test::chromosomeLengths(Population const& _population)
|
||||
{
|
||||
@@ -44,6 +50,15 @@ map<string, size_t> phaser::test::enumerateOptmisationSteps()
|
||||
return stepIndices;
|
||||
}
|
||||
|
||||
size_t phaser::test::countDifferences(Chromosome const& _chromosome1, Chromosome const& _chromosome2)
|
||||
{
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < min(_chromosome1.length(), _chromosome2.length()); ++i)
|
||||
count += static_cast<int>(_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i]);
|
||||
|
||||
return count + abs(static_cast<int>(_chromosome1.length() - _chromosome2.length()));
|
||||
}
|
||||
|
||||
string phaser::test::stripWhitespace(string const& input)
|
||||
{
|
||||
regex whitespaceRegex("\\s+");
|
||||
|
||||
Reference in New Issue
Block a user