Commit 4fd27cc2 authored by Taddeus Kroes's avatar Taddeus Kroes

Added some more unit tests for line generator.

parent cf2d2ce4
...@@ -100,21 +100,25 @@ class TestLine(unittest.TestCase): ...@@ -100,21 +100,25 @@ class TestLine(unittest.TestCase):
a, b, c, l2 = L('a'), L('b'), L('c'), L(2) a, b, c, l2 = L('a'), L('b'), L('c'), L(2)
mul = N('*', a, b) mul = N('*', a, b)
self.assertEquals(generate_line(mul), 'ab') self.assertEquals(generate_line(mul), 'ab')
mul = N('*', mul, c) mul = N('*', mul, c)
self.assertEquals(generate_line(mul), 'abc') self.assertEquals(generate_line(mul), 'abc')
mul = N('*', N('*', a, l2), b)
self.assertEquals(generate_line(mul), 'a * 2b')
mul = N('*', a, N('-', b, c)) mul = N('*', a, N('-', b, c))
self.assertEquals(generate_line(mul), 'a(b - c)') self.assertEquals(generate_line(mul), 'a(b - c)')
mul = N('*', l2, N('-', b, c))
self.assertEquals(generate_line(mul), '2(b - c)')
mul = N('*', N('+', a, b), c) mul = N('*', N('+', a, b), c)
self.assertEquals(generate_line(mul), '(a + b)c') self.assertEquals(generate_line(mul), '(a + b)c')
mul = N('*', N('+', a, b), l2)
self.assertEquals(generate_line(mul), '(a + b) * 2')
mul = N('*', N('+', a, b), N('+', c, l2)) mul = N('*', N('+', a, b), N('+', c, l2))
self.assertEquals(generate_line(mul), '(a + b)(c + 2)') self.assertEquals(generate_line(mul), '(a + b)(c + 2)')
mul = N('*', l2, a) mul = N('*', l2, a)
self.assertEquals(generate_line(mul), '2a') self.assertEquals(generate_line(mul), '2a')
mul = N('*', a, l2) mul = N('*', a, l2)
self.assertEquals(generate_line(mul), 'a * 2') self.assertEquals(generate_line(mul), 'a * 2')
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