diff options
Diffstat (limited to 'test/parser_test.c')
-rw-r--r-- | test/parser_test.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/parser_test.c b/test/parser_test.c index d1b8881..573296f 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -71,7 +71,11 @@ test_parse_function(const MunitParameter params[], ast_node_t *ast_return = ast_function->data.function.body; assert_int(AST_RETURN_STMT, ==, ast_return->kind); - assert_int(42, ==, ast_return->data.return_stmt.number); + + ast_node_t *ast_literal = ast_return->data.return_stmt.argument; + + assert_int(AST_LITERAL, ==, ast_literal->kind); + assert_int(42, ==, ast_literal->data.literal.value.integer); ast_node_destroy(ast_function); @@ -89,7 +93,7 @@ test_parse_basic_syntax_errors(const MunitParameter params[], assert_parser_error("main(): { return 42; }" , "expected 'TOKEN_NAME' but got '{'"); assert_parser_error("main(): i32 return 42; }" , "expected '{' but got 'TOKEN_NAME'"); assert_parser_error("main(): i32 { 42; }" , "expected 'TOKEN_NAME' but got 'TOKEN_NUMBER'"); - assert_parser_error("main(): i32 { return; }" , "expected 'TOKEN_NUMBER' but got ';'"); + assert_parser_error("main(): i32 { return; }" , "unexpected '; (;)' token"); assert_parser_error("main(): i32 { return 42;" , "expected '}' but got end of file"); assert_parser_error("main(): beff { return 42; }" , "type 'beff' is not defined"); assert_parser_error("main(): i32 { oxi 42; }" , "expected 'return' keyword but got 'oxi'"); |