mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allows additional EVMVersion comparators in isoltest.
This commit is contained in:
parent
eac0048176
commit
15d753a3e0
@ -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
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >byzantium
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// f(uint256): 7 -> 28
|
||||
|
@ -5,7 +5,7 @@
|
||||
let d := and(shr(247, calldataload(0)), 0xff)
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >byzantium
|
||||
// EVMVersion: >=constantinople
|
||||
// step: expressionSimplifier
|
||||
// ----
|
||||
// {
|
||||
|
@ -5,7 +5,7 @@
|
||||
let d := shr(255, calldataload(3))
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >byzantium
|
||||
// EVMVersion: >=constantinople
|
||||
// step: expressionSimplifier
|
||||
// ----
|
||||
// {
|
||||
|
Loading…
Reference in New Issue
Block a user