diff options
Diffstat (limited to 'test/parser_test.c')
-rw-r--r-- | test/parser_test.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/parser_test.c b/test/parser_test.c index 78e2e23..ebb917c 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -48,9 +48,9 @@ assert_parser_error(char *src, char *error_msg) make_lexer_from_static_src(&lexer, src); parser_init(&parser, &lexer, scope); - ast_node_t *ast_function = parser_parse_function_declaration(&parser); + ast_node_t *ast_ns = parser_parse_ns(&parser); - assert_false(ast_function != NULL); + assert_false(ast_ns != NULL); assert_int(1, ==, parser.errors_len); assert_string_equal(error_msg, parser.errors[0].message); @@ -394,7 +394,7 @@ assert_string_view_equal(char *expected, string_view_t actual) static MunitResult test_parse_basic_syntax_errors(const MunitParameter params[], void *user_data_or_fixture) { - assert_parser_error("main(): i32 { return 42; }", "expected 'fn' but got 'TOKEN_NAME'"); + assert_parser_error("main(): i32 { return 42; }", "Unexpected token 'main'"); assert_parser_error("fn (): i32 { return 42; }", "expected 'TOKEN_NAME' but got '('"); assert_parser_error("fn main): i32 { return 42; }", "expected '(' but got ')'"); assert_parser_error("fn main(: i32 { return 42; }", "expected ')' but got ':'"); @@ -427,8 +427,9 @@ test_parse_basic_syntax_errors(const MunitParameter params[], void *user_data_or "incompatible types: expected 'bool', actual 'i32'."); assert_parser_error("fn main(): i32 { if true { return true; } \nreturn 42;\n }", "incompatible types: expected 'i32', actual 'bool'."); - // FIXME: once function calls are implemented, this error should inform that - // neither a variable or function call was found. + assert_parser_error("fn main(): i32 { return fn_404(); }", "identifier 'fn_404' not defined"); + assert_parser_error("fn my_bool_fn(): bool { return true; } fn main(): i32 { return my_bool_fn(); }", + "incompatible types: expected 'i32', actual 'bool'."); assert_parser_error("fn main(): i32 { oxi 42; }", "unexpected token 'TOKEN_NAME' value='oxi'"); return MUNIT_OK; |