diff options
Diffstat (limited to 'tests/parser_test.c')
| -rw-r--r-- | tests/parser_test.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/parser_test.c b/tests/parser_test.c index 9db85ec..eecc9b9 100644 --- a/tests/parser_test.c +++ b/tests/parser_test.c @@ -246,6 +246,25 @@ static void test_parse_while(struct TestContext* context) free_program(&program); } +static void test_parse_select(struct TestContext* context) +{ + struct Lexer lexer = create_lexer("proc main\n{\nr1 = r2 if r3 < r4 else r5\n}\n"); + struct Program program; + + check(context, parse_program(&lexer, &program)); + + struct Statement s = program.procs[0].body[0]; + check(context, s.kind == STATEMENT_SELECT); + check(context, text_is(s.select.target, "r1")); + check(context, primary_is(s.select.if_value, "r2")); + check(context, primary_is(s.select.left, "r3")); + check(context, text_is(s.select.comparison, "<")); + check(context, primary_is(s.select.right, "r4")); + check(context, primary_is(s.select.else_value, "r5")); + + free_program(&program); +} + static void test_parse_while_named(struct TestContext* context) { struct Lexer lexer = create_lexer("proc main\n{\nwhile .drain rcx > 0\n{\nrcx -= 1\n}\n}\n"); @@ -435,6 +454,7 @@ void run_parser_tests(struct TestContext* context) test_parse_else_if(context); test_parse_while(context); test_parse_while_named(context); + test_parse_select(context); test_parse_call(context); test_parse_stack(context); test_parse_sized_deref(context); |
