Implement primitive procedure application evaluation

This commit is contained in:
2025-08-10 16:33:16 +01:00
parent d8e51b0aa0
commit d5173243ba
2 changed files with 44 additions and 2 deletions

View File

@@ -69,6 +69,25 @@ static void test_foo_evals_to_42_when_set_in_env(void)
TEST_ASSERT_EQUAL(42, am.val->atom.integer);
}
static void test_add_1_2_3_evals_to_6(void)
{
am.expr = expr_pair(
&am, expr_str_symbol(&am, "+"),
expr_pair(
&am, expr_integer(&am, 1),
expr_pair(
&am, expr_integer(&am, 2),
expr_pair(
&am, expr_integer(&am, 3), 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(6, am.val->atom.integer);
}
int main(void)
{
UNITY_BEGIN();
@@ -76,5 +95,6 @@ int main(void)
RUN_TEST(test_empty_list_self_evals);
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);
return UNITY_END();
}