diff --git a/test/CommonSyntaxTest.cpp b/test/CommonSyntaxTest.cpp index 79b597804..b3c242957 100644 --- a/test/CommonSyntaxTest.cpp +++ b/test/CommonSyntaxTest.cpp @@ -114,7 +114,7 @@ void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix, { assert(static_cast(error.locationStart) <= source.length()); assert(static_cast(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 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 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 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), diff --git a/test/CommonSyntaxTest.h b/test/CommonSyntaxTest.h index 606f61a88..fb46c37a6 100644 --- a/test/CommonSyntaxTest.h +++ b/test/CommonSyntaxTest.h @@ -34,7 +34,7 @@ namespace solidity::test struct SyntaxTestError { - std::string type; + langutil::Error::Type type; std::optional errorId; std::string message; std::string sourceName; diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index 906391e01..90003768e 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -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, diff --git a/test/libyul/SyntaxTest.cpp b/test/libyul/SyntaxTest.cpp index cea1d5745..20aadcf19 100644 --- a/test/libyul/SyntaxTest.cpp +++ b/test/libyul/SyntaxTest.cpp @@ -61,7 +61,7 @@ void SyntaxTest::parseAndAnalyze() } m_errorList.emplace_back(SyntaxTestError{ - Error::formatErrorType(error->type()), + error->type(), error->errorId(), errorMessage(*error), name,