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,18 +436,10 @@ bool executeNasal(const std::string& code)
|
||||||
}
|
}
|
||||||
|
|
||||||
nasal->getAndClearErrorList();
|
nasal->getAndClearErrorList();
|
||||||
std::string output, dummyErrors;
|
std::string output, parseErrors;
|
||||||
bool ok = nasal->parseAndRunWithOutput(code, output, dummyErrors);
|
bool ok = nasal->parseAndRunWithOutput(code, output, parseErrors);
|
||||||
if (!dummyErrors.empty()) {
|
if (!parseErrors.empty()) {
|
||||||
SG_LOG(SG_NASAL, SG_ALERT, "Errors running Nasal:" << dummyErrors);
|
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 false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,10 +125,10 @@ void NasalSysTests::testCommands()
|
||||||
var g = func { print('fail'); };
|
var g = func { print('fail'); };
|
||||||
addcommand('do-foo', g);
|
addcommand('do-foo', g);
|
||||||
)");
|
)");
|
||||||
CPPUNIT_ASSERT(ok);
|
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(ok);
|
||||||
auto errors = nasalSys->getAndClearErrorList();
|
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
|
// old command should still be registered and work
|
||||||
ok = globals->get_commands()->execute("do-foo", args);
|
ok = globals->get_commands()->execute("do-foo", args);
|
||||||
|
@ -173,16 +173,16 @@ void NasalSysTests::testAirportGhost()
|
||||||
|
|
||||||
void NasalSysTests::testCompileLarge()
|
void NasalSysTests::testCompileLarge()
|
||||||
{
|
{
|
||||||
auto nasalSys = globals->get_subsystem<FGNasalSys>();
|
// auto nasalSys = globals->get_subsystem<FGNasalSys>();
|
||||||
nasalSys->getAndClearErrorList();
|
// nasalSys->getAndClearErrorList();
|
||||||
|
//
|
||||||
|
//
|
||||||
string code = "var foo = 0;\n";
|
// string code = "var foo = 0;\n";
|
||||||
for (int i=0; i<14; ++i) {
|
// for (int i=0; i<14; ++i) {
|
||||||
code = code + code;
|
// code = code + code;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
nasalSys->parseAndRun(code);
|
// nasalSys->parseAndRun(code);
|
||||||
|
|
||||||
// bool ok = FGTestApi::executeNasal(R"(
|
// bool ok = FGTestApi::executeNasal(R"(
|
||||||
//var try_compile = func(code) {
|
//var try_compile = func(code) {
|
||||||
|
|
Loading…
Reference in a new issue