Browse Source

fixes?

master
Gabriel Pariat 3 years ago
parent
commit
aa34ca8c68
  1. 2
      implementations/c/src/environment.c
  2. 2
      implementations/c/src/evaluator.c
  3. 1
      implementations/c/src/main.c
  4. 1
      implementations/c/src/table.c
  5. 2
      implementations/c/tests/check_ptlisp.log
  6. 4
      implementations/c/tests/evaluator-test.c
  7. 12
      implementations/c/tests/reader-test.c

2
implementations/c/src/environment.c

@ -28,5 +28,5 @@ Pointer environment_set(Pointer env, Pointer key, Pointer value) {
} }
void environment_init(void) { void environment_init(void) {
GLOBALS = table(0); GLOBALS = table(1);
} }

2
implementations/c/src/evaluator.c

@ -7,7 +7,7 @@ static Pointer run_fn(Func fn, Pointer params) {
/* print(args, stderr); */ /* print(args, stderr); */
Pointer env = fn.env; Pointer env = fn.env;
Pointer value = NIL; Pointer value = NIL;
Pointer tbl = table(2); Pointer tbl = table(1);
env = cons(tbl, env); env = cons(tbl, env);
while(args != NIL && params != NIL) { while(args != NIL && params != NIL) {

1
implementations/c/src/main.c

@ -3,6 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
int main() { int main() {
printf("PTLISP: \n");
init(); init();
repl(); repl();
return 0; return 0;

1
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); pointer = memory_resize(pointer, sizeof(Table) + table->size * sizeof(TableData) * 2);
table = &TABLE(pointer); table = &TABLE(pointer);
// Move data at the end of the new data section. // Move data at the end of the new data section.
for (unsigned j = table->length; j < table->size; j++) { for (unsigned j = table->length; j < table->size; j++) {
table->data[j + table->size] = table->data[j]; table->data[j + table->size] = table->data[j];

2
implementations/c/tests/check_ptlisp.log

@ -9,5 +9,5 @@ Running suite(s): Memory
Lisp Lisp
Reader Reader
Printer Printer
100%: Checks: 87, Failures: 0, Errors: 0 100%: Checks: 85, Failures: 0, Errors: 0
PASS check_ptlisp (exit status: 0) PASS check_ptlisp (exit status: 0)

4
implementations/c/tests/evaluator-test.c

@ -8,8 +8,8 @@ END_TEST
START_TEST(eval_number_test) { START_TEST(eval_number_test) {
Pointer num = number(69); Pointer num = number(69);
ck_assert_uint_eq(eval_fn(num, NIL), num); ck_assert_uint_eq(eval(num, NIL), num);
ck_assert_double_eq(NUMBER(eval_fn(num, NIL)), 69); ck_assert_double_eq(NUMBER(eval(num, NIL)), 69);
} }
END_TEST END_TEST

12
implementations/c/tests/reader-test.c

@ -45,16 +45,6 @@ START_TEST(read_fn_test) {
fclose(s); fclose(s);
} END_TEST } 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) { START_TEST(read_char_macro_fn_test) {
FILE* s; 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, peek_char_fn_test);
tcase_add_test(tc1_1, read_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, 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_char_macro_fn_test);
tcase_add_test(tc1_1, read_list_macro_fn_test); tcase_add_test(tc1_1, read_list_macro_fn_test);
tcase_add_test(tc1_1, read_right_paren_macro_fn_test); tcase_add_test(tc1_1, read_right_paren_macro_fn_test);

Loading…
Cancel
Save