diff options
author | Carlos Maniero <carlosmaniero@gmail.com> | 2023-04-26 01:57:42 -0300 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-26 09:11:47 +0200 |
commit | cd77ac7997fa956c1d67ef91cde056e817aa16c7 (patch) | |
tree | f42ab962e225a90507a25d253d39d94095739cc9 /test/parser_test.c | |
parent | dddec15f6ac62311b4980f0de9e6893da00481ae (diff) |
ast: Include a Binary Operation kind enum
The AST was using a string view to distinguish the operation kind. An
enum was created for this purpose simplifying code generation.
Signed-off-by: Carlos Maniero <carlosmaniero@gmail.com>
Reviewed-by: Johnny Richard <johnny@johnnyrichar.com>
Diffstat (limited to 'test/parser_test.c')
-rw-r--r-- | test/parser_test.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/parser_test.c b/test/parser_test.c index d8aee07..251054d 100644 --- a/test/parser_test.c +++ b/test/parser_test.c @@ -145,13 +145,14 @@ test_parse_arithmetic_expression(const MunitParameter params[], void *user_data_ { assert_int(AST_BINARY_OPERATION, ==, exp1->kind); - assert_string_view_equal("-", exp1->data.binary_operation.op); + assert_int(AST_BINARY_OPERATION, ==, exp1->kind); + assert_int(AST_BINOP_SUBTRACTION, ==, exp1->data.binary_operation.kind); ast_node_t *exp2 = exp1->data.binary_operation.left; { assert_int(AST_BINARY_OPERATION, ==, exp2->kind); - assert_string_view_equal("+", exp2->data.binary_operation.op); + assert_int(AST_BINOP_ADITION, ==, exp2->data.binary_operation.kind); assert_int(AST_LITERAL, ==, exp2->data.binary_operation.left->kind); assert_int(exp2->data.binary_operation.left->data.literal.value.integer, ==, 1); @@ -160,12 +161,12 @@ test_parse_arithmetic_expression(const MunitParameter params[], void *user_data_ { assert_int(AST_BINARY_OPERATION, ==, exp3->kind); - assert_string_view_equal("/", exp3->data.binary_operation.op); + assert_int(AST_BINOP_DIVISION, ==, exp3->data.binary_operation.kind); ast_node_t *exp4 = exp3->data.binary_operation.left; { assert_int(AST_BINARY_OPERATION, ==, exp4->kind); - assert_string_view_equal("*", exp4->data.binary_operation.op); + assert_int(AST_BINOP_MULTIPLICATION, ==, exp4->data.binary_operation.kind); assert_int(AST_LITERAL, ==, exp4->data.binary_operation.left->kind); assert_int(exp4->data.binary_operation.left->data.literal.value.integer, ==, 3); |