summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-05-01 01:57:22 +0200
committerCarlos Maniero <carlos@maniero.me>2023-05-01 18:24:42 -0300
commite3d8e031c6f20c68f2227028ee8b3e73cd9b8161 (patch)
tree52068df5df3fea73eea9e5af311b03771a0f614a /test
parent8c56ddf0b640b8880eb5b97e5ca1b787585c29c0 (diff)
parser: Implement variable assignment
This commit introduces variable assignment making it possible to change a variable value. Example: myvar: i32 = 1; myvar = 2; Signed-off-by: Johnny Richard <johnny@johnnyrichard.com> Co-authored-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'test')
-rw-r--r--test/parser_test.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/parser_test.c b/test/parser_test.c
index 5d615ec..8f75e07 100644
--- a/test/parser_test.c
+++ b/test/parser_test.c
@@ -220,9 +220,10 @@ test_parse_basic_syntax_errors(const MunitParameter params[], void *user_data_or
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 { return b; }", "identifier 'b' not defined");
+ assert_parser_error("main(): i32 { b = 1; return b; }", "trying to assign 'b' before defining it.");
// FIXME: once function calls are implemented, this error should inform that
// neither a variable or function call was found.
- assert_parser_error("main(): i32 { oxi 42; }", "expected ':' but got 'TOKEN_NUMBER'");
+ assert_parser_error("main(): i32 { oxi 42; }", "expected 'TOKEN_NAME' but got 'TOKEN_NUMBER'");
return MUNIT_OK;
}