summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/testsuite/libtestsuite.hh
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/testsuite/libtestsuite.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/testsuite/libtestsuite.hh')
-rw-r--r--tiger-compiler/src/testsuite/libtestsuite.hh41
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