Add seemingly functional but hacky gc

This commit is contained in:
2022-11-14 22:43:49 -05:00
parent fbc1055659
commit 706b4a586d
9 changed files with 120 additions and 18 deletions

View File

@@ -37,7 +37,8 @@ void tearDown(void) {
// TODO: Implement GC so we can clean these both up
//ucl_object_delete(input);
input = NULL;
ucl_object_delete(response);
ucl_state_delete(state);
ucl_gc();
response = NULL;
state = NULL;
}
@@ -150,15 +151,15 @@ void test_call_function(void) {
}
void test_setq(void) {
response = eval("(setq bar 2)");
response = eval("(setq bar 123)");
TEST_ASSERT_OBJ_INT(response);
TEST_ASSERT_EQUAL(response->symbol, 2);
TEST_ASSERT_EQUAL(response->symbol, 123);
response = eval("bar");
TEST_ASSERT_OBJ_INT(response);
TEST_ASSERT_EQUAL(response->symbol, 2);
TEST_ASSERT_EQUAL(response->symbol, 123);
}
void test_setq_from_function(void) {
@@ -238,6 +239,20 @@ void test_nth_oob(void) {
TEST_ASSERT_OBJ_ERROR(response);
}
void test_eval_defun_gc(void) {
response = eval("(defun foo (a b) (+ a b))");
TEST_ASSERT_OBJ_SYMBOL(response);
TEST_ASSERT_EQUAL_STRING(response->symbol, "foo");
ucl_gc();
response = eval("(foo 10 15)");
TEST_ASSERT_OBJ_INT(response);
TEST_ASSERT_EQUAL(response->integer, 25);
}
int main(void) {
UNITY_BEGIN();
@@ -266,7 +281,7 @@ int main(void) {
RUN_TEST(test_nth_0);
RUN_TEST(test_nth_1);
RUN_TEST(test_nth_oob);
RUN_TEST(test_eval_defun_gc);
return UNITY_END();
}