diff options
| author | hachem <im@hachem.wtf> | 2026-08-30 22:42:20 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-30 22:42:20 +0200 |
| commit | 81799f3e41ad9cab305930b7743a752003ff16ec (patch) | |
| tree | 20fd67914ac143ab97a00392abcf5817ba11db22 /tests/codegen_test.c | |
| parent | 294777178f9203283364f3e672569becb4dd1e7c (diff) | |
feat: sized memory stores bia ^
Diffstat (limited to 'tests/codegen_test.c')
| -rw-r--r-- | tests/codegen_test.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/codegen_test.c b/tests/codegen_test.c index a72638b..64a422d 100644 --- a/tests/codegen_test.c +++ b/tests/codegen_test.c @@ -203,6 +203,31 @@ static void test_generate_address_expr(struct TestContext* context) free_program(&program); } +static void test_generate_sized_store(struct TestContext* context) +{ + struct Lexer lexer = create_lexer( + "proc main\n{\n^byte rsi = rdx\n^dword rsi = rax\n^byte rsi = 5\n^rsi = rbx\n}\n"); + struct Program program; + check(context, parse_program(&lexer, &program)); + + FILE* out = tmpfile(); + generate_nasm(&program, out); + fflush(out); + rewind(out); + + char buffer[1024]; + size_t read = fread(buffer, 1, sizeof(buffer) - 1, out); + buffer[read] = '\0'; + fclose(out); + + check(context, strstr(buffer, "mov byte [rsi], dl") != NULL); + check(context, strstr(buffer, "mov dword [rsi], eax") != NULL); + check(context, strstr(buffer, "mov byte [rsi], 5") != NULL); + check(context, strstr(buffer, "mov [rsi], rbx") != NULL); + + free_program(&program); +} + void run_codegen_tests(struct TestContext* context) { test_generate_consts_and_data(context); @@ -213,4 +238,5 @@ void run_codegen_tests(struct TestContext* context) test_generate_divide(context); test_generate_stack_frame(context); test_generate_address_expr(context); + test_generate_sized_store(context); } |
