Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
3f86d185
Commit
3f86d185
authored
Jan 07, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved assertion helper functions to separate class for common usage.
parent
3ba4a7a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
25 deletions
+29
-25
tests/rulestestcase.py
tests/rulestestcase.py
+26
-0
tests/test_rules_poly.py
tests/test_rules_poly.py
+3
-25
No files found.
tests/rulestestcase.py
0 → 100644
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
)
tests/test_rules_poly.py
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
Expression
Node
,
Expression
Leaf
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment