Skip to content
Snippets Groups Projects
Commit bb3c5d23 authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Fixed fraction division line generator.

parent 7f65d03d
No related branches found
No related tags found
No related merge requests found
...@@ -143,7 +143,7 @@ def generate_line(root): ...@@ -143,7 +143,7 @@ def generate_line(root):
elif child_pred < node_pred: elif child_pred < node_pred:
exp = '(' + exp + ')' exp = '(' + exp + ')'
elif child_pred == node_pred: 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)): or (op == '+' and child[1].negated)):
exp = '(' + exp + ')' exp = '(' + exp + ')'
elif not i and op == '^': elif not i and op == '^':
......
...@@ -221,3 +221,10 @@ class TestLine(unittest.TestCase): ...@@ -221,3 +221,10 @@ class TestLine(unittest.TestCase):
def test_double_negation(self): def test_double_negation(self):
neg = --L(1) neg = --L(1)
self.assertEquals(generate_line(neg), '--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)')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment