Fix logic of duplicate-command-add test
parseAndReturn returns false, when runtime errors occur.
This commit is contained in:
parent
3cd0a3d002
commit
ef3ba040ca
2 changed files with 17 additions and 25 deletions
|
@ -436,21 +436,13 @@ 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);
|
||||
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;
|
||||
}
|
||||
|
||||
auto errors = nasal->getAndClearErrorList();
|
||||
if (!errors.empty()) {
|
||||
for (auto err : errors) {
|
||||
SG_LOG(SG_NASAL, SG_ALERT, "Errors running Nasal:" << err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,11 +125,11 @@ void NasalSysTests::testCommands()
|
|||
var g = func { print('fail'); };
|
||||
addcommand('do-foo', g);
|
||||
)");
|
||||
|
||||
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);
|
||||
CPPUNIT_ASSERT(ok);
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue