Skip to content

Commit 3357567

Browse files
committed
Fix CommonSyntaxTest.cpp and others
1 parent 1c58b91 commit 3357567

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

test/CommonSyntaxTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ TestCase::TestResult CommonSyntaxTest::conclude(ostream& _stream, string const&
8383
void CommonSyntaxTest::printExpectationAndError(ostream& _stream, string const& _linePrefix, bool _formatted)
8484
{
8585
string nextIndentLevel = _linePrefix + " ";
86-
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
86+
util::AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
8787
printErrorList(_stream, m_expectations, nextIndentLevel, _formatted);
88-
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
88+
util::AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
8989
printErrorList(_stream, m_errorList, nextIndentLevel, _formatted);
9090
}
9191

@@ -104,8 +104,8 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
104104
continue;
105105

106106
if (outputSourceNames)
107-
_stream << _linePrefix << formatting::CYAN << "==== Source: " << name << " ====" << formatting::RESET << endl;
108-
vector<char const*> sourceFormatting(source.length(), formatting::RESET);
107+
_stream << _linePrefix << util::formatting::CYAN << "==== Source: " << name << " ====" << util::formatting::RESET << endl;
108+
vector<char const*> sourceFormatting(source.length(), util::formatting::RESET);
109109
for (auto const& error: m_errorList)
110110
if (error.sourceName == name && error.locationStart >= 0 && error.locationEnd >= 0)
111111
{
@@ -115,11 +115,11 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
115115
for (int i = error.locationStart; i < error.locationEnd; i++)
116116
if (isWarning)
117117
{
118-
if (sourceFormatting[static_cast<size_t>(i)] == formatting::RESET)
119-
sourceFormatting[static_cast<size_t>(i)] = formatting::ORANGE_BACKGROUND_256;
118+
if (sourceFormatting[static_cast<size_t>(i)] == util::formatting::RESET)
119+
sourceFormatting[static_cast<size_t>(i)] = util::formatting::ORANGE_BACKGROUND_256;
120120
}
121121
else
122-
sourceFormatting[static_cast<size_t>(i)] = formatting::RED_BACKGROUND;
122+
sourceFormatting[static_cast<size_t>(i)] = util::formatting::RED_BACKGROUND;
123123
}
124124

125125
_stream << _linePrefix << sourceFormatting.front() << source.front();
@@ -131,12 +131,12 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
131131
_stream << source[i];
132132
else
133133
{
134-
_stream << formatting::RESET << endl;
134+
_stream << util::formatting::RESET << endl;
135135
if (i + 1 < source.length())
136136
_stream << _linePrefix << sourceFormatting[i];
137137
}
138138
}
139-
_stream << formatting::RESET;
139+
_stream << util::formatting::RESET;
140140
}
141141
else
142142
{
@@ -157,12 +157,12 @@ void CommonSyntaxTest::printErrorList(
157157
)
158158
{
159159
if (_errorList.empty())
160-
AnsiColorized(_stream, _formatted, {BOLD, GREEN}) << _linePrefix << "Success" << endl;
160+
util::AnsiColorized(_stream, _formatted, {BOLD, GREEN}) << _linePrefix << "Success" << endl;
161161
else
162162
for (auto const& error: _errorList)
163163
{
164164
{
165-
AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
165+
util::AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
166166
_stream << _linePrefix << error.type;
167167
if (error.errorId.has_value())
168168
_stream << ' ' << error.errorId->error;
@@ -184,7 +184,7 @@ void CommonSyntaxTest::printErrorList(
184184
}
185185
}
186186

187-
string CommonSyntaxTest::errorMessage(Exception const& _e)
187+
string CommonSyntaxTest::errorMessage(util::Exception const& _e)
188188
{
189189
if (_e.comment() && !_e.comment()->empty())
190190
return boost::replace_all_copy(*_e.comment(), "\n", "\\n");

test/libsolidity/util/TestFileParser.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
// SPDX-License-Identifier: GPL-3.0
1818

19+
20+
#include <libsolutil/StringUtils.h>
21+
1922
#include <test/libsolidity/util/TestFileParser.h>
2023

2124
#include <test/libsolidity/util/BytesUtils.h>
@@ -34,6 +37,7 @@
3437
#include <stdexcept>
3538

3639
using namespace solidity;
40+
using namespace solidity::util;
3741
using namespace solidity::frontend;
3842
using namespace solidity::frontend::test;
3943
using namespace std;
@@ -767,7 +771,7 @@ char TestFileParser::Scanner::scanHexPart()
767771
advance(); // skip 'x'
768772

769773
int value{};
770-
if (util::isDigit(current()))
774+
if (isDigit(current()))
771775
value = current() - '0';
772776
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
773777
value = toLower(current()) - 'a' + 10;
@@ -779,7 +783,7 @@ char TestFileParser::Scanner::scanHexPart()
779783
return static_cast<char>(value);
780784

781785
value <<= 4;
782-
if (util::isDigit(current()))
786+
if (isDigit(current()))
783787
value |= current() - '0';
784788
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
785789
value |= toLower(current()) - 'a' + 10;

0 commit comments

Comments
 (0)