summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/testsuite/tests-collector.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/tests-collector.hh
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/src/testsuite/tests-collector.hh')
-rw-r--r--tiger-compiler/src/testsuite/tests-collector.hh53
1 files changed, 53 insertions, 0 deletions
diff --git a/tiger-compiler/src/testsuite/tests-collector.hh b/tiger-compiler/src/testsuite/tests-collector.hh
new file mode 100644
index 0000000..d7e3ef1
--- /dev/null
+++ b/tiger-compiler/src/testsuite/tests-collector.hh
@@ -0,0 +1,53 @@
+/**
+ ** \file testsuite/tests-collector.hh
+ ** \brief Declaration of testsuite::TestsCollector.
+ */
+
+#pragma once
+#include <ast/default-visitor.hh>
+#include <ast/non-assert-visitor.hh>
+#include <ast/non-object-visitor.hh>
+
+namespace testsuite
+ {
+
+ class TestsCollector
+ : public ast::DefaultConstVisitor
+ , public ast::NonObjectConstVisitor
+ , public ast::NonAssertConstVisitor
+ {
+
+ public:
+ using super_type = ast::DefaultConstVisitor;
+ using super_type::operator();
+
+ TestsCollector() = default;
+
+ /**
+ * Return all the functions recognized as test functions by the
+ * visitor.
+ *
+ * @return a vector of references to FunctionDec nodes that represents
+ * test functions
+ */
+ inline std::vector<const ast::FunctionDec*>& tests_get();
+
+ void operator()(const ast::FunctionDec& e) override;
+
+ protected:
+ // The tests identified by the visitor
+ std::vector<const ast::FunctionDec*> tests_;
+
+ /**
+ * Return whether the function declaration is identified as a test
+ * function.
+ * @param node an ast node
+ * @return true if the node references a valid test function, false
+ * otherwise
+ */
+ inline bool is_a_test_function(const ast::FunctionDec& node) ;
+ };
+
+ } // namespace testsuite
+
+#include <testsuite/tests-collector.hxx>