mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix CommonSyntaxTest.cpp and others
This commit is contained in:
parent
1c58b91075
commit
3357567453
@ -83,9 +83,9 @@ TestCase::TestResult CommonSyntaxTest::conclude(ostream& _stream, string const&
|
||||
void CommonSyntaxTest::printExpectationAndError(ostream& _stream, string const& _linePrefix, bool _formatted)
|
||||
{
|
||||
string nextIndentLevel = _linePrefix + " ";
|
||||
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
|
||||
util::AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
|
||||
printErrorList(_stream, m_expectations, nextIndentLevel, _formatted);
|
||||
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
|
||||
util::AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
|
||||
printErrorList(_stream, m_errorList, nextIndentLevel, _formatted);
|
||||
}
|
||||
|
||||
@ -104,8 +104,8 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
|
||||
continue;
|
||||
|
||||
if (outputSourceNames)
|
||||
_stream << _linePrefix << formatting::CYAN << "==== Source: " << name << " ====" << formatting::RESET << endl;
|
||||
vector<char const*> sourceFormatting(source.length(), formatting::RESET);
|
||||
_stream << _linePrefix << util::formatting::CYAN << "==== Source: " << name << " ====" << util::formatting::RESET << endl;
|
||||
vector<char const*> sourceFormatting(source.length(), util::formatting::RESET);
|
||||
for (auto const& error: m_errorList)
|
||||
if (error.sourceName == name && error.locationStart >= 0 && error.locationEnd >= 0)
|
||||
{
|
||||
@ -115,11 +115,11 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
|
||||
for (int i = error.locationStart; i < error.locationEnd; i++)
|
||||
if (isWarning)
|
||||
{
|
||||
if (sourceFormatting[static_cast<size_t>(i)] == formatting::RESET)
|
||||
sourceFormatting[static_cast<size_t>(i)] = formatting::ORANGE_BACKGROUND_256;
|
||||
if (sourceFormatting[static_cast<size_t>(i)] == util::formatting::RESET)
|
||||
sourceFormatting[static_cast<size_t>(i)] = util::formatting::ORANGE_BACKGROUND_256;
|
||||
}
|
||||
else
|
||||
sourceFormatting[static_cast<size_t>(i)] = formatting::RED_BACKGROUND;
|
||||
sourceFormatting[static_cast<size_t>(i)] = util::formatting::RED_BACKGROUND;
|
||||
}
|
||||
|
||||
_stream << _linePrefix << sourceFormatting.front() << source.front();
|
||||
@ -131,12 +131,12 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
|
||||
_stream << source[i];
|
||||
else
|
||||
{
|
||||
_stream << formatting::RESET << endl;
|
||||
_stream << util::formatting::RESET << endl;
|
||||
if (i + 1 < source.length())
|
||||
_stream << _linePrefix << sourceFormatting[i];
|
||||
}
|
||||
}
|
||||
_stream << formatting::RESET;
|
||||
_stream << util::formatting::RESET;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -157,12 +157,12 @@ void CommonSyntaxTest::printErrorList(
|
||||
)
|
||||
{
|
||||
if (_errorList.empty())
|
||||
AnsiColorized(_stream, _formatted, {BOLD, GREEN}) << _linePrefix << "Success" << endl;
|
||||
util::AnsiColorized(_stream, _formatted, {BOLD, GREEN}) << _linePrefix << "Success" << endl;
|
||||
else
|
||||
for (auto const& error: _errorList)
|
||||
{
|
||||
{
|
||||
AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
|
||||
util::AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
|
||||
_stream << _linePrefix << error.type;
|
||||
if (error.errorId.has_value())
|
||||
_stream << ' ' << error.errorId->error;
|
||||
@ -184,7 +184,7 @@ void CommonSyntaxTest::printErrorList(
|
||||
}
|
||||
}
|
||||
|
||||
string CommonSyntaxTest::errorMessage(Exception const& _e)
|
||||
string CommonSyntaxTest::errorMessage(util::Exception const& _e)
|
||||
{
|
||||
if (_e.comment() && !_e.comment()->empty())
|
||||
return boost::replace_all_copy(*_e.comment(), "\n", "\\n");
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
#include <test/libsolidity/util/TestFileParser.h>
|
||||
|
||||
#include <test/libsolidity/util/BytesUtils.h>
|
||||
@ -34,6 +37,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace solidity;
|
||||
using namespace solidity::util;
|
||||
using namespace solidity::frontend;
|
||||
using namespace solidity::frontend::test;
|
||||
using namespace std;
|
||||
@ -767,7 +771,7 @@ char TestFileParser::Scanner::scanHexPart()
|
||||
advance(); // skip 'x'
|
||||
|
||||
int value{};
|
||||
if (util::isDigit(current()))
|
||||
if (isDigit(current()))
|
||||
value = current() - '0';
|
||||
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
|
||||
value = toLower(current()) - 'a' + 10;
|
||||
@ -779,7 +783,7 @@ char TestFileParser::Scanner::scanHexPart()
|
||||
return static_cast<char>(value);
|
||||
|
||||
value <<= 4;
|
||||
if (util::isDigit(current()))
|
||||
if (isDigit(current()))
|
||||
value |= current() - '0';
|
||||
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
|
||||
value |= toLower(current()) - 'a' + 10;
|
||||
|
Loading…
Reference in New Issue
Block a user