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
4f57eb5c
Commit
4f57eb5c
authored
Feb 11, 2020
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add missing tests for ASTNodeListAffectationExpressionBuilder
parent
8e5a9431
No related branches found
No related tags found
1 merge request
!37
Feature/language
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/language/ASTNodeListAffectationExpressionBuilder.cpp
+9
-2
9 additions, 2 deletions
src/language/ASTNodeListAffectationExpressionBuilder.cpp
tests/test_ASTNodeListAffectationExpressionBuilder.cpp
+84
-0
84 additions, 0 deletions
tests/test_ASTNodeListAffectationExpressionBuilder.cpp
with
93 additions
and
2 deletions
src/language/ASTNodeListAffectationExpressionBuilder.cpp
+
9
−
2
View file @
4f57eb5c
...
@@ -59,10 +59,15 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor(
...
@@ -59,10 +59,15 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor(
if
(
std
::
stoi
(
node_sub_data_type
.
m_parent_node
.
string
())
==
0
)
{
if
(
std
::
stoi
(
node_sub_data_type
.
m_parent_node
.
string
())
==
0
)
{
list_affectation_processor
->
template
add
<
ValueT
,
ZeroType
>(
value_node
);
list_affectation_processor
->
template
add
<
ValueT
,
ZeroType
>(
value_node
);
}
else
{
}
else
{
throw
parse_error
(
"invalid operand value"
,
std
::
vector
{
node_sub_data_type
.
m_parent_node
.
begin
()});
// LCOV_EXCL_START
throw
parse_error
(
"unexpected error: invalid operand value"
,
std
::
vector
{
node_sub_data_type
.
m_parent_node
.
begin
()});
// LCOV_EXCL_STOP
}
}
}
else
{
}
else
{
throw
parse_error
(
"invalid dimension"
,
std
::
vector
{
node_sub_data_type
.
m_parent_node
.
begin
()});
// LCOV_EXCL_START
throw
parse_error
(
"unexpected error: invalid dimension"
,
std
::
vector
{
node_sub_data_type
.
m_parent_node
.
begin
()});
// LCOV_EXCL_STOP
}
}
}
else
{
}
else
{
throw
parse_error
(
"unexpected error: invalid value type"
);
throw
parse_error
(
"unexpected error: invalid value type"
);
...
@@ -138,9 +143,11 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor(
...
@@ -138,9 +143,11 @@ ASTNodeListAffectationExpressionBuilder::_buildAffectationProcessor(
add_affectation_processor_for_vector_data
(
TinyVector
<
3
>
{},
node_sub_data_type
);
add_affectation_processor_for_vector_data
(
TinyVector
<
3
>
{},
node_sub_data_type
);
break
;
break
;
}
}
// LCOV_EXCL_START
default
:
{
default
:
{
throw
parse_error
(
"invalid dimension"
,
std
::
vector
{
value_node
.
begin
()});
throw
parse_error
(
"invalid dimension"
,
std
::
vector
{
value_node
.
begin
()});
}
}
// LCOV_EXCL_STOP
}
}
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_ASTNodeListAffectationExpressionBuilder.cpp
+
84
−
0
View file @
4f57eb5c
...
@@ -161,6 +161,71 @@ R*R*R*R (r,b,z,m) = (3.2, 1, 6, 2);
...
@@ -161,6 +161,71 @@ R*R*R*R (r,b,z,m) = (3.2, 1, 6, 2);
CHECK_AST
(
data
,
result
);
CHECK_AST
(
data
,
result
);
}
}
SECTION
(
"without conversion R^1*R^2*R^3*R"
)
{
std
::
string_view
data
=
R"(
R^1 a = 0;
R^2 b = (1,2);
R^3 c = (1,2,3);
R^1*R^2*R^3*R (x1,x2,x3,x) = (a, b, c, 2);
)"
;
std
::
string_view
result
=
R"(
(root:ASTNodeListProcessor)
+-(language::eq_op:AffectationFromZeroProcessor<TinyVector<1ul, double> >)
| +-(language::name:a:NameProcessor)
| `-(language::integer:0:ValueProcessor)
+-(language::eq_op:AffectationFromListProcessor<language::eq_op, TinyVector<2ul, double> >)
| +-(language::name:b:NameProcessor)
| `-(language::expression_list:ASTNodeExpressionListProcessor)
| +-(language::integer:1:ValueProcessor)
| `-(language::integer:2:ValueProcessor)
+-(language::eq_op:AffectationFromListProcessor<language::eq_op, TinyVector<3ul, double> >)
| +-(language::name:c:NameProcessor)
| `-(language::expression_list:ASTNodeExpressionListProcessor)
| +-(language::integer:1:ValueProcessor)
| +-(language::integer:2:ValueProcessor)
| `-(language::integer:3:ValueProcessor)
`-(language::eq_op:ListAffectationProcessor<language::eq_op>)
+-(language::name_list:FakeProcessor)
| +-(language::name:x1:NameProcessor)
| +-(language::name:x2:NameProcessor)
| +-(language::name:x3:NameProcessor)
| `-(language::name:x:NameProcessor)
`-(language::expression_list:ASTNodeExpressionListProcessor)
+-(language::name:a:NameProcessor)
+-(language::name:b:NameProcessor)
+-(language::name:c:NameProcessor)
`-(language::integer:2:ValueProcessor)
)"
;
CHECK_AST
(
data
,
result
);
}
SECTION
(
"Zero initialization"
)
{
std
::
string_view
data
=
R"(
R^1*R^2*R^3*R (x1,x2,x3,x) = (0, 0, 0, 0);
)"
;
std
::
string_view
result
=
R"(
(root:ASTNodeListProcessor)
`-(language::eq_op:ListAffectationProcessor<language::eq_op>)
+-(language::name_list:FakeProcessor)
| +-(language::name:x1:NameProcessor)
| +-(language::name:x2:NameProcessor)
| +-(language::name:x3:NameProcessor)
| `-(language::name:x:NameProcessor)
`-(language::expression_list:ASTNodeExpressionListProcessor)
+-(language::integer:0:ValueProcessor)
+-(language::integer:0:ValueProcessor)
+-(language::integer:0:ValueProcessor)
`-(language::integer:0:ValueProcessor)
)"
;
CHECK_AST
(
data
,
result
);
}
SECTION
(
"from function"
)
SECTION
(
"from function"
)
{
{
std
::
string_view
data
=
R"(
std
::
string_view
data
=
R"(
...
@@ -314,5 +379,24 @@ R x;
...
@@ -314,5 +379,24 @@ R x;
CHECK_AST_THROWS_WITH
(
data
,
std
::
string
{
"invalid implicit conversion: Z -> function"
});
CHECK_AST_THROWS_WITH
(
data
,
std
::
string
{
"invalid implicit conversion: Z -> function"
});
}
}
SECTION
(
"invalid R^n -> R^m conversion"
)
{
std
::
string_view
data
=
R"(
R^2 x = (1,2);
R^3 y = x;
)"
;
CHECK_AST_THROWS_WITH
(
data
,
std
::
string
{
"incompatible dimensions in affectation"
});
}
SECTION
(
"invalid Z -> R^d conversion (non-zero)"
)
{
std
::
string_view
data
=
R"(
R^2 x = 1;
)"
;
CHECK_AST_THROWS_WITH
(
data
,
std
::
string
{
"invalid implicit conversion: Z -> R^2"
});
}
}
}
}
}
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