diff options
| author | hachem <im@hachem.wtf> | 2026-08-31 19:58:56 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-31 19:58:56 +0200 |
| commit | 5b06b0e4b8effaacd23308d6a6b26c525e7d3af4 (patch) | |
| tree | 351155777028e604845d3dfec27d3caf3b22257f /tests/sema_test.c | |
| parent | cbdb9073480c3e4d8a088b306c23406cf42e25c0 (diff) | |
feat: add enums and structs
Diffstat (limited to 'tests/sema_test.c')
| -rw-r--r-- | tests/sema_test.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/sema_test.c b/tests/sema_test.c index 2d6e187..e89f608 100644 --- a/tests/sema_test.c +++ b/tests/sema_test.c @@ -97,6 +97,17 @@ static void test_deref_needs_register(struct TestContext* context) check(context, analyze_source("proc main\n{\nrax = ^rsi\n}\n")); } +static void test_enum_struct_members(struct TestContext* context) +{ + check(context, analyze_source( + "enum Color\n{\nRed,\nGreen\n}\nstruct Point\n{\nx\ny\n}\n" + "proc main\n{\nrax = Color.Green\nrbx = Point.y\nrcx = Point.size\n}\n")); + check(context, !analyze_source( + "enum Color\n{\nRed\n}\nproc main\n{\nrax = Color.Nope\n}\n")); + check(context, !analyze_source( + "struct Point\n{\nx\n}\nproc main\n{\nrax = Point.z\n}\n")); +} + static void test_references_resolve(struct TestContext* context) { // registers, params, consts, data (+ .len), stack buffers, labels, calls @@ -133,5 +144,6 @@ void run_sema_tests(struct TestContext* context) test_const_expr_rejects_register(context); test_const_expr_rejects_data(context); test_deref_needs_register(context); + test_enum_struct_members(context); test_references_resolve(context); } |
