Add regression test for trivia at the head of tokenlist
All checks were successful
Validate the build / validate-build (push) Successful in 29s
All checks were successful
Validate the build / validate-build (push) Successful in 29s
This commit is contained in:
parent
5560de2904
commit
92c63092a1
5
tests/input/regression/test_trivia_head.asm
Normal file
5
tests/input/regression/test_trivia_head.asm
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
; sample program with trivia on the head of the tokenlist
|
||||||
|
|
||||||
|
_start:
|
||||||
|
xor rax, rax
|
||||||
|
call exit
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
extern MunitTest ast_tests[];
|
extern MunitTest ast_tests[];
|
||||||
extern MunitTest lexer_tests[];
|
extern MunitTest lexer_tests[];
|
||||||
|
extern MunitTest regression_tests[];
|
||||||
|
|
||||||
int main(int argc, char *argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
|
int main(int argc, char *argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
|
||||||
MunitSuite suites[] = {
|
MunitSuite suites[] = {
|
||||||
|
{"/regression", regression_tests, nullptr, 1, MUNIT_SUITE_OPTION_NONE},
|
||||||
{"/ast", ast_tests, nullptr, 1, MUNIT_SUITE_OPTION_NONE},
|
{"/ast", ast_tests, nullptr, 1, MUNIT_SUITE_OPTION_NONE},
|
||||||
{"/lexer", lexer_tests, nullptr, 1, MUNIT_SUITE_OPTION_NONE},
|
{"/lexer", lexer_tests, nullptr, 1, MUNIT_SUITE_OPTION_NONE},
|
||||||
{nullptr, nullptr, nullptr, 0, MUNIT_SUITE_OPTION_NONE},
|
{nullptr, nullptr, nullptr, 0, MUNIT_SUITE_OPTION_NONE},
|
||||||
|
31
tests/regression.c
Normal file
31
tests/regression.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "../src/ast.h"
|
||||||
|
#include "../src/parser/parser.h"
|
||||||
|
#include "munit.h"
|
||||||
|
|
||||||
|
MunitResult test_regression_trivia_head(const MunitParameter params[], void *data) {
|
||||||
|
(void)params;
|
||||||
|
(void)data;
|
||||||
|
|
||||||
|
lexer_t *lex = &(lexer_t){};
|
||||||
|
error_t *err = lexer_open(lex, "tests/input/regression/test_trivia_head.asm");
|
||||||
|
munit_assert_null(err);
|
||||||
|
|
||||||
|
tokenlist_t *list;
|
||||||
|
err = tokenlist_alloc(&list);
|
||||||
|
munit_assert_null(err);
|
||||||
|
|
||||||
|
err = tokenlist_fill(list, lex);
|
||||||
|
munit_assert_null(err);
|
||||||
|
|
||||||
|
parse_result_t result = parse(list->head);
|
||||||
|
munit_assert_null(result.err);
|
||||||
|
munit_assert_null(result.next);
|
||||||
|
|
||||||
|
ast_node_free(result.node);
|
||||||
|
tokenlist_free(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
MunitTest regression_tests[] = {
|
||||||
|
{"/trivia_head", test_regression_trivia_head, nullptr, nullptr, MUNIT_TEST_OPTION_NONE, nullptr},
|
||||||
|
{nullptr, nullptr, nullptr, nullptr, MUNIT_TEST_OPTION_NONE, nullptr}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user