Skip to content
Snippets Groups Projects
Commit 980637a1 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add very simple tests for ASTExecutionInfo

parent cd39291d
No related branches found
No related tags found
1 merge request!67Feature/inline help
...@@ -16,6 +16,8 @@ class ASTExecutionInfo ...@@ -16,6 +16,8 @@ class ASTExecutionInfo
// The only place where the ASTExecutionInfo can be built // The only place where the ASTExecutionInfo can be built
friend void parser(const std::string& filename); friend void parser(const std::string& filename);
// also allowed for testing
friend void test_ASTExecutionInfo(const ASTNode&, const ModuleRepository&);
ASTExecutionInfo(const ASTNode& root_node, const ModuleRepository& module_repository); ASTExecutionInfo(const ASTNode& root_node, const ModuleRepository& module_repository);
......
...@@ -4,11 +4,22 @@ ...@@ -4,11 +4,22 @@
#include <language/ast/ASTModulesImporter.hpp> #include <language/ast/ASTModulesImporter.hpp>
#include <language/ast/ASTNodeExpressionBuilder.hpp> #include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp> #include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/utils/ASTExecutionInfo.hpp>
#include <language/utils/ASTPrinter.hpp> #include <language/utils/ASTPrinter.hpp>
#include <language/utils/SymbolTable.hpp> #include <language/utils/SymbolTable.hpp>
#include <pegtl/string_input.hpp> #include <pegtl/string_input.hpp>
inline void
test_ASTExecutionInfo(const ASTNode& root_node, const ModuleRepository& module_repository)
{
ASTExecutionInfo execution_info{root_node, module_repository};
REQUIRE(&root_node == &execution_info.rootNode());
REQUIRE(&module_repository == &execution_info.moduleRepository());
REQUIRE(&ASTExecutionInfo::current() == &execution_info);
}
#define CHECK_AST(data, expected_output) \ #define CHECK_AST(data, expected_output) \
{ \ { \
static_assert(std::is_same_v<std::decay_t<decltype(data)>, std::string_view>); \ static_assert(std::is_same_v<std::decay_t<decltype(data)>, std::string_view>); \
...@@ -17,10 +28,13 @@ ...@@ -17,10 +28,13 @@
string_input input{data, "test.pgs"}; \ string_input input{data, "test.pgs"}; \
auto ast = ASTBuilder::build(input); \ auto ast = ASTBuilder::build(input); \
\ \
ASTModulesImporter{*ast}; \ ASTModulesImporter importer{*ast}; \
ASTNodeTypeCleaner<language::import_instruction>{*ast}; \ ASTNodeTypeCleaner<language::import_instruction>{*ast}; \
\ \
ASTNodeExpressionBuilder{*ast}; \ ASTNodeExpressionBuilder{*ast}; \
const auto& module_repository = importer.moduleRepository(); \
test_ASTExecutionInfo(*ast, module_repository); \
\
ExecutionPolicy exec_policy; \ ExecutionPolicy exec_policy; \
ast->execute(exec_policy); \ ast->execute(exec_policy); \
\ \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment