summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/testsuite/tests-collector.hh
blob: d7e3ef1547d0733e4ecffbec32e6b7c229baffa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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>