diff options
author | chriseth <chris@ethereum.org> | 2018-12-06 21:01:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-06 21:01:39 +0800 |
commit | 0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d (patch) | |
tree | a247b6ea5b9b305e60d9e4d403e805335415ba6f /test | |
parent | 1643d63e3af1b0e3aabac2f2ded3619505d0fa8c (diff) | |
parent | 073b03d90c8f0648ba135f0b30d8e72fd871478f (diff) | |
download | dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.tar dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.tar.gz dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.tar.bz2 dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.tar.lz dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.tar.xz dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.tar.zst dexon-solidity-0e8841005ca7bf93545a1bc76bd8fa0ed67cb32d.zip |
Merge pull request #5554 from ethereum/cp-SourceReferenceFormatter-refactor
[2/3] Refactor SourceReferenceFormatter (split-out data extraction & make use of new SourceLocation knowledge)
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/AnalysisFramework.cpp | 3 | ||||
-rw-r--r-- | test/libsolidity/GasMeter.cpp | 3 | ||||
-rw-r--r-- | test/libsolidity/SolidityExecutionFramework.h | 3 | ||||
-rw-r--r-- | test/libyul/Common.cpp | 6 | ||||
-rw-r--r-- | test/libyul/Common.h | 3 | ||||
-rw-r--r-- | test/libyul/YulOptimizerTest.cpp | 8 | ||||
-rw-r--r-- | test/libyul/YulOptimizerTest.h | 2 | ||||
-rw-r--r-- | test/tools/yulopti.cpp | 8 |
8 files changed, 16 insertions, 20 deletions
diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index bd24115c..8a72f996 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -127,8 +127,7 @@ string AnalysisFramework::formatError(Error const& _error) const { return SourceReferenceFormatter::formatExceptionInformation( _error, - (_error.type() == Error::Type::Warning) ? "Warning" : "Error", - [&](std::string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); } + (_error.type() == Error::Type::Warning) ? "Warning" : "Error" ); } diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 601948bc..5535bd74 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -138,8 +138,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs) if (first->first->location().intersects(second->first->location())) { BOOST_CHECK_MESSAGE(false, "Source locations should not overlap!"); - auto scannerFromSource = [&](string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); }; - SourceReferenceFormatter formatter(cout, scannerFromSource); + SourceReferenceFormatter formatter(cout); formatter.printSourceLocation(&first->first->location()); formatter.printSourceLocation(&second->first->location()); diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h index cedbf51a..73377eb9 100644 --- a/test/libsolidity/SolidityExecutionFramework.h +++ b/test/libsolidity/SolidityExecutionFramework.h @@ -72,8 +72,7 @@ public: m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns); if (!m_compiler.compile()) { - auto scannerFromSourceName = [&](std::string const& _sourceName) -> langutil::Scanner const& { return m_compiler.scanner(_sourceName); }; - langutil::SourceReferenceFormatter formatter(std::cerr, scannerFromSourceName); + langutil::SourceReferenceFormatter formatter(std::cerr); for (auto const& error: m_compiler.errors()) formatter.printExceptionInformation( diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index e2462eb7..0f2529de 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -40,9 +40,9 @@ using namespace langutil; using namespace yul; using namespace dev::solidity; -void yul::test::printErrors(ErrorList const& _errors, Scanner const& _scanner) +void yul::test::printErrors(ErrorList const& _errors) { - SourceReferenceFormatter formatter(cout, [&](std::string const&) -> Scanner const& { return _scanner; }); + SourceReferenceFormatter formatter(cout); for (auto const& error: _errors) formatter.printExceptionInformation( @@ -76,7 +76,7 @@ pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(strin return make_pair(parserResult, analysisInfo); } } - printErrors(errors, *scanner); + printErrors(errors); BOOST_FAIL("Invalid source."); // Unreachable. diff --git a/test/libyul/Common.h b/test/libyul/Common.h index a1c64ca5..01fc416a 100644 --- a/test/libyul/Common.h +++ b/test/libyul/Common.h @@ -29,7 +29,6 @@ namespace langutil { -class Scanner; class Error; using ErrorList = std::vector<std::shared_ptr<Error const>>; } @@ -44,7 +43,7 @@ namespace yul namespace test { -void printErrors(langutil::ErrorList const& _errors, langutil::Scanner const& _scanner); +void printErrors(langutil::ErrorList const& _errors); std::pair<std::shared_ptr<Block>, std::shared_ptr<AsmAnalysisInfo>> parse(std::string const& _source, bool _yul = true); Block disambiguate(std::string const& _source, bool _yul = true); diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index d1d22fd0..96b9d263 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -264,7 +264,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c if (!m_ast || !errorReporter.errors().empty()) { FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl; - printErrors(_stream, errorReporter.errors(), *scanner); + printErrors(_stream, errorReporter.errors()); return false; } m_analysisInfo = make_shared<yul::AsmAnalysisInfo>(); @@ -278,7 +278,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c if (!analyzer.analyze(*m_ast) || !errorReporter.errors().empty()) { FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error analyzing source." << endl; - printErrors(_stream, errorReporter.errors(), *scanner); + printErrors(_stream, errorReporter.errors()); return false; } return true; @@ -290,9 +290,9 @@ void YulOptimizerTest::disambiguate() m_analysisInfo.reset(); } -void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors, Scanner const& _scanner) +void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors) { - SourceReferenceFormatter formatter(_stream, [&](string const&) -> Scanner const& { return _scanner; }); + SourceReferenceFormatter formatter(_stream); for (auto const& error: _errors) formatter.printExceptionInformation( diff --git a/test/libyul/YulOptimizerTest.h b/test/libyul/YulOptimizerTest.h index 90026e24..5648e995 100644 --- a/test/libyul/YulOptimizerTest.h +++ b/test/libyul/YulOptimizerTest.h @@ -57,7 +57,7 @@ private: bool parse(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted); void disambiguate(); - static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors, langutil::Scanner const& _scanner); + static void printErrors(std::ostream& _stream, langutil::ErrorList const& _errors); std::string m_source; bool m_yul = false; diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index d0643d73..d6dbc1b1 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -67,9 +67,9 @@ namespace po = boost::program_options; class YulOpti { public: - void printErrors(Scanner const& _scanner) + void printErrors() { - SourceReferenceFormatter formatter(cout, [&](string const&) -> Scanner const& { return _scanner; }); + SourceReferenceFormatter formatter(cout); for (auto const& error: m_errors) formatter.printExceptionInformation( @@ -86,7 +86,7 @@ public: if (!m_ast || !errorReporter.errors().empty()) { cout << "Error parsing source." << endl; - printErrors(*scanner); + printErrors(); return false; } m_analysisInfo = make_shared<yul::AsmAnalysisInfo>(); @@ -100,7 +100,7 @@ public: if (!analyzer.analyze(*m_ast) || !errorReporter.errors().empty()) { cout << "Error analyzing source." << endl; - printErrors(*scanner); + printErrors(); return false; } return true; |