Decaf Compiler
testsuite.h
Go to the documentation of this file.
1 
6 #include <stdbool.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <stdint.h>
10 #include <assert.h>
11 #include <time.h>
12 
13 #include <check.h>
14 
15 #include "p1-lexer.h"
16 #include "p2-parser.h"
17 #include "p3-analysis.h"
18 
22 #define TEST_VALID(NAME,TEXT) START_TEST (NAME) \
23 { ck_assert (valid_program(TEXT)); } \
24 END_TEST
25 
29 #define TEST_INVALID(NAME,TEXT) START_TEST (NAME) \
30 { ck_assert (invalid_program(TEXT)); } \
31 END_TEST
32 
36 #define TEST_VALID_MAIN(NAME,TEXT) START_TEST (NAME) \
37 { ck_assert (valid_program("def int main () { " TEXT " }")); } \
38 END_TEST
39 
43 #define TEST_INVALID_MAIN(NAME,TEXT) START_TEST (NAME) \
44 { ck_assert (invalid_program("def int main () { " TEXT " }")); } \
45 END_TEST
46 
50 #define TEST(NAME) tcase_add_test (tc, NAME)
51 
58 ErrorList* run_analysis (char* text);
59 
66 bool invalid_program (char* text);
67 
75 bool valid_program (char* text);
Interface for Project 1 (Lexer)
Interface for Project 2 (Parser)
Interface for Project 3 (Analysis)
Linked list of AnalysisError* elements.
Definition: symbol.h:217
ErrorList * run_analysis(char *text)
Run lexer, parser, and analysis on given text.
Definition: testsuite.c:10
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:26
bool invalid_program(char *text)
Run lexer and parser on given text and verify that it throws an exception.
Definition: testsuite.c:32