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

Add tests for language's node processors for checkpointing

parent 97da1620
Branches
No related tags found
1 merge request!199Integrate checkpointing
Showing
with 1090 additions and 1 deletion
......@@ -8,6 +8,7 @@
#include <language/utils/SymbolTable.hpp>
#include <utils/checkpointing/Checkpoint.hpp>
#include <utils/checkpointing/ResumingManager.hpp>
#include <utils/pugs_config.hpp>
class ASTNodeListProcessor final : public INodeProcessor
{
......@@ -26,6 +27,7 @@ class ASTNodeListProcessor final : public INodeProcessor
{
ResumingManager& resuming_manager = ResumingManager::getInstance();
if (resuming_manager.isResuming()) {
#ifdef PUGS_HAS_HDF5
const size_t checkpoint_id = resuming_manager.checkpointId();
const ASTCheckpointsInfo& ast_checkpoint_info = ASTCheckpointsInfo::getInstance();
......@@ -35,6 +37,7 @@ class ASTNodeListProcessor final : public INodeProcessor
i_child < m_node.children.size(); ++i_child) {
m_node.children[i_child]->execute(exec_policy);
}
#endif // PUGS_HAS_HDF5
} else {
for (auto&& child : m_node.children) {
child->execute(exec_policy);
......
......@@ -7,6 +7,7 @@
#include <language/utils/SymbolTable.hpp>
#include <utils/checkpointing/Checkpoint.hpp>
#include <utils/checkpointing/ResumingManager.hpp>
#include <utils/pugs_config.hpp>
class DoWhileProcessor final : public INodeProcessor
{
......@@ -28,6 +29,7 @@ class DoWhileProcessor final : public INodeProcessor
ResumingManager& resuming_manager = ResumingManager::getInstance();
do {
if (resuming_manager.isResuming()) {
#ifdef PUGS_HAS_HDF5
const size_t checkpoint_id = resuming_manager.checkpointId();
const ASTCheckpointsInfo& ast_checkpoint_info = ASTCheckpointsInfo::getInstance();
......@@ -35,6 +37,7 @@ class DoWhileProcessor final : public INodeProcessor
const size_t i_child = ast_checkpoint.getASTLocation()[resuming_manager.currentASTLevel()++];
Assert(i_child == 0);
#endif // PUGS_HAS_HDF5
};
m_node.children[0]->execute(exec_until_jump);
if (not exec_until_jump.exec()) {
......
......@@ -7,6 +7,7 @@
#include <language/utils/SymbolTable.hpp>
#include <utils/checkpointing/Checkpoint.hpp>
#include <utils/checkpointing/ResumingManager.hpp>
#include <utils/pugs_config.hpp>
class ForProcessor final : public INodeProcessor
{
......@@ -42,6 +43,7 @@ class ForProcessor final : public INodeProcessor
m_node.children[1]->execute(exec_policy)));
}()) {
if (resuming_manager.isResuming()) {
#ifdef PUGS_HAS_HDF5
const size_t checkpoint_id = resuming_manager.checkpointId();
const ASTCheckpointsInfo& ast_checkpoint_info = ASTCheckpointsInfo::getInstance();
......@@ -49,6 +51,7 @@ class ForProcessor final : public INodeProcessor
const size_t i_child = ast_checkpoint.getASTLocation()[resuming_manager.currentASTLevel()++];
Assert(i_child == 3);
#endif // PUGS_HAS_HDF5
}
m_node.children[3]->execute(exec_until_jump);
if (not exec_until_jump.exec()) {
......
......@@ -7,6 +7,7 @@
#include <language/utils/SymbolTable.hpp>
#include <utils/checkpointing/Checkpoint.hpp>
#include <utils/checkpointing/ResumingManager.hpp>
#include <utils/pugs_config.hpp>
class IfProcessor final : public INodeProcessor
{
......@@ -25,6 +26,7 @@ class IfProcessor final : public INodeProcessor
{
ResumingManager& resuming_manager = ResumingManager::getInstance();
if (resuming_manager.isResuming()) {
#ifdef PUGS_HAS_HDF5
const size_t checkpoint_id = resuming_manager.checkpointId();
const ASTCheckpointsInfo& ast_checkpoint_info = ASTCheckpointsInfo::getInstance();
......@@ -32,7 +34,7 @@ class IfProcessor final : public INodeProcessor
const size_t i_child = ast_checkpoint.getASTLocation()[resuming_manager.currentASTLevel()++];
m_node.children[i_child]->execute(exec_policy);
#endif // PUGS_HAS_HDF5
} else {
const bool is_true = static_cast<bool>(std::visit( // LCOV_EXCL_LINE (false negative)
[](const auto& value) -> bool {
......
......@@ -7,6 +7,7 @@
#include <language/utils/SymbolTable.hpp>
#include <utils/checkpointing/Checkpoint.hpp>
#include <utils/checkpointing/ResumingManager.hpp>
#include <utils/pugs_config.hpp>
class WhileProcessor final : public INodeProcessor
{
......@@ -38,6 +39,7 @@ class WhileProcessor final : public INodeProcessor
m_node.children[0]->execute(exec_policy)));
}()) {
if (resuming_manager.isResuming()) {
#ifdef PUGS_HAS_HDF5
const size_t checkpoint_id = resuming_manager.checkpointId();
const ASTCheckpointsInfo& ast_checkpoint_info = ASTCheckpointsInfo::getInstance();
......@@ -45,6 +47,7 @@ class WhileProcessor final : public INodeProcessor
const size_t i_child = ast_checkpoint.getASTLocation()[resuming_manager.currentASTLevel()++];
Assert(i_child == 1);
#endif // PUGS_HAS_HDF5
}
m_node.children[1]->execute(exec_until_jump);
......
......@@ -172,6 +172,7 @@ add_executable (unit_tests
test_checkpointing_Checkpoint.cpp
test_checkpointing_PrintCheckpointInfo.cpp
test_checkpointing_PrintScriptFrom.cpp
test_checkpointing_Resume.cpp
test_checkpointing_ResumingManager.cpp
test_checkpointing_ResumingUtils.cpp
test_checkpointing_SetResumeFrom.cpp
......
......@@ -10,6 +10,7 @@
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/modules/MathModule.hpp>
#include <language/node_processor/BuiltinFunctionProcessor.hpp>
#include <test_BuiltinFunctionRegister.hpp>
......@@ -638,4 +639,12 @@ let x:R, x = tuple_ZtoR(3);
CHECK_BUILTIN_FUNCTION_EVALUATION_RESULT(data, "x", 0.5 * 3);
}
}
SECTION("expression type")
{
ASTNode node;
REQUIRE(BuiltinFunctionExpressionProcessor{nullptr}.type() ==
INodeProcessor::Type::builtin_function_expression_processor);
REQUIRE(BuiltinFunctionProcessor{node}.type() == INodeProcessor::Type::builtin_function_processor);
}
}
......@@ -10,6 +10,7 @@
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/node_processor/ConcatExpressionProcessor.hpp>
#include <language/utils/ASTPrinter.hpp>
#include <utils/Demangle.hpp>
#include <utils/Stringify.hpp>
......@@ -205,4 +206,11 @@ TEST_CASE("ConcatExpressionProcessor", "[language]")
CHECK_CONCAT_EXPRESSION_RESULT(R"(let x:R^3x3, x = [[1,2,3],[4,5,6],[7,8,9]]; let s:string, s = "_foo"; s = x+s;)",
"s", os.str());
}
SECTION("expression type")
{
ASTNode node;
REQUIRE(ConcatExpressionProcessor<std::string, std::string>{node}.type() ==
INodeProcessor::Type::concat_expression_processor);
}
}
......@@ -10,6 +10,7 @@
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/node_processor/DoWhileProcessor.hpp>
#include <language/utils/ASTPrinter.hpp>
#include <utils/Demangle.hpp>
......@@ -147,4 +148,10 @@ do {
CHECK_DO_WHILE_PROCESSOR_THROWS_WITH(data, "invalid implicit conversion: Z -> B");
}
}
SECTION("expression type")
{
ASTNode node;
REQUIRE(DoWhileProcessor{node}.type() == INodeProcessor::Type::do_while_processor);
}
}
......@@ -10,6 +10,7 @@
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/node_processor/ForProcessor.hpp>
#include <language/utils/ASTPrinter.hpp>
#include <utils/Demangle.hpp>
......@@ -122,4 +123,10 @@ for(let l:N, l=0; l; ++l) {
CHECK_FOR_PROCESSOR_THROWS_WITH(data, "invalid implicit conversion: N -> B");
}
}
SECTION("expression type")
{
ASTNode node;
REQUIRE(ForProcessor{node}.type() == INodeProcessor::Type::for_processor);
}
}
......@@ -9,6 +9,7 @@
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/node_processor/FunctionProcessor.hpp>
#include <utils/Demangle.hpp>
#include <utils/Stringify.hpp>
......@@ -1954,4 +1955,12 @@ f(1, 2);
}
}
}
SECTION("expression type")
{
ASTNode node;
REQUIRE((FunctionProcessor{node, SymbolTable::Context{}}.type() == INodeProcessor::Type::function_processor));
REQUIRE((FunctionExpressionProcessor<double, double>{node}.type() ==
INodeProcessor::Type::function_expression_processor));
}
}
......@@ -9,6 +9,7 @@
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/node_processor/IfProcessor.hpp>
#include <utils/Demangle.hpp>
#include <pegtl/string_input.hpp>
......@@ -157,4 +158,10 @@ if (1.2) {
CHECK_IF_PROCESSOR_THROWS_WITH(data, "invalid implicit conversion: R -> B");
}
}
SECTION("expression type")
{
ASTNode node;
REQUIRE(IfProcessor{node}.type() == INodeProcessor::Type::if_processor);
}
}
......@@ -10,6 +10,7 @@
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/node_processor/WhileProcessor.hpp>
#include <utils/Demangle.hpp>
#include <pegtl/string_input.hpp>
......@@ -142,4 +143,10 @@ while(1) {
CHECK_WHILE_PROCESSOR_THROWS_WITH(data, "invalid implicit conversion: Z -> B");
}
}
SECTION("expression type")
{
ASTNode node;
REQUIRE(WhileProcessor{node}.type() == INodeProcessor::Type::while_processor);
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment