1
0
Fork 0

Fix logic of duplicate-command-add test

parseAndReturn returns false, when runtime errors occur.
This commit is contained in:
James Turner 2022-01-14 07:57:24 +01:00
parent 3cd0a3d002
commit ef3ba040ca
2 changed files with 17 additions and 25 deletions

View file

@ -436,18 +436,10 @@ bool executeNasal(const std::string& code)
}
nasal->getAndClearErrorList();
std::string output, dummyErrors;
bool ok = nasal->parseAndRunWithOutput(code, output, dummyErrors);
if (!dummyErrors.empty()) {
SG_LOG(SG_NASAL, SG_ALERT, "Errors running Nasal:" << dummyErrors);
return false;
}
auto errors = nasal->getAndClearErrorList();
if (!errors.empty()) {
for (auto err : errors) {
SG_LOG(SG_NASAL, SG_ALERT, "Errors running Nasal:" << err);
}
std::string output, parseErrors;
bool ok = nasal->parseAndRunWithOutput(code, output, parseErrors);
if (!parseErrors.empty()) {
SG_LOG(SG_NASAL, SG_ALERT, "Errors running Nasal:" << parseErrors);
return false;
}

View file

@ -125,10 +125,10 @@ void NasalSysTests::testCommands()
var g = func { print('fail'); };
addcommand('do-foo', g);
)");
CPPUNIT_ASSERT(ok);
CPPUNIT_ASSERT(ok);
auto errors = nasalSys->getAndClearErrorList();
CPPUNIT_ASSERT_EQUAL(1UL, errors.size());
CPPUNIT_ASSERT_EQUAL(errors.size(), static_cast<size_t>(1));
// old command should still be registered and work
ok = globals->get_commands()->execute("do-foo", args);
@ -173,16 +173,16 @@ void NasalSysTests::testAirportGhost()
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);
// 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) {