tests: Improved pattern unit tests
This commit is contained in:
parent
9ccfadfb54
commit
d6f9ec3f8f
@ -17,10 +17,10 @@ namespace hex::pl {
|
||||
Lexer() = default;
|
||||
|
||||
std::optional<std::vector<Token>> lex(const std::string& code);
|
||||
const LexerError& getError() { return this->m_error; }
|
||||
const std::optional<LexerError>& getError() { return this->m_error; }
|
||||
|
||||
private:
|
||||
LexerError m_error;
|
||||
std::optional<LexerError> m_error;
|
||||
|
||||
[[noreturn]] void throwLexerError(const std::string &error, u32 lineNumber) const {
|
||||
throw LexerError(lineNumber, "Lexer: " + error);
|
||||
|
@ -55,11 +55,11 @@ namespace hex::pl {
|
||||
void setHardError(const EvaluateError &error) { this->m_lastHardError = error; }
|
||||
|
||||
[[nodiscard]]
|
||||
const LogConsole::EvaluateError& getLastHardError() { return this->m_lastHardError; };
|
||||
const std::optional<EvaluateError>& getLastHardError() { return this->m_lastHardError; };
|
||||
|
||||
private:
|
||||
std::vector<std::pair<Level, std::string>> m_consoleLog;
|
||||
EvaluateError m_lastHardError;
|
||||
std::optional<EvaluateError> m_lastHardError;
|
||||
};
|
||||
|
||||
}
|
@ -22,10 +22,10 @@ namespace hex::pl {
|
||||
~Parser() = default;
|
||||
|
||||
std::optional<std::vector<ASTNode*>> parse(const std::vector<Token> &tokens);
|
||||
const ParseError& getError() { return this->m_error; }
|
||||
const std::optional<ParseError>& getError() { return this->m_error; }
|
||||
|
||||
private:
|
||||
ParseError m_error;
|
||||
std::optional<ParseError> m_error;
|
||||
TokenIter m_curr;
|
||||
TokenIter m_originalPosition;
|
||||
|
||||
|
@ -64,9 +64,8 @@ int test(int argc, char **argv) {
|
||||
|
||||
if (auto error = language.getError(); error.has_value())
|
||||
hex::log::info("Compile error: {} : {}", error->first, error->second);
|
||||
else
|
||||
for (auto &[level, message] : language.getConsoleLog())
|
||||
hex::log::info("Evaluate error: {}", message);
|
||||
for (auto &[level, message] : language.getConsoleLog())
|
||||
hex::log::info("Evaluate error: {}", message);
|
||||
|
||||
return failing ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user