diff options
author | chriseth <chris@ethereum.org> | 2018-02-14 12:00:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 12:00:41 +0800 |
commit | 3155dd8058672ce8f04bc2c0f2536cb549067d0a (patch) | |
tree | 7ddb56e276c74db30671eb17ffdde5eda027142d /test/libsolidity/ErrorCheck.cpp | |
parent | c4cbbb054b5ed3b8ceaa21ee5b47b0704762ff40 (diff) | |
parent | ef8292c6bb337d3c4b27836da6732b85021d1c5d (diff) | |
download | dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.tar dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.tar.gz dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.tar.bz2 dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.tar.lz dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.tar.xz dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.tar.zst dexon-solidity-3155dd8058672ce8f04bc2c0f2536cb549067d0a.zip |
Merge pull request #3503 from ethereum/develop
Merge develop into release for v0.4.20.
Diffstat (limited to 'test/libsolidity/ErrorCheck.cpp')
-rw-r--r-- | test/libsolidity/ErrorCheck.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp index b1e94061..fba2c897 100644 --- a/test/libsolidity/ErrorCheck.cpp +++ b/test/libsolidity/ErrorCheck.cpp @@ -23,8 +23,19 @@ #include <libdevcore/Exceptions.h> #include <string> +#include <set> using namespace std; +using namespace dev; +using namespace dev::solidity; + +namespace +{ +std::string errorMessage(Error const& _e) +{ + return _e.comment() ? *_e.comment() : "NONE"; +} +} bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _substr) { @@ -41,3 +52,31 @@ bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _su cout << "Expected error message but found none." << endl; return _substr.empty(); } + +string dev::solidity::searchErrors(ErrorList const& _errors, vector<pair<Error::Type, string>> const& _expectations) +{ + auto expectations = _expectations; + for (auto const& error: _errors) + { + string msg = errorMessage(*error); + bool found = false; + for (auto it = expectations.begin(); it != expectations.end(); ++it) + if (msg.find(it->second) != string::npos && error->type() == it->first) + { + found = true; + expectations.erase(it); + break; + } + if (!found) + return "Unexpected error: " + error->typeName() + ": " + msg; + } + if (!expectations.empty()) + { + string msg = "Expected error(s) not present:\n"; + for (auto const& expectation: expectations) + msg += expectation.second + "\n"; + return msg; + } + + return ""; +} |