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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
c1d8d089
Commit
c1d8d089
authored
Jul 8, 2019
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add ASTSymbolTableBuilder tests
parent
32abd3af
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!37
Feature/language
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_ASTSymbolTableBuilder.cpp
+48
-0
48 additions, 0 deletions
tests/test_ASTSymbolTableBuilder.cpp
with
49 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
c1d8d089
...
...
@@ -3,6 +3,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PUGS_BINARY_DIR})
add_executable
(
unit_tests
test_main.cpp
test_ASTSymbolTableBuilder.cpp
test_ASTBuilder.cpp
test_Array.cpp
test_ArrayUtils.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_ASTSymbolTableBuilder.cpp
0 → 100644
+
48
−
0
View file @
c1d8d089
#include
<catch2/catch.hpp>
#include
<ASTBuilder.hpp>
#include
<ASTSymbolTableBuilder.hpp>
TEST_CASE
(
"ASTSymbolTableBuilder"
,
"[language]"
)
{
SECTION
(
"Build symbols"
)
{
std
::
string_view
data
=
R"(
N n = 2;
{
N m = n;
R n = m/3.;
}
)"
;
string_input
input
{
data
,
"test.pgs"
};
auto
ast
=
ASTBuilder
::
build
(
input
);
ASTSymbolTableBuilder
{
*
ast
};
}
SECTION
(
"Undeclared symbol"
)
{
std
::
string_view
data
=
R"(
N n = a;
)"
;
string_input
input
{
data
,
"test.pgs"
};
auto
ast
=
ASTBuilder
::
build
(
input
);
REQUIRE_THROWS_AS
(
ASTSymbolTableBuilder
{
*
ast
},
parse_error
);
}
SECTION
(
"Re-declared symbol"
)
{
std
::
string_view
data
=
R"(
N n = 0;
N n = 1;
)"
;
string_input
input
{
data
,
"test.pgs"
};
auto
ast
=
ASTBuilder
::
build
(
input
);
REQUIRE_THROWS_AS
(
ASTSymbolTableBuilder
{
*
ast
},
parse_error
);
}
}
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