aboutsummaryrefslogtreecommitdiff
path: root/tests/parser_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parser_test.c')
-rw-r--r--tests/parser_test.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/parser_test.c b/tests/parser_test.c
index 88e32a1..a88a319 100644
--- a/tests/parser_test.c
+++ b/tests/parser_test.c
@@ -241,6 +241,23 @@ static void test_parse_while(struct TestContext* context)
check(context, primary_is(loop.loop.right, "0"));
check(context, loop.loop.body_count == 2);
check(context, text_is(loop.loop.body[1].assign.target, "rcx"));
+ check(context, !loop.loop.named);
+
+ 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");
+ struct Program program;
+
+ check(context, parse_program(&lexer, &program));
+
+ struct Statement loop = program.procs[0].body[0];
+ check(context, loop.kind == STATEMENT_WHILE);
+ check(context, loop.loop.named);
+ check(context, text_is(loop.loop.name, "drain"));
+ check(context, primary_is(loop.loop.left, "rcx"));
free_program(&program);
}
@@ -417,6 +434,7 @@ void run_parser_tests(struct TestContext* context)
test_parse_if_block(context);
test_parse_else_if(context);
test_parse_while(context);
+ test_parse_while_named(context);
test_parse_call(context);
test_parse_stack(context);
test_parse_sized_deref(context);