tmp
This commit is contained in:
parent
0494bf05af
commit
0b3f780ec7
2 changed files with 59 additions and 3 deletions
54
Objects/tests/TestCompiler.cpp
Normal file
54
Objects/tests/TestCompiler.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "compiler/function.h"
|
||||
#include "core/object.h"
|
||||
#include "interpreter/interpreter.h"
|
||||
#include "primitives/interpreterobject.h"
|
||||
#include "primitives/linkobject.h"
|
||||
#include "primitives/methodobject.h"
|
||||
|
||||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
TEST_DEF_STATIC(Basic) {
|
||||
{
|
||||
// no errors
|
||||
auto method = NDO_CAST(MethodObject, NDO->create("method"));
|
||||
|
||||
method->mScript->mReadable->val = "print 1 * 20 + 10;";
|
||||
method->compile();
|
||||
|
||||
NDO->destroy(method);
|
||||
|
||||
assertNoLeaks();
|
||||
}
|
||||
|
||||
{
|
||||
// with errors
|
||||
auto method = NDO_CAST(MethodObject, NDO->create("method"));
|
||||
|
||||
method->mScript->mReadable->val = "print undefinedVariable;";
|
||||
method->compile();
|
||||
|
||||
NDO->destroy(method);
|
||||
|
||||
assertNoLeaks();
|
||||
}
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(ErrorHandling) {
|
||||
Parser parser;
|
||||
|
||||
String stream = "var i = true; print (i + 1) * 10; invalidCharacter ";
|
||||
auto res = parser.parse(stream);
|
||||
|
||||
TEST(res.isError);
|
||||
|
||||
delete res.scope;
|
||||
}
|
||||
|
||||
TEST_DEF(Compiler) {
|
||||
testBasic();
|
||||
testErrorHandling();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue