1
0
Fork 0

Unit-test for Nasal parsing bug

This commit is contained in:
James Turner 2021-03-03 22:00:01 +00:00
parent de90c281a5
commit 8716801c8c
2 changed files with 37 additions and 0 deletions

View file

@ -168,3 +168,38 @@ void NasalSysTests::testAirportGhost()
CPPUNIT_ASSERT(ok);
}
// https://sourceforge.net/p/flightgear/codetickets/2246/
void NasalSysTests::testCompileLarge()
{
auto nasalSys = globals->get_subsystem<FGNasalSys>();
nasalSys->getAndClearErrorList();
string code = "var foo = 0;\n";
for (int i=0; i<14; ++i) {
code = code + code;
}
nasalSys->parseAndRun(code);
// bool ok = FGTestApi::executeNasal(R"(
//var try_compile = func(code) {
// call(compile, [code], nil,nil,var err=[]);
// return size(err);
//}
//
//var expression = "var foo = 0;\n";
//var code = "";
//
//for(var i=0;i<=10000;i+=1) {
// code ~= expression;
// if (try_compile(code) == 1) {
// print("Error compiling, LOC count is:", i+1);
// break;
// }
//}
// )");
// CPPUNIT_ASSERT(ok);
}

View file

@ -34,6 +34,7 @@ class NasalSysTests : public CppUnit::TestFixture
CPPUNIT_TEST(testStructEquality);
CPPUNIT_TEST(testCommands);
CPPUNIT_TEST(testAirportGhost);
CPPUNIT_TEST(testCompileLarge);
CPPUNIT_TEST_SUITE_END();
public:
@ -47,6 +48,7 @@ public:
void testStructEquality();
void testCommands();
void testAirportGhost();
void testCompileLarge();
};
#endif // _FG_NASALSYS_UNIT_TESTS_HXX