From b56829ea26ad9343f4a74df24c0ecb7f74a1cb0a Mon Sep 17 00:00:00 2001 From: Ilusha <63184036+IlyaShurupov@users.noreply.github.com> Date: Thu, 14 Mar 2024 08:00:35 +0300 Subject: [PATCH] tmp --- Objects/tests/ObjectTests.hpp | 6 ++++++ Objects/tests/TestCompiler.cpp | 9 ++++++--- Objects/tests/TestCore.cpp | 9 +++++++-- Objects/tests/TestInterpreter.cpp | 15 ++++++++++----- Objects/tests/TestParser.cpp | 11 ++++++++--- Objects/tests/TestPrimitives.cpp | 9 +++++++-- Objects/tests/Tests.cpp | 23 ++++++++--------------- Utils/private/Testing.cpp | 2 -- 8 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 Objects/tests/ObjectTests.hpp diff --git a/Objects/tests/ObjectTests.hpp b/Objects/tests/ObjectTests.hpp new file mode 100644 index 0000000..3ba521e --- /dev/null +++ b/Objects/tests/ObjectTests.hpp @@ -0,0 +1,6 @@ + +#include "Testing.hpp" + +#include "primitives/primitives.h" + +extern tp::ModuleManifest objTestModule; \ No newline at end of file diff --git a/Objects/tests/TestCompiler.cpp b/Objects/tests/TestCompiler.cpp index c390cbb..923c24c 100644 --- a/Objects/tests/TestCompiler.cpp +++ b/Objects/tests/TestCompiler.cpp @@ -1,5 +1,5 @@ -#include "Testing.hpp" +#include "ObjectTests.hpp" #include "compiler/function.h" #include "core/object.h" @@ -49,6 +49,9 @@ TEST_DEF_STATIC(ErrorHandling) { } TEST_DEF(Compiler) { - testBasic(); - testErrorHandling(); + if (objTestModule.initialize()) { + testBasic(); + testErrorHandling(); + objTestModule.deinitialize(); + } } diff --git a/Objects/tests/TestCore.cpp b/Objects/tests/TestCore.cpp index d7a815b..77f9eb1 100644 --- a/Objects/tests/TestCore.cpp +++ b/Objects/tests/TestCore.cpp @@ -1,5 +1,5 @@ -#include "Testing.hpp" +#include "ObjectTests.hpp" #include "core/object.h" @@ -28,4 +28,9 @@ TEST_DEF_STATIC(BasicAPI) { NDO->destroy(savedInt); } -TEST_DEF(Core) { testBasicAPI(); } +TEST_DEF(Core) { + if (objTestModule.initialize()) { + testBasicAPI(); + objTestModule.deinitialize(); + } +} diff --git a/Objects/tests/TestInterpreter.cpp b/Objects/tests/TestInterpreter.cpp index 6657923..18c9c0a 100644 --- a/Objects/tests/TestInterpreter.cpp +++ b/Objects/tests/TestInterpreter.cpp @@ -1,5 +1,5 @@ -#include "Testing.hpp" +#include "ObjectTests.hpp" #include "compiler/function.h" #include "core/object.h" @@ -135,8 +135,13 @@ TEST_DEF_STATIC(Complex) { } TEST_DEF(Interpreter) { - testEntry(); - testSimple(); - testSimpleSave(); - // testComplex(); + if (objTestModule.initialize()) { + + testEntry(); + testSimple(); + testSimpleSave(); + // testComplex(); + + objTestModule.deinitialize(); + } } diff --git a/Objects/tests/TestParser.cpp b/Objects/tests/TestParser.cpp index 0e34890..3324853 100644 --- a/Objects/tests/TestParser.cpp +++ b/Objects/tests/TestParser.cpp @@ -1,5 +1,5 @@ -#include "Testing.hpp" +#include "ObjectTests.hpp" #include "parser/parser.h" @@ -53,6 +53,11 @@ TEST_DEF_STATIC(ErrorHandling) { } TEST_DEF(Parser) { - testBasic(); - testErrorHandling(); + if (objTestModule.initialize()) { + + testBasic(); + testErrorHandling(); + + objTestModule.deinitialize(); + } } diff --git a/Objects/tests/TestPrimitives.cpp b/Objects/tests/TestPrimitives.cpp index 6c2927e..111a1aa 100644 --- a/Objects/tests/TestPrimitives.cpp +++ b/Objects/tests/TestPrimitives.cpp @@ -1,5 +1,5 @@ -#include "Testing.hpp" +#include "ObjectTests.hpp" #include "compiler/function.h" #include "core/object.h" @@ -30,4 +30,9 @@ TEST_DEF_STATIC(Dict) { NDO->destroy(dictLoaded); } -TEST_DEF(Primitives) { testDict(); } +TEST_DEF(Primitives) { + if (objTestModule.initialize()) { + testDict(); + objTestModule.deinitialize(); + } +} diff --git a/Objects/tests/Tests.cpp b/Objects/tests/Tests.cpp index 5e84561..b04ba04 100644 --- a/Objects/tests/Tests.cpp +++ b/Objects/tests/Tests.cpp @@ -1,7 +1,5 @@ -#include "Testing.hpp" - -#include "primitives/primitives.h" +#include "ObjectTests.hpp" using namespace tp; using namespace obj; @@ -11,20 +9,15 @@ void testCore(); void testPrimitives(); void testInterpreter(); +tp::ModuleManifest* objDeps[] = { &gModuleObjects, nullptr }; +tp::ModuleManifest objTestModule("ObjectsTests", nullptr, nullptr, objDeps); + int main() { - tp::ModuleManifest* deps[] = { &gModuleObjects, nullptr }; - tp::ModuleManifest module("ObjectsTests", nullptr, nullptr, deps); - - if (module.initialize()) { - - testParser(); - testCore(); - testPrimitives(); - testInterpreter(); - - module.deinitialize(); - } + testParser(); + testCore(); + testPrimitives(); + testInterpreter(); return 0; } diff --git a/Utils/private/Testing.cpp b/Utils/private/Testing.cpp index 2f156e3..2135953 100644 --- a/Utils/private/Testing.cpp +++ b/Utils/private/Testing.cpp @@ -10,7 +10,6 @@ using namespace tp; Testing tp::gTesting; void Testing::startTest(const char* name) { - MODULE_SANITY_CHECK(gModuleUtils) auto newNode = new (malloc(sizeof(TestingNode))) TestingNode{ {}, {}, name, mCurrent }; mCurrent->mSubTests.pushBack(newNode); mCurrent = mCurrent->mSubTests.last()->data; @@ -23,7 +22,6 @@ void Testing::endTest() { } void Testing::addFailedCheck(const FailedCheck& info) { - DEBUG_BREAK(0 && info.expression); auto lastRecord = &mCurrent->mFailedChecks.last()->data; if (lastRecord && lastRecord->failedCheck.file == info.file && lastRecord->failedCheck.line == info.line) { lastRecord->times++;