Commit bb3c5d23 authored by Taddeus Kroes's avatar Taddeus Kroes

Fixed fraction division line generator.

parent 7f65d03d
......@@ -143,7 +143,7 @@ def generate_line(root):
elif child_pred < node_pred:
exp = '(' + exp + ')'
elif child_pred == node_pred:
if i and (op != child.title() \
if i and (op != child.title() or op == '/' \
or (op == '+' and child[1].negated)):
exp = '(' + exp + ')'
elif not i and op == '^':
......
......@@ -221,3 +221,10 @@ class TestLine(unittest.TestCase):
def test_double_negation(self):
neg = --L(1)
self.assertEquals(generate_line(neg), '--1')
def test_divide_fractions(self):
a, b, c, d = L('a'), L('b'), L('c'), L('d')
div = N('/', a, N('/', b, c))
self.assertEquals(generate_line(div), 'a / (b / c)')
div = N('/', N('/', a, b), N('/', c, d))
self.assertEquals(generate_line(div), 'a / b / (c / d)')
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