diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..89e3480 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +CC=gcc +objects= stack.o method_dispatcher/method_dispatcher.o interpreter/core_methods.o interpreter/interpreter.o + +all: $(objects) test + +CFLAG= -c -O -o + +%.o: %.c + $(CC) $(CFLAG) $@ $< + +.PHONY: test + +test: + cd test && make + cd method_dispatcher/test && make + cd interpreter/test && make diff --git a/interpreter/test/test_interpreter.c b/interpreter/test/test_interpreter.c index 5793f0c..62db833 100644 --- a/interpreter/test/test_interpreter.c +++ b/interpreter/test/test_interpreter.c @@ -1,5 +1,6 @@ #include #include +#include #include "../interpreter.h" #include "../core_methods.h" #include "../../method_dispatcher/method_dispatcher.h" @@ -39,9 +40,13 @@ int main(void) machine_state_t_exec_cycle(state); machine_state_t_exec_cycle(state); printf("data_reg[0]: %x\n", state->data_reg[0]); + assert(state->data_reg[0] == 0xfefe); printf("data_reg[1]: %x\n", state->data_reg[1]); + assert(state->data_reg[1] == 5); printf("data_reg[2]: %x\n", state->data_reg[2]); + assert(state->data_reg[2] == 3); printf("program_counter: %d\n", state->program_counter); + assert(state->program_counter == 8); dispatch_tree_autoinserter_t_del(inserter); machine_state_t_del(state); free(program); diff --git a/test/test_stack.c b/test/test_stack.c index 05fecc1..328c35c 100644 --- a/test/test_stack.c +++ b/test/test_stack.c @@ -1,5 +1,6 @@ #include #include "../stack.h" +#include int main(void) { @@ -13,10 +14,14 @@ int main(void) { bci_stack_t_push(&stack, (uint16_t) i); } + --i; while(!status) { status = bci_stack_t_pop(&stack, &res); - printf("%d\n", res); + if(!status) + { + assert(res == i--); + } }