aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/AnalysisFramework.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-14 12:00:41 +0800
committerGitHub <noreply@github.com>2018-02-14 12:00:41 +0800
commit3155dd8058672ce8f04bc2c0f2536cb549067d0a (patch)
tree7ddb56e276c74db30671eb17ffdde5eda027142d /test/libsolidity/AnalysisFramework.cpp
parentc4cbbb054b5ed3b8ceaa21ee5b47b0704762ff40 (diff)
parentef8292c6bb337d3c4b27836da6732b85021d1c5d (diff)
downloaddexon-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/AnalysisFramework.cpp')
-rw-r--r--test/libsolidity/AnalysisFramework.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp
index ea9703ea..a27e3222 100644
--- a/test/libsolidity/AnalysisFramework.cpp
+++ b/test/libsolidity/AnalysisFramework.cpp
@@ -36,7 +36,7 @@ using namespace dev;
using namespace dev::solidity;
using namespace dev::solidity::test;
-pair<SourceUnit const*, shared_ptr<Error const>>
+pair<SourceUnit const*, ErrorList>
AnalysisFramework::parseAnalyseAndReturnError(
string const& _source,
bool _reportWarnings,
@@ -53,7 +53,7 @@ AnalysisFramework::parseAnalyseAndReturnError(
m_compiler.analyze();
- std::shared_ptr<Error const> firstError;
+ ErrorList errors;
for (auto const& currentError: m_compiler.errors())
{
solAssert(currentError->comment(), "");
@@ -72,16 +72,15 @@ AnalysisFramework::parseAnalyseAndReturnError(
if (_reportWarnings || (currentError->type() != Error::Type::Warning))
{
- if (firstError && !_allowMultipleErrors)
+ if (!_allowMultipleErrors && !errors.empty())
{
BOOST_FAIL("Multiple errors found: " + formatErrors());
}
- if (!firstError)
- firstError = currentError;
+ errors.emplace_back(std::move(currentError));
}
}
- return make_pair(&m_compiler.ast(""), firstError);
+ return make_pair(&m_compiler.ast(""), errors);
}
SourceUnit const* AnalysisFramework::parseAndAnalyse(string const& _source)
@@ -89,23 +88,23 @@ SourceUnit const* AnalysisFramework::parseAndAnalyse(string const& _source)
auto sourceAndError = parseAnalyseAndReturnError(_source);
BOOST_REQUIRE(!!sourceAndError.first);
string message;
- if (sourceAndError.second)
- message = "Unexpected error: " + formatError(*sourceAndError.second);
- BOOST_REQUIRE_MESSAGE(!sourceAndError.second, message);
+ if (!sourceAndError.second.empty())
+ message = "Unexpected error: " + formatErrors();
+ BOOST_REQUIRE_MESSAGE(sourceAndError.second.empty(), message);
return sourceAndError.first;
}
bool AnalysisFramework::success(string const& _source)
{
- return !parseAnalyseAndReturnError(_source).second;
+ return parseAnalyseAndReturnError(_source).second.empty();
}
-Error AnalysisFramework::expectError(std::string const& _source, bool _warning, bool _allowMultiple)
+ErrorList AnalysisFramework::expectError(std::string const& _source, bool _warning, bool _allowMultiple)
{
- auto sourceAndError = parseAnalyseAndReturnError(_source, _warning, true, _allowMultiple);
- BOOST_REQUIRE(!!sourceAndError.second);
- BOOST_REQUIRE_MESSAGE(!!sourceAndError.first, "Expected error, but no error happened.");
- return *sourceAndError.second;
+ auto sourceAndErrors = parseAnalyseAndReturnError(_source, _warning, true, _allowMultiple);
+ BOOST_REQUIRE(!sourceAndErrors.second.empty());
+ BOOST_REQUIRE_MESSAGE(!!sourceAndErrors.first, "Expected error, but no error happened.");
+ return sourceAndErrors.second;
}
string AnalysisFramework::formatErrors()