34
34
#include < memory>
35
35
#include < stdexcept>
36
36
37
- using namespace std ;
38
37
using namespace solidity ;
39
38
using namespace solidity ::util;
40
39
using namespace solidity ::util::formatting;
@@ -48,10 +47,10 @@ namespace fs = boost::filesystem;
48
47
namespace
49
48
{
50
49
51
- int parseUnsignedInteger (string::iterator& _it, string::iterator _end)
50
+ int parseUnsignedInteger (std:: string::iterator& _it, std:: string::iterator _end)
52
51
{
53
52
if (_it == _end || !util::isDigit (*_it))
54
- BOOST_THROW_EXCEPTION (runtime_error (" Invalid test expectation. Source location expected." ));
53
+ BOOST_THROW_EXCEPTION (std:: runtime_error (" Invalid test expectation. Source location expected." ));
55
54
int result = 0 ;
56
55
while (_it != _end && util::isDigit (*_it))
57
56
{
@@ -64,23 +63,23 @@ int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
64
63
65
64
}
66
65
67
- CommonSyntaxTest::CommonSyntaxTest (string const & _filename, langutil::EVMVersion _evmVersion):
66
+ CommonSyntaxTest::CommonSyntaxTest (std:: string const & _filename, langutil::EVMVersion _evmVersion):
68
67
EVMVersionRestrictedTestCase(_filename),
69
68
m_sources(m_reader.sources()),
70
69
m_expectations(parseExpectations(m_reader.stream())),
71
70
m_evmVersion(_evmVersion)
72
71
{
73
72
}
74
73
75
- TestCase::TestResult CommonSyntaxTest::run (ostream& _stream, string const & _linePrefix, bool _formatted)
74
+ TestCase::TestResult CommonSyntaxTest::run (std:: ostream& _stream, std:: string const & _linePrefix, bool _formatted)
76
75
{
77
76
parseCustomExpectations (m_reader.stream ());
78
77
parseAndAnalyze ();
79
78
80
79
return conclude (_stream, _linePrefix, _formatted);
81
80
}
82
81
83
- TestCase::TestResult CommonSyntaxTest::conclude (ostream& _stream, string const & _linePrefix, bool _formatted)
82
+ TestCase::TestResult CommonSyntaxTest::conclude (std:: ostream& _stream, std:: string const & _linePrefix, bool _formatted)
84
83
{
85
84
if (expectationsMatch ())
86
85
return TestResult::Success;
@@ -89,16 +88,16 @@ TestCase::TestResult CommonSyntaxTest::conclude(ostream& _stream, string const&
89
88
return TestResult::Failure;
90
89
}
91
90
92
- void CommonSyntaxTest::printExpectationAndError (ostream& _stream, string const & _linePrefix, bool _formatted)
91
+ void CommonSyntaxTest::printExpectationAndError (std:: ostream& _stream, std:: string const & _linePrefix, bool _formatted)
93
92
{
94
- string nextIndentLevel = _linePrefix + " " ;
95
- util::AnsiColorized (_stream, _formatted, {BOLD, CYAN}) << _linePrefix << " Expected result:" << endl;
93
+ std:: string nextIndentLevel = _linePrefix + " " ;
94
+ util::AnsiColorized (_stream, _formatted, {BOLD, CYAN}) << _linePrefix << " Expected result:" << std:: endl;
96
95
printExpectedResult (_stream, nextIndentLevel, _formatted);
97
- util::AnsiColorized (_stream, _formatted, {BOLD, CYAN}) << _linePrefix << " Obtained result:" << endl;
96
+ util::AnsiColorized (_stream, _formatted, {BOLD, CYAN}) << _linePrefix << " Obtained result:" << std:: endl;
98
97
printObtainedResult (_stream, nextIndentLevel, _formatted);
99
98
}
100
99
101
- void CommonSyntaxTest::printSource (ostream& _stream, string const & _linePrefix, bool _formatted) const
100
+ void CommonSyntaxTest::printSource (std:: ostream& _stream, std:: string const & _linePrefix, bool _formatted) const
102
101
{
103
102
if (m_sources.sources .empty ())
104
103
return ;
@@ -113,8 +112,8 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
113
112
continue ;
114
113
115
114
if (outputSourceNames)
116
- _stream << _linePrefix << util::formatting::CYAN << " ==== Source: " << name << " ====" << util::formatting::RESET << endl;
117
- vector<char const *> sourceFormatting (source.length (), util::formatting::RESET);
115
+ _stream << _linePrefix << util::formatting::CYAN << " ==== Source: " << name << " ====" << util::formatting::RESET << std:: endl;
116
+ std:: vector<char const *> sourceFormatting (source.length (), util::formatting::RESET);
118
117
for (auto const & error: m_errorList)
119
118
if (error.sourceName == name && error.locationStart >= 0 && error.locationEnd >= 0 )
120
119
{
@@ -143,7 +142,7 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
143
142
_stream << source[i];
144
143
else
145
144
{
146
- _stream << util::formatting::RESET << endl;
145
+ _stream << util::formatting::RESET << std:: endl;
147
146
if (i + 1 < source.length ())
148
147
_stream << _linePrefix << sourceFormatting[i];
149
148
}
@@ -158,9 +157,9 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
158
157
}
159
158
}
160
159
161
- void CommonSyntaxTest::parseCustomExpectations (istream& _stream)
160
+ void CommonSyntaxTest::parseCustomExpectations (std:: istream& _stream)
162
161
{
163
- string remainingExpectations = boost::trim_copy (readUntilEnd (_stream));
162
+ std:: string remainingExpectations = boost::trim_copy (readUntilEnd (_stream));
164
163
soltestAssert (
165
164
remainingExpectations.empty (),
166
165
" Found custom expectations not supported by the test case:\n " + remainingExpectations
@@ -172,27 +171,27 @@ bool CommonSyntaxTest::expectationsMatch()
172
171
return m_expectations == m_errorList;
173
172
}
174
173
175
- void CommonSyntaxTest::printExpectedResult (ostream& _stream, string const & _linePrefix, bool _formatted) const
174
+ void CommonSyntaxTest::printExpectedResult (std:: ostream& _stream, std:: string const & _linePrefix, bool _formatted) const
176
175
{
177
176
printErrorList (_stream, m_expectations, _linePrefix, _formatted);
178
177
}
179
178
180
- void CommonSyntaxTest::printObtainedResult (ostream& _stream, string const & _linePrefix, bool _formatted) const
179
+ void CommonSyntaxTest::printObtainedResult (std:: ostream& _stream, std:: string const & _linePrefix, bool _formatted) const
181
180
{
182
181
printErrorList (_stream, m_errorList, _linePrefix, _formatted);
183
182
}
184
183
185
184
void CommonSyntaxTest::printErrorList (
186
- ostream& _stream,
187
- vector<SyntaxTestError> const & _errorList,
188
- string const & _linePrefix,
185
+ std:: ostream& _stream,
186
+ std:: vector<SyntaxTestError> const & _errorList,
187
+ std:: string const & _linePrefix,
189
188
bool _formatted
190
189
)
191
190
{
192
191
if (_errorList.empty ())
193
192
{
194
193
if (_formatted)
195
- util::AnsiColorized (_stream, _formatted, {BOLD, GREEN}) << _linePrefix << " Success" << endl;
194
+ util::AnsiColorized (_stream, _formatted, {BOLD, GREEN}) << _linePrefix << " Success" << std:: endl;
196
195
}
197
196
else
198
197
for (auto const & error: _errorList)
@@ -220,25 +219,25 @@ void CommonSyntaxTest::printErrorList(
220
219
_stream << error.locationEnd ;
221
220
_stream << " ): " ;
222
221
}
223
- _stream << error.message << endl;
222
+ _stream << error.message << std:: endl;
224
223
}
225
224
}
226
225
227
- string CommonSyntaxTest::errorMessage (util::Exception const & _e)
226
+ std:: string CommonSyntaxTest::errorMessage (util::Exception const & _e)
228
227
{
229
228
if (_e.comment () && !_e.comment ()->empty ())
230
229
return boost::replace_all_copy (*_e.comment (), " \n " , " \\ n" );
231
230
else
232
231
return " NONE" ;
233
232
}
234
233
235
- vector<SyntaxTestError> CommonSyntaxTest::parseExpectations (istream& _stream)
234
+ std:: vector<SyntaxTestError> CommonSyntaxTest::parseExpectations (std:: istream& _stream)
236
235
{
237
- static string const customExpectationsDelimiter (" // ----" );
236
+ static std:: string const customExpectationsDelimiter (" // ----" );
238
237
239
- vector<SyntaxTestError> expectations;
240
- string line;
241
- while (getline (_stream, line))
238
+ std:: vector<SyntaxTestError> expectations;
239
+ std:: string line;
240
+ while (std:: getline (_stream, line))
242
241
{
243
242
auto it = line.begin ();
244
243
@@ -254,17 +253,17 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
254
253
if (it == line.end ()) continue ;
255
254
256
255
auto typeBegin = it;
257
- while (it != line.end () && isalpha (*it, locale::classic ()))
256
+ while (it != line.end () && isalpha (*it, std:: locale::classic ()))
258
257
++it;
259
258
260
- string errorTypeStr (typeBegin, it);
261
- optional<Error::Type> errorType = Error::parseErrorType (errorTypeStr);
259
+ std:: string errorTypeStr (typeBegin, it);
260
+ std:: optional<Error::Type> errorType = Error::parseErrorType (errorTypeStr);
262
261
if (!errorType.has_value ())
263
- BOOST_THROW_EXCEPTION (runtime_error (" Invalid error type: " + errorTypeStr));
262
+ BOOST_THROW_EXCEPTION (std:: runtime_error (" Invalid error type: " + errorTypeStr));
264
263
265
264
skipWhitespace (it, line.end ());
266
265
267
- optional<ErrorId> errorId;
266
+ std:: optional<ErrorId> errorId;
268
267
if (it != line.end () && util::isDigit (*it))
269
268
errorId = ErrorId{static_cast <unsigned long long >(parseUnsignedInteger (it, line.end ()))};
270
269
@@ -295,7 +294,7 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
295
294
296
295
skipWhitespace (it, line.end ());
297
296
298
- string errorMessage (it, line.end ());
297
+ std:: string errorMessage (it, line.end ());
299
298
expectations.emplace_back (SyntaxTestError{
300
299
errorType.value (),
301
300
std::move (errorId),
0 commit comments