Add am_append_arg procedure

This commit is contained in:
2025-08-10 19:44:05 +01:00
parent 6077cf571d
commit 624311d04f
3 changed files with 33 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
#include "am.h"
#include "unity.h"
#define CAR(expr) (expr->pair.car)
#define CDR(expr) (expr->pair.cdr)
static am_t am;
void setUp(void)
@@ -22,9 +25,27 @@ static void test_expr_value_restored_after_push_modify_pop(void)
TEST_ASSERT_EQUAL(&a, am.expr);
}
static void test_append_arg_42_with_empty_argl(void)
{
am.argl = expr_empty_list(&am);
am.val = expr_integer(&am, 42);
am_append_arg(&am);
TEST_ASSERT_FALSE(am.argl->is_atom);
TEST_ASSERT_NOT_NULL(CAR(am.argl));
TEST_ASSERT_TRUE(CAR(am.argl)->is_atom);
TEST_ASSERT_EQUAL(ATOM_TYPE_INTEGER, CAR(am.argl)->atom.type);
TEST_ASSERT_EQUAL(42, CAR(am.argl)->atom.integer);
TEST_ASSERT_TRUE(CDR(am.argl)->is_atom);
TEST_ASSERT_EQUAL(ATOM_TYPE_EMPTY_LIST, CDR(am.argl)->atom.type);
}
int main(void)
{
UNITY_BEGIN();
RUN_TEST(test_expr_value_restored_after_push_modify_pop);
RUN_TEST(test_append_arg_42_with_empty_argl);
return UNITY_END();
}