moved some stuff around in an attempt to make

things cleaner (not sure it is, but we tryin)
This commit is contained in:
Karma Riuk
2025-07-19 13:41:25 +02:00
parent c943380d58
commit 7b01840f4d
3 changed files with 58 additions and 56 deletions

33
test/utils/fixtures.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include "utils.hpp"
#include <doctest.h>
namespace test::utils {
void check_parser_errors(const std::vector<ast::error::error*>& errors) {
if (errors.empty())
return;
INFO("parser has " << errors.size() << " errors:");
std::ostringstream combined;
for (auto& err : errors)
combined << " > " << err->what() << '\n';
INFO(combined.str());
FAIL("Parser had errors.");
}
void ParserFixture::setup(std::string source) {
input.clear();
input << source;
lexer = std::make_unique<lexer::lexer>(input);
parser = std::make_unique<parser::parser>(*lexer);
program = parser->parse_program();
check_parser_errors(parser->errors);
REQUIRE_MESSAGE(
program != nullptr,
"parse_program() returned a null pointer"
);
}
} // namespace test::utils