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
f5d48c99
Commit
f5d48c99
authored
Feb 16, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied usage of __pos__ operators in some unit tests.
parent
0b791b7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
src/rules/negation.py
src/rules/negation.py
+5
-5
tests/test_rules_negation.py
tests/test_rules_negation.py
+7
-7
No files found.
src/rules/negation.py
View file @
f5d48c99
...
...
@@ -67,7 +67,7 @@ def double_negation(root, args):
"""
--a -> a
"""
return
negate
(
args
[
0
],
args
[
0
].
negated
-
2
)
return
args
[
0
].
reduce_negation
(
2
)
MESSAGES
[
double_negation
]
=
_
(
'Remove double negation in {1}.'
)
...
...
@@ -84,9 +84,9 @@ def match_negated_division(node):
if
a
.
negated
and
b
.
negated
:
return
[
P
(
node
,
double_negated_division
,
(
node
,))]
elif
a
.
negated
:
return
[
P
(
node
,
single_negated_division
,
(
a
[
0
]
,
b
))]
return
[
P
(
node
,
single_negated_division
,
(
+
a
,
b
))]
elif
b
.
negated
:
return
[
P
(
node
,
single_negated_division
,
(
a
,
b
[
0
]
))]
return
[
P
(
node
,
single_negated_division
,
(
a
,
+
b
))]
return
[]
...
...
@@ -111,9 +111,9 @@ def double_negated_division(root, args):
"""
-a / -b -> a / b
"""
a
,
b
=
root
a
,
b
=
args
[
0
]
return
a
[
0
]
/
b
[
0
]
return
+
a
/
+
b
MESSAGES
[
double_negated_division
]
=
\
...
...
tests/test_rules_negation.py
View file @
f5d48c99
...
...
@@ -14,12 +14,12 @@ class TestRulesNegation(RulesTestCase):
l1
,
l2
=
root
=
tree
(
'-1 / 2'
)
possibilities
=
match_negated_division
(
root
)
self
.
assertEqualPos
(
possibilities
,
[
P
(
root
,
single_negated_division
,
(
l1
[
0
]
,
l2
))])
[
P
(
root
,
single_negated_division
,
(
+
l1
,
l2
))])
l1
,
l2
=
root
=
tree
(
'1 / -2'
)
possibilities
=
match_negated_division
(
root
)
self
.
assertEqualPos
(
possibilities
,
[
P
(
root
,
single_negated_division
,
(
l1
,
l2
[
0
]
))])
[
P
(
root
,
single_negated_division
,
(
l1
,
+
l2
))])
def
test_match_negated_division_double
(
self
):
root
=
tree
(
'-1 / -2'
)
...
...
@@ -30,15 +30,15 @@ class TestRulesNegation(RulesTestCase):
def
test_single_negated_division
(
self
):
l1
,
l2
=
root
=
tree
(
'-1 / 2'
)
self
.
assertEqualNodes
(
single_negated_division
(
root
,
(
l1
[
0
]
,
l2
)),
-
(
l1
[
0
]
/
l2
))
self
.
assertEqualNodes
(
single_negated_division
(
root
,
(
+
l1
,
l2
)),
-
(
+
l1
/
l2
))
l1
,
l2
=
root
=
tree
(
'1 / -2'
)
self
.
assertEqualNodes
(
single_negated_division
(
root
,
(
l1
,
l2
[
0
]
)),
-
(
l1
/
l2
[
0
]
))
self
.
assertEqualNodes
(
single_negated_division
(
root
,
(
l1
,
+
l2
)),
-
(
l1
/
+
l2
))
def
test_double_negated_division
(
self
):
l1
,
l2
=
root
=
tree
(
'-1 / -2'
)
self
.
assertEqualNodes
(
double_negated_division
(
root
,
(
root
,)),
l1
[
0
]
/
l2
[
0
]
)
+
l1
/
+
l2
)
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