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
f64ecc9a
Commit
f64ecc9a
authored
Jan 14, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit tested possibilities.py.
parent
4e3c77b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
src/possibilities.py
src/possibilities.py
+0
-1
tests/test_possibilities.py
tests/test_possibilities.py
+42
-0
No files found.
src/possibilities.py
View file @
f64ecc9a
...
@@ -22,7 +22,6 @@ class Possibility(object):
...
@@ -22,7 +22,6 @@ class Possibility(object):
return
'<Possibility root="%s" handler=%s args=%s>'
\
return
'<Possibility root="%s" handler=%s args=%s>'
\
%
(
self
.
root
,
self
.
handler
.
func_name
,
self
.
args
)
%
(
self
.
root
,
self
.
handler
.
func_name
,
self
.
args
)
# TODO: Add unit tests
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
self
.
handler
==
other
.
handler
\
return
self
.
handler
==
other
.
handler
\
and
hash
(
self
.
root
)
==
hash
(
other
.
root
)
\
and
hash
(
self
.
root
)
==
hash
(
other
.
root
)
\
...
...
tests/test_possibilities.py
0 → 100644
View file @
f64ecc9a
import
unittest
from
src.possibilities
import
MESSAGES
,
Possibility
as
P
,
filter_duplicates
from
tests.test_rules_poly
import
tree
def
dummy_handler
(
root
,
args
):
return
root
def
dummy_handler_msg
(
root
,
args
):
return
root
MESSAGES
[
dummy_handler_msg
]
=
'foo {1} + {2} bar'
class
TestPossibilities
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
l1
,
self
.
l2
=
self
.
n
=
tree
(
'1 + 2'
)
self
.
p0
=
P
(
self
.
n
,
dummy_handler
,
(
self
.
l1
,
self
.
l2
))
self
.
p1
=
P
(
self
.
n
,
dummy_handler_msg
,
(
self
.
l1
,
self
.
l2
))
def
test___str__
(
self
):
self
.
assertEqual
(
str
(
self
.
p0
),
'<Possibility root="1 + 2" handler=dummy_handler args=(1, 2)>'
)
self
.
assertEqual
(
str
(
self
.
p1
),
'foo 1 + 2 bar'
)
def
test___repr__
(
self
):
self
.
assertEqual
(
repr
(
self
.
p0
),
'<Possibility root="1 + 2" handler=dummy_handler args=(1, 2)>'
)
def
test___eq__
(
self
):
assert
self
.
p0
==
P
(
self
.
n
,
dummy_handler
,
(
self
.
l1
,
self
.
l2
))
assert
self
.
p0
!=
self
.
p1
def
test_filter_duplicates
(
self
):
self
.
assertEqual
(
filter_duplicates
([]),
[])
self
.
assertEqual
(
filter_duplicates
([
1
,
2
]),
[
1
,
2
])
self
.
assertEqual
(
filter_duplicates
([
1
,
2
,
2
]),
[
1
,
2
])
self
.
assertEqual
(
filter_duplicates
([
1
,
2
,
3
,
2
]),
[
1
,
2
,
3
])
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