Handle argument evaluation

This commit is contained in:
2025-08-10 19:54:09 +01:00
parent 624311d04f
commit 662b99a40f
3 changed files with 48 additions and 2 deletions

View File

@@ -88,6 +88,31 @@ static void test_add_1_2_3_evals_to_6(void)
TEST_ASSERT_EQUAL(6, am.val->atom.integer);
}
static void test_add_1_mul_2_3_evals_to_7(void)
{
am.expr = expr_pair(
&am, expr_str_symbol(&am, "+"),
expr_pair(
&am, expr_integer(&am, 1),
expr_pair(
&am,
expr_pair(
&am, expr_str_symbol(&am, "*"),
expr_pair(
&am, expr_integer(&am, 2),
expr_pair(
&am, expr_integer(&am, 3),
expr_empty_list(&am)))),
expr_empty_list(&am))));
eval(&am);
TEST_ASSERT_NOT_NULL(am.val);
TEST_ASSERT_TRUE(am.val->is_atom);
TEST_ASSERT_EQUAL(ATOM_TYPE_INTEGER, am.val->atom.type);
TEST_ASSERT_EQUAL(7, am.val->atom.integer);
}
int main(void)
{
UNITY_BEGIN();
@@ -96,5 +121,6 @@ int main(void)
RUN_TEST(test_prim_proc_self_evals);
RUN_TEST(test_foo_evals_to_42_when_set_in_env);
RUN_TEST(test_add_1_2_3_evals_to_6);
RUN_TEST(test_add_1_mul_2_3_evals_to_7);
return UNITY_END();
}