Added some unit tests for exponentiation expressions.

parent 4d65a52b
......@@ -45,10 +45,20 @@ class TestLine(unittest.TestCase):
node_pow = Node('^', a, Node('+', b, c))
self.assertEquals(generate_line(node_pow), 'a ^ (b + c)')
def test_pow_intermediate(self):
def test_pow_intermediate1(self):
# expression: (a(b+c))^(d+e)
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)')
self.assertEquals(generate_line(node_pow), '(a * (b + c)) ^ (d + e)')
def test_pow_intermediate2(self):
# expression: a(b+c)^(d+e)
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_pow = Node('^', node_bc, node_de)
node_mul = Node('*', a, node_pow)
self.assertEquals(generate_line(node_mul), 'a * (b + c) ^ (d + e)')
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