isoltest: Removes additional whitespaces from output.

This commit is contained in:
Erik Kundt 2019-07-13 14:02:20 +02:00
parent 8c51a089d7
commit 41fb6f4ff8
2 changed files with 19 additions and 13 deletions

View File

@ -86,7 +86,7 @@ vector<dev::solidity::test::FunctionCall> TestFileParser::parseFunctionCalls(siz
call.displayMode = FunctionCall::DisplayMode::MultiLine; call.displayMode = FunctionCall::DisplayMode::MultiLine;
m_lineNumber++; m_lineNumber++;
} }
call.arguments.comment = parseComment(); call.arguments.comment = parseComment();
if (accept(Token::Newline, true)) if (accept(Token::Newline, true))
@ -94,13 +94,13 @@ vector<dev::solidity::test::FunctionCall> TestFileParser::parseFunctionCalls(siz
call.displayMode = FunctionCall::DisplayMode::MultiLine; call.displayMode = FunctionCall::DisplayMode::MultiLine;
m_lineNumber++; m_lineNumber++;
} }
if (accept(Token::Arrow, true)) if (accept(Token::Arrow, true))
{ {
call.omitsArrow = false; call.omitsArrow = false;
call.expectations = parseFunctionCallExpectations(); call.expectations = parseFunctionCallExpectations();
if (accept(Token::Newline, true)) if (accept(Token::Newline, true))
m_lineNumber++; m_lineNumber++;
} }
else else
{ {

View File

@ -62,7 +62,7 @@ string TestFunctionCall::format(
{ {
string output = formatRawParameters(m_call.arguments.parameters, _linePrefix); string output = formatRawParameters(m_call.arguments.parameters, _linePrefix);
stream << colon; stream << colon;
if (_singleLine) if (!m_call.arguments.parameters.at(0).format.newline)
stream << ws; stream << ws;
stream << output; stream << output;
@ -78,12 +78,10 @@ string TestFunctionCall::format(
if (m_call.omitsArrow) if (m_call.omitsArrow)
{ {
if (_renderResult && (m_failure || !matchesExpectation())) if (_renderResult && (m_failure || !matchesExpectation()))
stream << ws << arrow << ws; stream << ws << arrow;
} }
else else
{ stream << ws << arrow;
stream << ws << arrow << ws;
}
} }
else else
{ {
@ -93,7 +91,7 @@ string TestFunctionCall::format(
stream << comment << m_call.arguments.comment << comment; stream << comment << m_call.arguments.comment << comment;
stream << endl << _linePrefix << newline << ws; stream << endl << _linePrefix << newline << ws;
} }
stream << arrow << ws; stream << arrow;
} }
/// Format either the expected output or the actual result output /// Format either the expected output or the actual result output
@ -105,7 +103,8 @@ string TestFunctionCall::format(
result = isFailure ? result = isFailure ?
failure : failure :
formatRawParameters(m_call.expectations.result); formatRawParameters(m_call.expectations.result);
AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << result; if (!result.empty())
AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << ws << result;
} }
else else
{ {
@ -124,9 +123,11 @@ string TestFunctionCall::format(
); );
if (isFailure) if (isFailure)
AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << result; AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << ws << result;
else else
stream << result; if (!result.empty())
stream << ws << result;
} }
/// Format comments on expectations taking the display-mode into account. /// Format comments on expectations taking the display-mode into account.
@ -292,7 +293,12 @@ string TestFunctionCall::formatRawParameters(
os << endl << _linePrefix << "// "; os << endl << _linePrefix << "// ";
os << param.rawString; os << param.rawString;
if (&param != &_params.back()) if (&param != &_params.back())
os << ", "; {
if (param.format.newline)
os << ",";
else
os << ", ";
}
} }
return os.str(); return os.str();
} }