Use same multi-source-syntax for test files

This commit is contained in:
Mathias Baumann 2020-09-03 11:39:56 +02:00
parent 3817515015
commit a1eb0f7225
2 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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))