aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/AnalysisFramework.cpp
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-04-03 18:05:26 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-04-04 01:54:45 +0800
commit6f9644add18b27363a423e2c7ccb0e578ba800bc (patch)
treec6158178cf44a68563acd92ef5f3ccad98ce56c6 /test/libsolidity/AnalysisFramework.cpp
parent104a9736b35495cf50bf1a895d61aed9a1ba830a (diff)
downloaddexon-solidity-6f9644add18b27363a423e2c7ccb0e578ba800bc.tar.gz
dexon-solidity-6f9644add18b27363a423e2c7ccb0e578ba800bc.tar.zst
dexon-solidity-6f9644add18b27363a423e2c7ccb0e578ba800bc.zip
SyntaxTests: extend syntax tests and isoltest to support parser errors and compiler exceptions.
Diffstat (limited to 'test/libsolidity/AnalysisFramework.cpp')
-rw-r--r--test/libsolidity/AnalysisFramework.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp
index 4538757d..72b86767 100644
--- a/test/libsolidity/AnalysisFramework.cpp
+++ b/test/libsolidity/AnalysisFramework.cpp
@@ -56,12 +56,23 @@ AnalysisFramework::parseAnalyseAndReturnError(
m_compiler.analyze();
+ ErrorList errors = filterErrors(m_compiler.errors(), _reportWarnings);
+ if (errors.size() > 1 && !_allowMultipleErrors)
+ BOOST_FAIL("Multiple errors found: " + formatErrors());
+
+ return make_pair(&m_compiler.ast(""), std::move(errors));
+}
+
+ErrorList AnalysisFramework::filterErrors(ErrorList const& _errorList, bool _includeWarnings) const
+{
ErrorList errors;
- for (auto const& currentError: m_compiler.errors())
+ for (auto const& currentError: _errorList)
{
solAssert(currentError->comment(), "");
if (currentError->type() == Error::Type::Warning)
{
+ if (!_includeWarnings)
+ continue;
bool ignoreWarning = false;
for (auto const& filter: m_warningsToFilter)
if (currentError->comment()->find(filter) == 0)
@@ -73,17 +84,10 @@ AnalysisFramework::parseAnalyseAndReturnError(
continue;
}
- if (_reportWarnings || (currentError->type() != Error::Type::Warning))
- {
- if (!_allowMultipleErrors && !errors.empty())
- {
- BOOST_FAIL("Multiple errors found: " + formatErrors());
- }
- errors.emplace_back(std::move(currentError));
- }
+ errors.emplace_back(currentError);
}
- return make_pair(&m_compiler.ast(""), errors);
+ return errors;
}
SourceUnit const* AnalysisFramework::parseAndAnalyse(string const& _source)
@@ -110,7 +114,7 @@ ErrorList AnalysisFramework::expectError(std::string const& _source, bool _warni
return sourceAndErrors.second;
}
-string AnalysisFramework::formatErrors()
+string AnalysisFramework::formatErrors() const
{
string message;
for (auto const& error: m_compiler.errors())
@@ -118,7 +122,7 @@ string AnalysisFramework::formatErrors()
return message;
}
-string AnalysisFramework::formatError(Error const& _error)
+string AnalysisFramework::formatError(Error const& _error) const
{
return SourceReferenceFormatter::formatExceptionInformation(
_error,