Add store into abstract machine struct

This commit is contained in:
2025-08-10 15:21:24 +01:00
parent b20a6749f7
commit d8e51b0aa0
18 changed files with 129 additions and 141 deletions

View File

@@ -4,13 +4,10 @@
#include <string.h>
static am_t am;
static store_t store;
void setUp(void)
{
am_init(&am);
store_init(&store);
env_init(&am, &store);
}
void tearDown(void)
@@ -19,11 +16,11 @@ void tearDown(void)
static void test_set_foo_to_42_then_fetch(void)
{
am.expr = expr_str_symbol(&store, "foo");
am.val = expr_integer(&store, 42);
env_set(&am, &store);
am.expr = expr_str_symbol(&am, "foo");
am.val = expr_integer(&am, 42);
env_set(&am);
am.expr = expr_str_symbol(&store, "foo");
am.expr = expr_str_symbol(&am, "foo");
am.val = NULL;
env_fetch(&am);
@@ -35,13 +32,13 @@ static void test_set_foo_to_42_then_fetch(void)
static void test_update_foo_from_123_to_456_then_fetch(void)
{
am.expr = expr_str_symbol(&store, "foo");
am.val = expr_integer(&store, 123);
env_set(&am, &store);
am.val = expr_integer(&store, 456);
env_set(&am, &store);
am.expr = expr_str_symbol(&am, "foo");
am.val = expr_integer(&am, 123);
env_set(&am);
am.val = expr_integer(&am, 456);
env_set(&am);
am.expr = expr_str_symbol(&store, "foo");
am.expr = expr_str_symbol(&am, "foo");
am.val = NULL;
env_fetch(&am);