|
|
@@ -39,3 +39,16 @@ class TestLine(unittest.TestCase):
|
|
|
l0, l1, l2 = Leaf(1), Leaf(2), Leaf(3)
|
|
|
plus = Node('+', l0, l1, l2)
|
|
|
self.assertEquals(generate_line(plus), '1 + 2 + 3')
|
|
|
+
|
|
|
+ def test_pow_basic(self):
|
|
|
+ a, b, c = Leaf('a'), Leaf('b'), Leaf('c')
|
|
|
+ node_pow = Node('^', a, Node('+', b, c))
|
|
|
+ self.assertEquals(generate_line(node_pow), 'a ^ (b + c)')
|
|
|
+
|
|
|
+ def test_pow_intermediate(self):
|
|
|
+ a, b, c, d, e = Leaf('a'), Leaf('b'), Leaf('c'), Leaf('d'), Leaf('e')
|
|
|
+ node_bc = Node('+', b, c)
|
|
|
+ node_de = Node('+', d, e)
|
|
|
+ node_mul = Node('*', a, node_bc)
|
|
|
+ node_pow = Node('^', node_mul, node_de)
|
|
|
+ self.assertEquals(generate_line(node_pow), 'a * (b + c) ^ (d + e)')
|