Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
b35ad808
Commit
b35ad808
authored
6 months ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for ASTCheckpointsInfo
parent
0e544547
No related branches found
No related tags found
1 merge request
!199
Integrate checkpointing
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/language/utils/ASTCheckpointsInfo.cpp
+2
-2
2 additions, 2 deletions
src/language/utils/ASTCheckpointsInfo.cpp
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_ASTCheckpointsInfo.cpp
+83
-0
83 additions, 0 deletions
tests/test_ASTCheckpointsInfo.cpp
with
86 additions
and
2 deletions
src/language/utils/ASTCheckpointsInfo.cpp
+
2
−
2
View file @
b35ad808
...
...
@@ -29,7 +29,7 @@ ASTCheckpointsInfo::_findASTCheckpoint(std::vector<size_t>& location, const ASTN
ASTCheckpointsInfo
::
ASTCheckpointsInfo
(
const
ASTNode
&
root_node
)
{
Assert
(
m_checkpoints_info_instance
==
nullptr
,
"Can only define one ASTCheckpointInfo"
);
Assert
(
m_checkpoints_info_instance
==
nullptr
,
"Can only define one ASTCheckpoint
s
Info"
);
m_checkpoints_info_instance
=
this
;
Assert
(
root_node
.
is_root
());
...
...
@@ -43,7 +43,7 @@ ASTCheckpointsInfo::ASTCheckpointsInfo(const ASTNode& root_node)
const
ASTCheckpointsInfo
&
ASTCheckpointsInfo
::
getInstance
()
{
Assert
(
m_checkpoints_info_instance
!=
nullptr
,
"ASTCheckpointInfo is not defined!"
);
Assert
(
m_checkpoints_info_instance
!=
nullptr
,
"ASTCheckpoint
s
Info is not defined!"
);
return
*
m_checkpoints_info_instance
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/CMakeLists.txt
+
1
−
0
View file @
b35ad808
...
...
@@ -19,6 +19,7 @@ add_executable (unit_tests
test_ArraySubscriptProcessor.cpp
test_ASTBuilder.cpp
test_ASTCheckpoint.cpp
test_ASTCheckpointsInfo.cpp
test_ASTDotPrinter.cpp
test_ASTExecutionStack.cpp
test_ASTModulesImporter.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_ASTCheckpointsInfo.cpp
0 → 100644
+
83
−
0
View file @
b35ad808
#include
<catch2/catch_approx.hpp>
#include
<catch2/catch_test_macros.hpp>
#include
<catch2/matchers/catch_matchers_predicate.hpp>
#include
<utils/pugs_config.hpp>
#include
<dev/ParallelChecker.hpp>
#include
<language/ast/ASTBuilder.hpp>
#include
<language/ast/ASTExecutionStack.hpp>
#include
<language/ast/ASTModulesImporter.hpp>
#include
<language/ast/ASTNodeDataTypeBuilder.hpp>
#include
<language/ast/ASTNodeDeclarationToAffectationConverter.hpp>
#include
<language/ast/ASTNodeExpressionBuilder.hpp>
#include
<language/ast/ASTNodeTypeCleaner.hpp>
#include
<language/ast/ASTSymbolTableBuilder.hpp>
#include
<language/modules/MathModule.hpp>
#include
<language/utils/ASTCheckpointsInfo.hpp>
#include
<language/utils/CheckpointResumeRepository.hpp>
#include
<utils/ExecutionStatManager.hpp>
class
ASTCheckpointsInfoTester
{
private:
ASTCheckpointsInfo
m_ast_checkpoint_info
;
public:
ASTCheckpointsInfoTester
(
const
ASTNode
&
root_node
)
:
m_ast_checkpoint_info
(
root_node
)
{}
~
ASTCheckpointsInfoTester
()
=
default
;
};
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"ASTCheckpointsInfo"
,
"[utils/checkpointing]"
)
{
#ifndef NDEBUG
REQUIRE_THROWS_WITH
(
ASTCheckpointsInfo
::
getInstance
(),
"ASTCheckpointsInfo is not defined!"
);
#endif // NDEBUG
std
::
string
data
=
R"(
for(let i:N, i=0; i<7; ++i) {
checkpoint();
if (i == 2) {
checkpoint();
}
if (i == 5) {
checkpoint_and_exit();
}
}
)"
;
ExecutionStatManager
::
create
();
TAO_PEGTL_NAMESPACE
::
string_input
input
{
data
,
"test.pgs"
};
auto
ast
=
ASTBuilder
::
build
(
input
);
ASTModulesImporter
{
*
ast
};
ASTNodeTypeCleaner
<
language
::
import_instruction
>
{
*
ast
};
ASTSymbolTableBuilder
{
*
ast
};
ASTNodeDataTypeBuilder
{
*
ast
};
ASTNodeDeclarationToAffectationConverter
{
*
ast
};
ASTNodeTypeCleaner
<
language
::
var_declaration
>
{
*
ast
};
ASTNodeTypeCleaner
<
language
::
fct_declaration
>
{
*
ast
};
ASTNodeExpressionBuilder
{
*
ast
};
ExecutionPolicy
exec_policy
;
ASTExecutionStack
::
create
();
ASTCheckpointsInfoTester
ast_cp_info_tester
{
*
ast
};
ASTExecutionStack
::
destroy
();
ExecutionStatManager
::
destroy
();
ast
->
m_symbol_table
->
clearValues
();
REQUIRE
(
ASTCheckpointsInfo
::
getInstance
().
getASTCheckpoint
(
0
).
getASTLocation
()
==
std
::
vector
<
size_t
>
{
0
,
3
,
0
});
REQUIRE
(
ASTCheckpointsInfo
::
getInstance
().
getASTCheckpoint
(
1
).
getASTLocation
()
==
std
::
vector
<
size_t
>
{
0
,
3
,
1
,
1
});
REQUIRE
(
ASTCheckpointsInfo
::
getInstance
().
getASTCheckpoint
(
2
).
getASTLocation
()
==
std
::
vector
<
size_t
>
{
0
,
3
,
2
,
1
});
#ifndef NDEBUG
REQUIRE_THROWS_WITH
(
ASTCheckpointsInfoTester
(
*
ast
),
"Can only define one ASTCheckpointsInfo"
);
#endif // NDEBUG
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment