Commit f5d48c99 authored by Taddeus Kroes's avatar Taddeus Kroes

Applied usage of __pos__ operators in some unit tests.

parent 0b791b7f
...@@ -67,7 +67,7 @@ def double_negation(root, args): ...@@ -67,7 +67,7 @@ def double_negation(root, args):
""" """
--a -> a --a -> a
""" """
return negate(args[0], args[0].negated - 2) return args[0].reduce_negation(2)
MESSAGES[double_negation] = _('Remove double negation in {1}.') MESSAGES[double_negation] = _('Remove double negation in {1}.')
...@@ -84,9 +84,9 @@ def match_negated_division(node): ...@@ -84,9 +84,9 @@ def match_negated_division(node):
if a.negated and b.negated: if a.negated and b.negated:
return [P(node, double_negated_division, (node,))] return [P(node, double_negated_division, (node,))]
elif a.negated: elif a.negated:
return [P(node, single_negated_division, (a[0], b))] return [P(node, single_negated_division, (+a, b))]
elif b.negated: elif b.negated:
return [P(node, single_negated_division, (a, b[0]))] return [P(node, single_negated_division, (a, +b))]
return [] return []
...@@ -111,9 +111,9 @@ def double_negated_division(root, args): ...@@ -111,9 +111,9 @@ def double_negated_division(root, args):
""" """
-a / -b -> a / b -a / -b -> a / b
""" """
a, b = root a, b = args[0]
return a[0] / b[0] return +a / +b
MESSAGES[double_negated_division] = \ MESSAGES[double_negated_division] = \
......
...@@ -14,12 +14,12 @@ class TestRulesNegation(RulesTestCase): ...@@ -14,12 +14,12 @@ class TestRulesNegation(RulesTestCase):
l1, l2 = root = tree('-1 / 2') l1, l2 = root = tree('-1 / 2')
possibilities = match_negated_division(root) possibilities = match_negated_division(root)
self.assertEqualPos(possibilities, self.assertEqualPos(possibilities,
[P(root, single_negated_division, (l1[0], l2))]) [P(root, single_negated_division, (+l1, l2))])
l1, l2 = root = tree('1 / -2') l1, l2 = root = tree('1 / -2')
possibilities = match_negated_division(root) possibilities = match_negated_division(root)
self.assertEqualPos(possibilities, 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): def test_match_negated_division_double(self):
root = tree('-1 / -2') root = tree('-1 / -2')
...@@ -30,15 +30,15 @@ class TestRulesNegation(RulesTestCase): ...@@ -30,15 +30,15 @@ class TestRulesNegation(RulesTestCase):
def test_single_negated_division(self): def test_single_negated_division(self):
l1, l2 = root = tree('-1 / 2') l1, l2 = root = tree('-1 / 2')
self.assertEqualNodes(single_negated_division(root, (l1[0], l2)), self.assertEqualNodes(single_negated_division(root, (+l1, l2)),
-(l1[0] / l2)) -(+l1 / l2))
l1, l2 = root = tree('1 / -2') l1, l2 = root = tree('1 / -2')
self.assertEqualNodes(single_negated_division(root, (l1, l2[0])), self.assertEqualNodes(single_negated_division(root, (l1, +l2)),
-(l1 / l2[0])) -(l1 / +l2))
def test_double_negated_division(self): def test_double_negated_division(self):
l1, l2 = root = tree('-1 / -2') l1, l2 = root = tree('-1 / -2')
self.assertEqualNodes(double_negated_division(root, (root,)), self.assertEqualNodes(double_negated_division(root, (root,)),
l1[0] / l2[0]) +l1 / +l2)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment