From d53719e88fd7bc891234500d7a99fa149bda0d39 Mon Sep 17 00:00:00 2001 From: Taddeus Kroes <taddeuskroes@gmail.com> Date: Thu, 13 Sep 2012 11:57:37 +0200 Subject: [PATCH] Fixed previously added rule for all negation cases. --- src/rules/fractions.py | 2 +- tests/test_rules_fractions.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rules/fractions.py b/src/rules/fractions.py index 5948618..52ef3bd 100644 --- a/src/rules/fractions.py +++ b/src/rules/fractions.py @@ -570,7 +570,7 @@ def fraction_in_division(root, args): is_nominator, scope, fraction = args nom, denom = root - if fraction.negated: + if fraction.negated or fraction[0].negated: scope.replace(fraction, fraction[0].negate(fraction.negated)) else: scope.remove(fraction) diff --git a/tests/test_rules_fractions.py b/tests/test_rules_fractions.py index 2873c55..74e198e 100644 --- a/tests/test_rules_fractions.py +++ b/tests/test_rules_fractions.py @@ -383,3 +383,15 @@ class TestRulesFractions(RulesTestCase): root, expected = tree('c / (1 / a * b), (ac) / b') self.assertEqual(fraction_in_division(root, (False, Scope(root[1]), root[1][0])), expected) + + root, expected = tree('c / (-(1 / a) * b), (ac) / ((-1)b)') + self.assertEqual(fraction_in_division(root, + (False, Scope(root[1]), root[1][0])), expected) + + root, expected = tree('c / ((-1) / a * b), (ac) / ((-1)b)') + self.assertEqual(fraction_in_division(root, + (False, Scope(root[1]), root[1][0])), expected) + + root, expected = tree('c / (1 / (-a) * b), ((-a)c) / b') + self.assertEqual(fraction_in_division(root, + (False, Scope(root[1]), root[1][0])), expected) -- 2.26.2