Skip to content

Commit

Permalink
fix: CA function unary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimosinger authored Sep 15, 2022
1 parent 71d85d3 commit 6cc773f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ca_function_unary_operator::resolve_expression_tree(ca_expression_ctx expr_
expr_kind = expr_ctx.kind;
m_expr_ctx = expr_ctx;
expr_ctx.kind = ca_common_expr_policy::get_operands_type(function, expr_ctx.kind);
expr->resolve_expression_tree(m_expr_ctx, diags);
expr->resolve_expression_tree(expr_ctx, diags);
}

context::SET_t ca_function_unary_operator::operation(context::SET_t operand, const evaluation_context& eval_ctx) const
Expand Down
31 changes: 30 additions & 1 deletion parser_library/test/expressions/character_expression_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,33 @@ TEST(character_expression, invalid_expression)
//
// EXPECT_TRUE(a.diags().empty());
// EXPECT_EQ(get_var_value<C_t>(a.hlasm_ctx(), "C"), "VENFG");
//}
//}

TEST(character_expression, valid_function)
{
std::string input =
R"(
&A SETA 210
&C SETC (BYTE &A)
)";
analyzer a(input);
a.analyze();
a.collect_diags();

EXPECT_TRUE(a.diags().empty());
EXPECT_EQ(get_var_value<C_t>(a.hlasm_ctx(), "C"), "K");
}

TEST(character_expression, invalid_function)
{
std::string input =
R"(
&A SETC 'X'
&C SETC (BYTE &A)
)";
analyzer a(input);
a.analyze();
a.collect_diags();

EXPECT_TRUE(matches_message_codes(a.diags(), { "CE012" }));
}

0 comments on commit 6cc773f

Please sign in to comment.