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()) if (versionString.empty())
return true; return true;
char comparator = versionString.front(); string comparator;
versionString = versionString.substr(1); 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); boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
if (!version) if (!version)
throw runtime_error("Invalid EVM version: \"" + versionString + "\""); throw runtime_error("Invalid EVM version: \"" + versionString + "\"");
switch (comparator) if (comparator == ">")
{ return _evmVersion > version;
case '>': return version < _evmVersion; else if (comparator == ">=")
case '<': return _evmVersion < version; return _evmVersion >= version;
case '=': return _evmVersion == version; else if (comparator == "<")
case '!': return !(_evmVersion == version); return _evmVersion < version;
} else if (comparator == "<=")
throw runtime_error(string{"Invalid EVM comparator: \""} + 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 return false; // not reached
} }

View File

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

View File

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

View File

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