diff options
Diffstat (limited to 'tiger-compiler/src/testsuite/libtestsuite.hh')
| -rw-r--r-- | tiger-compiler/src/testsuite/libtestsuite.hh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tiger-compiler/src/testsuite/libtestsuite.hh b/tiger-compiler/src/testsuite/libtestsuite.hh new file mode 100644 index 0000000..2c42e04 --- /dev/null +++ b/tiger-compiler/src/testsuite/libtestsuite.hh @@ -0,0 +1,41 @@ +/** + ** \file testsuite/libtestsuite.hh + ** \brief Declare functions and variables exported by testsuite module. + */ + +#pragma once + +#include <ast/function-dec.hh> + +namespace testsuite + { + + /** + * Find all the tests functions of a program and return references to each of + * them. + * + * A function is considered a test function if it has the following + * properties :\n + * - It is located at the first level of a program file\n + * - Its name starts with test_* + * + * @param program the program to analyse + * @return a vector containing a reference to each test function + */ + std::vector<const ast::FunctionDec*> + find_program_tests(const ast::ChunkList& program); + + /** + * Create a testsuite runtime, which runs each function referenced in the + * vector. + * + * The return tree may then be appended to the main program AST list to be + * compiled along with the rest of this latter. + * + * @param tests the tests to run + * @return an AST tree describing the resulting testsuite runtime + */ + ast::ChunkInterface* + create_testsuite_runtime(const std::vector<const ast::FunctionDec*>& tests); + + } // namespace testsuite |
