folder for the tests (that utils is includable only by the tests and not the src code, I added a compiler flag only for the tests in the makefile, but the compiler_flags.txt is global for the lsp, gotta be careful with that)
22 lines
463 B
C++
22 lines
463 B
C++
#include "utils.hpp"
|
|
|
|
#include <doctest.h>
|
|
|
|
TEST_SUITE("Parser: return") {
|
|
TEST_CASE_FIXTURE(test::utils::ParserFixture, "Parse return statement") {
|
|
setup("\
|
|
return 5;\
|
|
return 10;\
|
|
return 103213;\
|
|
return 12 + 34;\
|
|
");
|
|
|
|
REQUIRE(program->statements.size() == 4);
|
|
|
|
for (const auto stmt : program->statements) {
|
|
CHECK(stmt->token_literal() == "return");
|
|
test::utils::cast<ast::return_stmt>(stmt);
|
|
}
|
|
}
|
|
}
|