Expose new index-of-interest FP methods to Nasal
Add some test checks for the Nasal API as well
This commit is contained in:
parent
1eef7300be
commit
d66edf42f5
2 changed files with 29 additions and 0 deletions
|
@ -820,6 +820,14 @@ static const char* flightplanGhostGetMember(naContext c, void* g, naRef field, n
|
|||
else if (!strcmp(fieldName, "remarks")) *out = stringToNasal(c, fp->remarks());
|
||||
else if (!strcmp(fieldName, "callsign")) *out = stringToNasal(c, fp->callsign());
|
||||
else if (!strcmp(fieldName, "estimatedDurationMins")) *out = naNum(fp->estimatedDurationMinutes());
|
||||
else if (!strcmp(fieldName, "firstNonDepartureLeg"))
|
||||
*out = naNum(fp->indexOfFirstNonDepartureWaypoint());
|
||||
else if (!strcmp(fieldName, "firstArrivalLeg"))
|
||||
*out = naNum(fp->indexOfFirstArrivalWaypoint());
|
||||
else if (!strcmp(fieldName, "firstApproachLeg"))
|
||||
*out = naNum(fp->indexOfFirstApproachWaypoint());
|
||||
else if (!strcmp(fieldName, "destination_runway_leg"))
|
||||
*out = naNum(fp->indexOfDestinationRunwayWaypoint());
|
||||
|
||||
else {
|
||||
return nullptr;
|
||||
|
|
|
@ -730,4 +730,25 @@ void RouteManagerTests::testRouteWithProcedures()
|
|||
|
||||
auto firstMiss = f->legAtIndex(f->indexOfDestinationRunwayWaypoint() + 1);
|
||||
CPPUNIT_ASSERT_EQUAL(firstMiss->waypoint()->ident(), string{"(461)"});
|
||||
|
||||
// check it in Nasal too
|
||||
bool ok = FGTestApi::executeNasal(
|
||||
R"(
|
||||
var f = flightplan();
|
||||
var depEnd = f.getWP(f.firstNonDepartureLeg - 1);
|
||||
var firstArrival = f.getWP(f.firstArrivalLeg);
|
||||
var firstApproach = f.getWP(f.firstApproachLeg);
|
||||
var destRunway = f.getWP(f.destination_runway_leg);
|
||||
|
||||
unitTest.assert_equal(depEnd.id, 'CANDR');
|
||||
|
||||
var firstEnroute = f.getWP(f.firstNonDepartureLeg );
|
||||
unitTest.assert_equal(firstEnroute.id, 'TOMYE');
|
||||
|
||||
unitTest.assert_equal(firstArrival.id, 'BEDUM');
|
||||
unitTest.assert_equal(firstApproach.id, 'D070O');
|
||||
unitTest.assert_equal(destRunway.id, '18R');
|
||||
)");
|
||||
|
||||
CPPUNIT_ASSERT(ok);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue