diff options
Diffstat (limited to 'tests/test_as_analyzer.c')
| -rw-r--r-- | tests/test_as_analyzer.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/tests/test_as_analyzer.c b/tests/test_as_analyzer.c deleted file mode 100644 index 993860a..0000000 --- a/tests/test_as_analyzer.c +++ /dev/null @@ -1,45 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <assert.h> - -#include "as_tokenizer.h" -#include "as_parser.h" -#include "as_analyzer.h" -#include "utils.h" - -char *input_buffer = - "start:\n" - " imm 1\n" - "mid: add\n" - " call start\n" - " sub\n" - ".insec: add\n" - " div\n" - "end: eq\n"; - -int main(int argc, char** argv) { - struct result result; - printf("[TEST] assembler analyzer\n"); - // make a memory buffer to FILE* - FILE *fp = fmemopen(input_buffer, strlen(input_buffer), "r"); - struct allocator * alct = new_allocator(); - struct token_stream * ts = new_token_stream(alct, fp); - result = parse_prog(alct, ts); - assert(result.errmsg == NULL); - struct prog* prog = result.value; - struct sym_table sym_table = analyze_prog(alct, prog); - - assert(strcmp(sym_table.buf[0].name, "start") == 0); - assert(strcmp(sym_table.buf[1].name, "mid") == 0); - assert(strcmp(sym_table.buf[2].name, "mid.insec") == 0); - assert(strcmp(sym_table.buf[3].name, "end") == 0); - - assert(sym_table.buf[0].offset == 0); - assert(sym_table.buf[1].offset == 9); - assert(sym_table.buf[2].offset == 21); - assert(sym_table.buf[3].offset == 23); - - printf("[PASS] assembler analyzer\n"); - delete_allocator(alct); - return 0; -} |
