fortpy
fortpy copied to clipboard
Unit Testing Embedded Executables
We need to show a warning when a unit test is defined for a subroutine or function that is declared inside of another subroutine. Since they are buried, they can't be made public in the module for unit testing purposes.
Another option is to cut and paste the code automatically so that its definition is outside the subroutine contains section and then it could be made public. This is more user-friendly. The cut and paste should be simple since we already have the start and stop lines for the subroutine and could just move them outside of the parent subroutine completely. The only complexity that emerges is:
- if there is only one nested executable, the
containsstatement is invalid and would have to be removed. - if there are multiple nested executables that reference each other, then moving one of them out, but not the others, will result in compilation failures. Although fortpy can detect most dependencies and track them down, there are a couple of cases where it doesn't work well for functions (the parser needs to be revisited). If we can trust the dependency listings, we will know which of the executables to cut out of the
containssection.