From aa34ca8c68e897a6bfd71670550a11b8e34d6a14 Mon Sep 17 00:00:00 2001 From: Gabriel Pariat Date: Mon, 21 Feb 2022 08:53:02 -0500 Subject: [PATCH] fixes? --- implementations/c/src/environment.c | 2 +- implementations/c/src/evaluator.c | 2 +- implementations/c/src/main.c | 1 + implementations/c/src/table.c | 1 - implementations/c/tests/check_ptlisp.log | 2 +- implementations/c/tests/evaluator-test.c | 4 ++-- implementations/c/tests/reader-test.c | 12 ------------ 7 files changed, 6 insertions(+), 18 deletions(-) diff --git a/implementations/c/src/environment.c b/implementations/c/src/environment.c index 07fa61b..2fe1bc2 100644 --- a/implementations/c/src/environment.c +++ b/implementations/c/src/environment.c @@ -28,5 +28,5 @@ Pointer environment_set(Pointer env, Pointer key, Pointer value) { } void environment_init(void) { - GLOBALS = table(0); + GLOBALS = table(1); } diff --git a/implementations/c/src/evaluator.c b/implementations/c/src/evaluator.c index 66552ca..677c038 100644 --- a/implementations/c/src/evaluator.c +++ b/implementations/c/src/evaluator.c @@ -7,7 +7,7 @@ static Pointer run_fn(Func fn, Pointer params) { /* print(args, stderr); */ Pointer env = fn.env; Pointer value = NIL; - Pointer tbl = table(2); + Pointer tbl = table(1); env = cons(tbl, env); while(args != NIL && params != NIL) { diff --git a/implementations/c/src/main.c b/implementations/c/src/main.c index da1f976..a32a1a0 100644 --- a/implementations/c/src/main.c +++ b/implementations/c/src/main.c @@ -3,6 +3,7 @@ #include int main() { + printf("PTLISP: \n"); init(); repl(); return 0; diff --git a/implementations/c/src/table.c b/implementations/c/src/table.c index 44741cb..38901ce 100644 --- a/implementations/c/src/table.c +++ b/implementations/c/src/table.c @@ -72,7 +72,6 @@ Pointer table_set(Pointer pointer, Pointer key, Pointer value) { pointer = memory_resize(pointer, sizeof(Table) + table->size * sizeof(TableData) * 2); table = &TABLE(pointer); - // Move data at the end of the new data section. for (unsigned j = table->length; j < table->size; j++) { table->data[j + table->size] = table->data[j]; diff --git a/implementations/c/tests/check_ptlisp.log b/implementations/c/tests/check_ptlisp.log index 7673696..81b08bf 100644 --- a/implementations/c/tests/check_ptlisp.log +++ b/implementations/c/tests/check_ptlisp.log @@ -9,5 +9,5 @@ Running suite(s): Memory Lisp Reader Printer -100%: Checks: 87, Failures: 0, Errors: 0 +100%: Checks: 85, Failures: 0, Errors: 0 PASS check_ptlisp (exit status: 0) diff --git a/implementations/c/tests/evaluator-test.c b/implementations/c/tests/evaluator-test.c index f6acd7c..125b172 100644 --- a/implementations/c/tests/evaluator-test.c +++ b/implementations/c/tests/evaluator-test.c @@ -8,8 +8,8 @@ END_TEST START_TEST(eval_number_test) { Pointer num = number(69); - ck_assert_uint_eq(eval_fn(num, NIL), num); - ck_assert_double_eq(NUMBER(eval_fn(num, NIL)), 69); + ck_assert_uint_eq(eval(num, NIL), num); + ck_assert_double_eq(NUMBER(eval(num, NIL)), 69); } END_TEST diff --git a/implementations/c/tests/reader-test.c b/implementations/c/tests/reader-test.c index 59dea7f..e2e20ad 100644 --- a/implementations/c/tests/reader-test.c +++ b/implementations/c/tests/reader-test.c @@ -45,16 +45,6 @@ START_TEST(read_fn_test) { fclose(s); } END_TEST -START_TEST(set_reader_macro_test) { - ck_assert_uint_eq(set_reader_macro(69, 420), T); - /* ck_assert_uint_eq(table_get(READTABLE, 69), 420); */ -} END_TEST - -START_TEST(set_reader_macro_fn_test) { - ck_assert_uint_eq(set_reader_macro_fn(LIST(69, 420), NIL), T); - /* ck_assert_uint_eq(table_get(READTABLE, 69), 420); */ -} END_TEST - START_TEST(read_char_macro_fn_test) { FILE* s; @@ -142,8 +132,6 @@ Suite* make_reader_test_suite(void) { tcase_add_test(tc1_1, peek_char_fn_test); tcase_add_test(tc1_1, read_char_fn_test); tcase_add_test(tc1_1, read_fn_test); - tcase_add_test(tc1_1, set_reader_macro_test); - tcase_add_test(tc1_1, set_reader_macro_fn_test); tcase_add_test(tc1_1, read_char_macro_fn_test); tcase_add_test(tc1_1, read_list_macro_fn_test); tcase_add_test(tc1_1, read_right_paren_macro_fn_test);