|
|
@@ -1,6 +1,7 @@
|
|
|
from src.rules.fractions import match_constant_division, division_by_one, \
|
|
|
division_of_zero, division_by_self, match_add_constant_fractions, \
|
|
|
- equalize_denominators, add_nominators
|
|
|
+ equalize_denominators, add_nominators, match_multiply_fractions, \
|
|
|
+ multiply_fractions
|
|
|
from src.node import Scope
|
|
|
from src.possibilities import Possibility as P
|
|
|
from tests.rulestestcase import RulesTestCase, tree
|
|
|
@@ -123,3 +124,18 @@ class TestRulesFractions(RulesTestCase):
|
|
|
|
|
|
n0, n1 = root = a / -b + -c / -b
|
|
|
self.assertEqualNodes(add_nominators(root, (n0, n1)), (a + -c) / -b)
|
|
|
+
|
|
|
+ def test_match_multiply_fractions(self):
|
|
|
+ (a, b), (c, d) = ab, cd = root = tree('a / b * (c / d)')
|
|
|
+
|
|
|
+ self.assertEqualPos(match_multiply_fractions(root),
|
|
|
+ [P(root, multiply_fractions, (Scope(root), ab, cd))])
|
|
|
+
|
|
|
+ def test_multiply_fractions(self):
|
|
|
+ (a, b), (c, d) = ab, cd = root = tree('a / b * (c / d)')
|
|
|
+ self.assertEqual(multiply_fractions(root, (Scope(root), ab, cd)),
|
|
|
+ a * c / (b * d))
|
|
|
+
|
|
|
+ (ab, e), cd = root = tree('a / b * e * (c / d)')
|
|
|
+ self.assertEqual(multiply_fractions(root, (Scope(root), ab, cd)),
|
|
|
+ a * c / (b * d) * e)
|