mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Store Error::Type rather than a string in SyntaxTestError
This commit is contained in:
parent
fc37b4eeb6
commit
81b5387a9f
@ -114,7 +114,7 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix,
|
||||
{
|
||||
assert(static_cast<size_t>(error.locationStart) <= source.length());
|
||||
assert(static_cast<size_t>(error.locationEnd) <= source.length());
|
||||
bool isWarning = error.type == "Warning";
|
||||
bool isWarning = (error.type == Error::Type::Warning);
|
||||
for (int i = error.locationStart; i < error.locationEnd; i++)
|
||||
if (isWarning)
|
||||
{
|
||||
@ -192,8 +192,8 @@ void CommonSyntaxTest::printErrorList(
|
||||
for (auto const& error: _errorList)
|
||||
{
|
||||
{
|
||||
util::AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == "Warning") ? YELLOW : RED});
|
||||
_stream << _linePrefix << error.type;
|
||||
util::AnsiColorized scope(_stream, _formatted, {BOLD, (error.type == Error::Type::Warning) ? YELLOW : RED});
|
||||
_stream << _linePrefix << Error::formatErrorType(error.type);
|
||||
if (error.errorId.has_value())
|
||||
_stream << ' ' << error.errorId->error;
|
||||
_stream << ": ";
|
||||
@ -246,7 +246,11 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
|
||||
auto typeBegin = it;
|
||||
while (it != line.end() && isalpha(*it, locale::classic()))
|
||||
++it;
|
||||
string errorType(typeBegin, it);
|
||||
|
||||
std::string errorTypeStr(typeBegin, it);
|
||||
optional<Error::Type> errorType = Error::parseErrorType(errorTypeStr);
|
||||
if (!errorType.has_value())
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Invalid error type: " + errorTypeStr));
|
||||
|
||||
skipWhitespace(it, line.end());
|
||||
|
||||
@ -283,7 +287,7 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
|
||||
|
||||
string errorMessage(it, line.end());
|
||||
expectations.emplace_back(SyntaxTestError{
|
||||
std::move(errorType),
|
||||
errorType.value(),
|
||||
std::move(errorId),
|
||||
std::move(errorMessage),
|
||||
std::move(sourceName),
|
||||
|
@ -34,7 +34,7 @@ namespace solidity::test
|
||||
|
||||
struct SyntaxTestError
|
||||
{
|
||||
std::string type;
|
||||
langutil::Error::Type type;
|
||||
std::optional<langutil::ErrorId> errorId;
|
||||
std::string message;
|
||||
std::string sourceName;
|
||||
|
@ -86,7 +86,7 @@ void SyntaxTest::parseAndAnalyze()
|
||||
catch (UnimplementedFeatureError const& _e)
|
||||
{
|
||||
m_errorList.emplace_back(SyntaxTestError{
|
||||
"UnimplementedFeatureError",
|
||||
Error::Type::UnimplementedFeatureError,
|
||||
nullopt,
|
||||
errorMessage(_e),
|
||||
"",
|
||||
@ -135,7 +135,7 @@ void SyntaxTest::filterObtainedErrors()
|
||||
}
|
||||
}
|
||||
m_errorList.emplace_back(SyntaxTestError{
|
||||
Error::formatErrorType(currentError->type()),
|
||||
currentError->type(),
|
||||
currentError->errorId(),
|
||||
errorMessage(*currentError),
|
||||
sourceName,
|
||||
|
@ -61,7 +61,7 @@ void SyntaxTest::parseAndAnalyze()
|
||||
}
|
||||
|
||||
m_errorList.emplace_back(SyntaxTestError{
|
||||
Error::formatErrorType(error->type()),
|
||||
error->type(),
|
||||
error->errorId(),
|
||||
errorMessage(*error),
|
||||
name,
|
||||
|
Loading…
Reference in New Issue
Block a user