From a1eb0f7225ee4e0850dd09d087ae534a5875a38f Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Thu, 3 Sep 2020 11:39:56 +0200 Subject: [PATCH] Use same multi-source-syntax for test files --- test/libsolidity/ASTJSON/documentation.sol | 6 +++--- test/libsolidity/ASTJSONTest.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/libsolidity/ASTJSON/documentation.sol b/test/libsolidity/ASTJSON/documentation.sol index 089f81e0b..4d354dd26 100644 --- a/test/libsolidity/ASTJSON/documentation.sol +++ b/test/libsolidity/ASTJSON/documentation.sol @@ -1,14 +1,14 @@ -// ---- SOURCE: a +==== Source: a ==== /**This contract is empty*/ contract C {} -// ---- SOURCE: b +==== Source: b ==== /**This contract is empty and has a line-breaking comment.*/ contract C {} -// ---- SOURCE: c +==== Source: c ==== contract C { /** Some comment on state var.*/ uint public state; diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index 76c8e50c7..4e7692562 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -44,6 +44,8 @@ using namespace boost::unit_test; namespace { +string const sourceDelimiter("==== Source: "); + void replaceVersionWithTag(string& _input) { boost::algorithm::replace_all( @@ -81,7 +83,6 @@ ASTJSONTest::ASTJSONTest(string const& _filename) string sourceName; string source; string line; - string const sourceDelimiter("// ---- SOURCE: "); string const delimiter("// ----"); while (getline(file, line)) { @@ -90,7 +91,10 @@ ASTJSONTest::ASTJSONTest(string const& _filename) if (!sourceName.empty()) m_sources.emplace_back(sourceName, source); - sourceName = line.substr(sourceDelimiter.size(), string::npos); + sourceName = line.substr( + sourceDelimiter.size(), + line.size() - " ===="s.size() - sourceDelimiter.size() + ); source = string(); } else if (!line.empty() && !boost::algorithm::starts_with(line, delimiter)) @@ -238,7 +242,7 @@ void ASTJSONTest::printSource(ostream& _stream, string const& _linePrefix, bool for (auto const& source: m_sources) { if (m_sources.size() > 1 || source.first != "a") - _stream << _linePrefix << "// ---- SOURCE: " << source.first << endl << endl; + _stream << _linePrefix << sourceDelimiter << source.first << endl << endl; stringstream stream(source.second); string line; while (getline(stream, line))