Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Taddeüs Kroes
trs
Commits
3f86d185
Commit
3f86d185
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Moved assertion helper functions to separate class for common usage.
parent
3ba4a7a4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/rulestestcase.py
+26
-0
26 additions, 0 deletions
tests/rulestestcase.py
tests/test_rules_poly.py
+3
-25
3 additions, 25 deletions
tests/test_rules_poly.py
with
29 additions
and
25 deletions
tests/rulestestcase.py
0 → 100644
+
26
−
0
View file @
3f86d185
import
unittest
from
src.node
import
ExpressionNode
class
RulesTestCase
(
unittest
.
TestCase
):
def
assertEqualPos
(
self
,
possibilities
,
expected
):
self
.
assertEqual
(
len
(
possibilities
),
len
(
expected
))
for
p
,
e
in
zip
(
possibilities
,
expected
):
self
.
assertEqual
(
p
.
root
,
e
.
root
)
for
pair
in
zip
(
p
.
args
,
e
.
args
):
self
.
assertEqual
(
*
pair
)
self
.
assertEqual
(
p
,
e
)
def
assertEqualNodes
(
self
,
a
,
b
):
if
not
isinstance
(
a
,
ExpressionNode
):
return
self
.
assertEqual
(
a
,
b
)
self
.
assertIsInstance
(
b
,
ExpressionNode
)
self
.
assertEqual
(
a
.
op
,
b
.
op
)
for
ca
,
cb
in
zip
(
a
,
b
):
self
.
assertEqualNodes
(
ca
,
cb
)
This diff is collapsed.
Click to expand it.
tests/test_rules_poly.py
+
3
−
25
View file @
3f86d185
import
unittest
from
src.rules.poly
import
match_combine_polynomes
,
combine_polynomes
,
\
combine_numerics
from
src.possibilities
import
Possibility
as
P
from
src.node
import
ExpressionNode
,
ExpressionLeaf
as
L
from
src.node
import
ExpressionLeaf
as
L
from
src.parser
import
Parser
from
tests.parser
import
ParserWrapper
from
tests.rulestestcase
import
RulesTestCase
def
tree
(
exp
,
**
kwargs
):
return
ParserWrapper
(
Parser
,
**
kwargs
).
run
([
exp
])
class
TestRulesPoly
(
unittest
.
TestCase
):
def
assertEqualPos
(
self
,
possibilities
,
expected
):
self
.
assertEqual
(
len
(
possibilities
),
len
(
expected
))
for
p
,
e
in
zip
(
possibilities
,
expected
):
self
.
assertEqual
(
p
.
root
,
e
.
root
)
for
pair
in
zip
(
p
.
args
,
e
.
args
):
self
.
assertEqual
(
*
pair
)
self
.
assertEqual
(
p
,
e
)
class
TestRulesPoly
(
RulesTestCase
):
def
test_identifiers_basic
(
self
):
a1
,
a2
=
root
=
tree
(
'
a+a
'
)
...
...
@@ -142,13 +130,3 @@ class TestRulesPoly(unittest.TestCase):
left
,
right
=
root
replacement
=
combine_polynomes
(
root
,
(
left
,
right
,
l2
,
l2
,
a
,
1
))
self
.
assertEqualNodes
(
replacement
,
(
l2
+
1
)
*
a
)
def
assertEqualNodes
(
self
,
a
,
b
):
if
not
isinstance
(
a
,
ExpressionNode
):
return
self
.
assertEqual
(
a
,
b
)
self
.
assertIsInstance
(
b
,
ExpressionNode
)
self
.
assertEqual
(
a
.
op
,
b
.
op
)
for
ca
,
cb
in
zip
(
a
,
b
):
self
.
assertEqualNodes
(
ca
,
cb
)
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