Allows additional EVMVersion comparators in isoltest.

This commit is contained in:
Erik Kundt 2019-04-24 12:08:49 +02:00 committed by chriseth
parent eac0048176
commit 15d753a3e0
4 changed files with 29 additions and 13 deletions

View File

@ -116,19 +116,35 @@ bool EVMVersionRestrictedTestCase::validateSettings(langutil::EVMVersion _evmVer
if (versionString.empty())
return true;
char comparator = versionString.front();
versionString = versionString.substr(1);
string comparator;
size_t versionBegin = 0;
for (auto character: versionString)
if (!isalpha(character))
{
comparator += character;
versionBegin++;
}
else
break;
versionString = versionString.substr(versionBegin);
boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
if (!version)
throw runtime_error("Invalid EVM version: \"" + versionString + "\"");
switch (comparator)
{
case '>': return version < _evmVersion;
case '<': return _evmVersion < version;
case '=': return _evmVersion == version;
case '!': return !(_evmVersion == version);
}
throw runtime_error(string{"Invalid EVM comparator: \""} + comparator + "\"");
if (comparator == ">")
return _evmVersion > version;
else if (comparator == ">=")
return _evmVersion >= version;
else if (comparator == "<")
return _evmVersion < version;
else if (comparator == "<=")
return _evmVersion <= version;
else if (comparator == "=")
return _evmVersion == version;
else if (comparator == "!")
return !(_evmVersion == version);
else
throw runtime_error("Invalid EVM comparator: \"" + comparator + "\"");
return false; // not reached
}

View File

@ -4,6 +4,6 @@ contract C {
}
}
// ====
// EVMVersion: >byzantium
// EVMVersion: >=constantinople
// ----
// f(uint256): 7 -> 28

View File

@ -5,7 +5,7 @@
let d := and(shr(247, calldataload(0)), 0xff)
}
// ====
// EVMVersion: >byzantium
// EVMVersion: >=constantinople
// step: expressionSimplifier
// ----
// {

View File

@ -5,7 +5,7 @@
let d := shr(255, calldataload(3))
}
// ====
// EVMVersion: >byzantium
// EVMVersion: >=constantinople
// step: expressionSimplifier
// ----
// {