Add Interpreter tests and improve Parser error logging
A set of tests for the InterpreterObject has been added to enhance its reliability and maintainability. The tests check the essential functionalities such as its creation, execution, saving, loading, and destruction. Furthermore, the error logging for the Parser has been improved, now providing more precise location of detected errors. The changes improve the robustness and debugability of the code.
This commit is contained in:
parent
0cefb47b66
commit
b06e1da529
3 changed files with 44 additions and 1 deletions
40
Objects/tests/interpreter/TestInterpreter.cpp
Normal file
40
Objects/tests/interpreter/TestInterpreter.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "core/object.h"
|
||||
#include "primitives/methodobject.h"
|
||||
#include "primitives/interpreterobject.h"
|
||||
#include "primitives/linkobject.h"
|
||||
#include "compiler/function.h"
|
||||
#include "interpreter/interpreter.h"
|
||||
|
||||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
TEST_DEF_STATIC(Simple) {
|
||||
|
||||
auto method = NDO_CAST(MethodObject, NDO->create("method"));
|
||||
auto interpreter = NDO_CAST(InterpreterObject, NDO->create("interpreter"));
|
||||
|
||||
interpreter->getMember<LinkObject>("target method")->setLink(method);
|
||||
|
||||
method->mScript->mReadable->val = "<< 3;";
|
||||
method->compile();
|
||||
|
||||
interpreter->exec();
|
||||
|
||||
NDO->save(interpreter, "interp.o");
|
||||
|
||||
auto interpreterLoaded = NDO_CAST(InterpreterObject, NDO->load("interp.o"));
|
||||
|
||||
interpreterLoaded->exec();
|
||||
|
||||
NDO->destroy(interpreter);
|
||||
NDO->destroy(interpreterLoaded);
|
||||
}
|
||||
|
||||
TEST_DEF(Interpreter) {
|
||||
testSimple();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue