Go to the documentation of this file.
21 #define TEST_VALID(NAME,TEXT) START_TEST (NAME) \
22 { ck_assert (valid_program(TEXT)); } \
28 #define TEST_INVALID(NAME,TEXT) START_TEST (NAME) \
29 { ck_assert (invalid_program(TEXT)); } \
35 #define TEST_VALID_MAIN(NAME,TEXT) START_TEST (NAME) \
36 { ck_assert (valid_program("def int main () { " TEXT " }")); } \
42 #define TEST_INVALID_MAIN(NAME,TEXT) START_TEST (NAME) \
43 { ck_assert (invalid_program("def int main () { " TEXT " }")); } \
49 #define TEST_VALID_EXPR(NAME,TEXT) START_TEST (NAME) \
50 { ck_assert (valid_program("def int main () { return " TEXT " ; }")); } \
56 #define TEST_INVALID_EXPR(NAME,TEXT) START_TEST (NAME) \
57 { ck_assert (invalid_program("def int main () { return " TEXT " ; }")); } \
63 #define TEST_INT_LITERAL(NAME,TEXT,VALUE) START_TEST (NAME) \
64 { ASTNode* p = run_parser("def int main() { return " TEXT " ; }"); \
65 int value = p->program.functions->head->funcdecl.body->block.statements->head->funcreturn.value->literal.integer; \
66 ck_assert_int_eq(value, VALUE); } \
72 #define TEST_STR_LITERAL(NAME,TEXT,VALUE) START_TEST (NAME) \
73 { ASTNode* p = run_parser("def int main() { return " TEXT " ; }"); \
74 char* value = p->program.functions->head->funcdecl.body->block.statements->head->funcreturn.value->literal.string; \
75 ck_assert_str_eq(value, VALUE); } \
81 #define TEST(NAME) tcase_add_test (tc, NAME)
Main AST node structure.
Definition: ast.h:470
Interface for Project 2 (Parser)
bool valid_program(char *text)
Run lexer and parser on given text and verify that it returns an AST and does not throw an exception.
Definition: testsuite.c:21
Interface for Project 1 (Lexer)
ASTNode * run_parser(char *text)
Run lexer and parser on given text.
Definition: testsuite.c:10
bool invalid_program(char *text)
Run lexer and parser on given text and verify that it throws an exception.
Definition: testsuite.c:26