diff options
Diffstat (limited to 'test/parser_test.c')
-rw-r--r-- | test/parser_test.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/parser_test.c b/test/parser_test.c index 12b2cac..1371453 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -268,6 +268,21 @@ test_parse_basic_syntax_errors(const MunitParameter params[], void *user_data_or assert_parser_error("fn main(): beff { return 42; }", "type 'beff' is not defined"); assert_parser_error("fn main(): i32 { return b; }", "identifier 'b' not defined"); assert_parser_error("fn main(): i32 { b = 1; return b; }", "trying to assign 'b' before defining it."); + assert_parser_error("fn main(): i32 { let b: bool = 3; return 1; }", + "incompatible types: expected 'bool', actual 'i32'."); + assert_parser_error("fn main(): i32 { let b: i32 = true; return 1; }", + "incompatible types: expected 'i32', actual 'bool'."); + assert_parser_error("fn main(): i32 { let b: i32 = 1; b = true; return 1; }", + "incompatible types: expected 'i32', actual 'bool'."); + assert_parser_error("fn main(): i32 { let b: bool = true; let c: i32 = b; return 1; }", + "incompatible types: expected 'i32', actual 'bool'."); + assert_parser_error("fn main(): i32 { let b: i32 = 1; let c: bool = b; return 1; }", + "incompatible types: expected 'bool', actual 'i32'."); + assert_parser_error("fn main(): i32 { let b: bool = 1; b = 42; return 1; }", + "incompatible types: expected 'bool', actual 'i32'."); + assert_parser_error("fn main(): i32 { return true; }", "incompatible types: expected 'i32', actual 'bool'."); + assert_parser_error("fn main(): i32 { let a: bool = true; return a; }", + "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 { oxi 42; }", "unexpected token 'TOKEN_NAME' value='oxi'"); |