summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-04-30 03:11:00 -0300
committerJohnny Richard <johnny@johnnyrichard.com>2023-04-30 17:40:01 +0200
commitb1f7b0cccc6986ca107d9eeb1c7d5e5e5a32dc49 (patch)
treefb1eb8192c3f6da14796d59831030dd23935edcd /test
parent090da456910429708ef7ee202b627e3dbce17819 (diff)
gas: Compile variable expression with scope support
This patch adds the variable compilation and uses a scope (a stack of map) to lookup for identities. Today we use a vector + ref_entry structs in order to achieve the scope implementation. The ref_entry lacks memory management, we are still no sure who will be the owner of the pointer. We also want to replace the scope a hashtable_t type as soon as we get one. Signed-off-by: Johnny Richard <johnny@johnnyrichard.com> Co-authored-by: Carlos Maniero <carlosmaniero@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/integration_test.c1
-rw-r--r--test/parser_test.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/test/integration_test.c b/test/integration_test.c
index 739a938..4178b42 100644
--- a/test/integration_test.c
+++ b/test/integration_test.c
@@ -42,6 +42,7 @@ test_examples(const MunitParameter params[], void *user_data_or_fixture)
{
assert_exit_status("../examples/main.pipa", 69);
assert_exit_status("../examples/arithmetics.pipa", 13);
+ assert_exit_status("../examples/variables.pipa", 28);
return MUNIT_OK;
}
diff --git a/test/parser_test.c b/test/parser_test.c
index d534509..5d615ec 100644
--- a/test/parser_test.c
+++ b/test/parser_test.c
@@ -126,8 +126,8 @@ test_parse_variable_definition(const MunitParameter params[], void *user_data_or
ast_node_t *ast_literal = ast_return->data.return_stmt.argument;
- assert_int(AST_IDENTIFIER, ==, ast_literal->kind);
- assert_string_view_equal("variable", ast_literal->data.identifier.name);
+ assert_int(AST_VARIABLE, ==, ast_literal->kind);
+ assert_string_view_equal("variable", ast_literal->data.variable.identifier->name);
ast_node_destroy(ast_function);
scope_destroy(scope);