Fixing lalr on windows
This commit is contained in:
parent
ffafeba6c2
commit
afe32d6014
15 changed files with 1276 additions and 1226 deletions
|
|
@ -44,7 +44,7 @@ auto script = R"(
|
|||
print false;
|
||||
)";
|
||||
|
||||
TEST_DEF_STATIC(Simple) {
|
||||
TEST_DEF_STATIC(Entry) {
|
||||
auto method = NDO_CAST(MethodObject, NDO->create("method"));
|
||||
auto interpreter = NDO_CAST(InterpreterObject, NDO->create("interpreter"));
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ TEST_DEF_STATIC(Simple) {
|
|||
|
||||
NDO->destroy(interpreter);
|
||||
|
||||
printf("\n\nEnd\n\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(SimpleSave) {
|
||||
|
|
@ -80,7 +80,42 @@ TEST_DEF_STATIC(SimpleSave) {
|
|||
NDO->destroy(interpreterLoaded);
|
||||
NDO->destroy(interpreter);
|
||||
|
||||
printf("\n\nEnd\n\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(Simple) {
|
||||
auto compileStartCount = getObjCount();
|
||||
|
||||
auto method = NDO_CAST(MethodObject, NDO->create("method"));
|
||||
auto interpreter = NDO_CAST(InterpreterObject, NDO->create("interpreter"));
|
||||
|
||||
interpreter->getMember<LinkObject>("target method")->setLink(method);
|
||||
|
||||
auto exec = [&](const char* script){
|
||||
method->mScript->mReadable->val = script;
|
||||
method->compile();
|
||||
|
||||
auto startCount = getObjCount();
|
||||
interpreter->exec();
|
||||
|
||||
if (getObjCount() != startCount) {
|
||||
TEST(false && "Mem leaks in interpreter");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
};
|
||||
|
||||
exec("10 + 15;");
|
||||
exec("print 10 + 15;");
|
||||
exec("print (10 + 15) * 20;");
|
||||
exec("var k : int;");
|
||||
exec("var k : int; print k;");
|
||||
|
||||
NDO->destroy(interpreter);
|
||||
|
||||
if (getObjCount() != compileStartCount) {
|
||||
TEST(false && "Mem leaks in compiler and interpreter");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(Complex) {
|
||||
|
|
@ -98,7 +133,8 @@ TEST_DEF_STATIC(Complex) {
|
|||
}
|
||||
|
||||
TEST_DEF(Interpreter) {
|
||||
testSimple();
|
||||
testEntry();
|
||||
// testSimple();
|
||||
testSimpleSave();
|
||||
// testComplex();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,38 @@ using namespace tp;
|
|||
using namespace obj;
|
||||
|
||||
TEST_DEF_STATIC(Basic) {
|
||||
Parser parser;
|
||||
{
|
||||
Parser parser;
|
||||
|
||||
String stream = "var i = true; print (i + 1) * 10;";
|
||||
auto res = parser.parse(stream);
|
||||
String stream = "";
|
||||
auto res = parser.parse(stream);
|
||||
|
||||
TEST(!res.isError);
|
||||
TEST(!res.isError);
|
||||
|
||||
delete res.scope;
|
||||
delete res.scope;
|
||||
}
|
||||
|
||||
{
|
||||
Parser parser;
|
||||
|
||||
String stream = "var i = true;";
|
||||
auto res = parser.parse(stream);
|
||||
|
||||
TEST(!res.isError);
|
||||
|
||||
delete res.scope;
|
||||
}
|
||||
|
||||
{
|
||||
Parser parser;
|
||||
|
||||
String stream = "var i = true; print (i + 1) * 10;";
|
||||
auto res = parser.parse(stream);
|
||||
|
||||
TEST(!res.isError);
|
||||
|
||||
delete res.scope;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_DEF_STATIC(ErrorHandling) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue