From 15d753a3e0b7e021ba6aff3497e54d18120de7fd Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 24 Apr 2019 12:08:49 +0200 Subject: [PATCH] Allows additional EVMVersion comparators in isoltest. --- test/TestCase.cpp | 36 +++++++++++++------ test/libsolidity/semanticTests/shifts.sol | 2 +- .../remove_redundant_shift_masking.yul | 2 +- .../replace_too_large_shift.yul | 2 +- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/test/TestCase.cpp b/test/TestCase.cpp index 90140532e..b4260e436 100644 --- a/test/TestCase.cpp +++ b/test/TestCase.cpp @@ -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 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 } diff --git a/test/libsolidity/semanticTests/shifts.sol b/test/libsolidity/semanticTests/shifts.sol index fb58ecb5c..e202f2889 100644 --- a/test/libsolidity/semanticTests/shifts.sol +++ b/test/libsolidity/semanticTests/shifts.sol @@ -4,6 +4,6 @@ contract C { } } // ==== -// EVMVersion: >byzantium +// EVMVersion: >=constantinople // ---- // f(uint256): 7 -> 28 diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul index 89bc0ca67..cb5303eaf 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/remove_redundant_shift_masking.yul @@ -5,7 +5,7 @@ let d := and(shr(247, calldataload(0)), 0xff) } // ==== -// EVMVersion: >byzantium +// EVMVersion: >=constantinople // step: expressionSimplifier // ---- // { diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul index 769c5489f..8d69bcc8d 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/replace_too_large_shift.yul @@ -5,7 +5,7 @@ let d := shr(255, calldataload(3)) } // ==== -// EVMVersion: >byzantium +// EVMVersion: >=constantinople // step: expressionSimplifier // ---- // {