Kaynağa Gözat

Division now has a higher precedece than multiplication (like implemented by MathJax).

Taddeus Kroes 14 yıl önce
ebeveyn
işleme
aade5fc51f
2 değiştirilmiş dosya ile 3 ekleme ve 2 silme
  1. 2 1
      line.py
  2. 1 1
      tests/test_line.py

+ 2 - 1
line.py

@@ -6,7 +6,8 @@ OPERATORS = (
     ('^^', ),
     ('=', ),
     ('+', '-'),
-    ('*', '/', 'mod'),
+    ('*', 'mod'),
+    ('/', ),
     ('^', '_'),
 )
 

+ 1 - 1
tests/test_line.py

@@ -51,7 +51,7 @@ class TestLine(unittest.TestCase):
     def test_parentheses_equal_precedence_left(self):
         a, b, c, d = L('a'), L('b'), L('c'), L('d')
         exp = N('*', N('/', N('*', a, b), c), d)
-        self.assertEquals(generate_line(exp), 'ab / c * d')
+        self.assertEquals(generate_line(exp), '(ab) / c * d')
 
     def test_parentheses_unary(self):
         neg = N('-', N('+', L(1), L(2)))