From d3149a790f6eab811b0e22b4d14390761f4574f1 Mon Sep 17 00:00:00 2001 From: FelixBrendel Date: Fri, 15 Mar 2019 17:43:35 +0100 Subject: [PATCH] Make it easier to integrate test scripts --- src/testing.cpp | 39 +++++++++++++++++++++++---------------- todo.org | 11 ----------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/testing.cpp b/src/testing.cpp index b2ed2ba..62a809e 100644 --- a/src/testing.cpp +++ b/src/testing.cpp @@ -95,6 +95,24 @@ } \ } \ +#define invoke_test_script(name) \ + printf("" name ":"); \ + if (test_file("tests/" name ".slime") == pass) { \ + for(size_t i = strlen(name); i < 70; ++i) \ + printf((i%3==1)? "." : " "); \ + printf("%spassed%s\n", console_green, console_normal); \ + } \ + else { \ + result = false; \ + for(int i = -1; i < 70; ++i) \ + printf((i%3==1)? "." : " "); \ + printf("%sfailed%s\n", console_red, console_normal); \ + if(error) { \ + free(error); \ + error = nullptr; \ + } \ + } + proc test_eval_operands() -> testresult { char operands_string[] = "((eval 1) (+ 1 2) \"okay\" (eval :haha))"; Lisp_Object* operands = Parser::parse_single_expression(operands_string); @@ -460,26 +478,14 @@ proc test_singular_t_and_nil() -> testresult { return pass; } -proc test_class_macro() -> testresult { +proc test_file(char* file) -> testresult { Memory::reset(); Environment* env = Memory::create_built_ins_environment(); - Parser::init(env); - - built_in_load(Memory::create_string("pre.slime"), env); - Lisp_Object* result = built_in_load(Memory::create_string("tests/class_macro.slime"), env); - - assert_no_error(); - return pass; -} - -proc test_lexical_scope() -> testresult { - Memory::reset(); - Environment* env = Memory::create_built_ins_environment(); Parser::init(env); built_in_load(Memory::create_string("pre.slime"), env); - Lisp_Object* result = built_in_load(Memory::create_string("tests/lexical_scope.slime"), env); + Lisp_Object* result = built_in_load(Memory::create_string(file), env); assert_no_error(); return pass; @@ -521,8 +527,9 @@ proc run_all_tests() -> bool { printf("\n-- Macros --\n"); printf("\n-- Test Files --\n"); - invoke_test(test_class_macro); - invoke_test(test_lexical_scope); + + invoke_test_script("lexical_scope"); + invoke_test_script("class_macro"); return result; } diff --git a/todo.org b/todo.org index 85d6b22..044bb9d 100644 --- a/todo.org +++ b/todo.org @@ -13,14 +13,3 @@ ;; should output 6 ;; outputs 0 #+END_SRC -* SSO - -#+begin_src c -Symbol* symbol; // { String* identifier } -Keyword* keyword; // { String* identifier } -Number* number; // { double value } -String* string; // has to stay a pointer -Pair* pair; // { Lisp_Object* first; Lisp_Object* rest } -Function* function; // -cFunction* cFunction; // has to stay a pointer -#+end_src