|
@@ -15,22 +15,27 @@ class TestLine(unittest.TestCase):
|
|
|
def test_simple(self):
|
|
def test_simple(self):
|
|
|
l0, l1 = Leaf(1), Leaf(2)
|
|
l0, l1 = Leaf(1), Leaf(2)
|
|
|
plus = Node('+', l0, l1)
|
|
plus = Node('+', l0, l1)
|
|
|
- assert generate_line(plus) == '1 + 2'
|
|
|
|
|
|
|
+ self.assertEquals(generate_line(plus), '1 + 2')
|
|
|
|
|
|
|
|
def test_parentheses(self):
|
|
def test_parentheses(self):
|
|
|
l0, l1 = Leaf(1), Leaf(2)
|
|
l0, l1 = Leaf(1), Leaf(2)
|
|
|
plus = Node('+', l0, l1)
|
|
plus = Node('+', l0, l1)
|
|
|
times = Node('*', plus, plus)
|
|
times = Node('*', plus, plus)
|
|
|
- assert generate_line(times) == '(1 + 2) * (1 + 2)'
|
|
|
|
|
|
|
+ self.assertEquals(generate_line(times), '(1 + 2) * (1 + 2)')
|
|
|
|
|
|
|
|
def test_function(self):
|
|
def test_function(self):
|
|
|
exp = Leaf('x')
|
|
exp = Leaf('x')
|
|
|
inf = Leaf('oo')
|
|
inf = Leaf('oo')
|
|
|
minus_inf = Node('-', inf)
|
|
minus_inf = Node('-', inf)
|
|
|
integral = Node('int', exp, minus_inf, inf)
|
|
integral = Node('int', exp, minus_inf, inf)
|
|
|
- assert generate_line(integral) == 'int(x, -oo, oo)'
|
|
|
|
|
|
|
+ self.assertEquals(generate_line(integral), 'int(x, -oo, oo)')
|
|
|
|
|
|
|
|
def test_mod(self):
|
|
def test_mod(self):
|
|
|
l0, l1 = Leaf(1), Leaf(2)
|
|
l0, l1 = Leaf(1), Leaf(2)
|
|
|
mod = Node('mod', l1, l0)
|
|
mod = Node('mod', l1, l0)
|
|
|
- assert generate_line(mod) == '2 mod 1'
|
|
|
|
|
|
|
+ self.assertEquals(generate_line(mod), '2 mod 1')
|
|
|
|
|
+
|
|
|
|
|
+ def test_n_ary(self):
|
|
|
|
|
+ l0, l1, l2 = Leaf(1), Leaf(2), Leaf(3)
|
|
|
|
|
+ plus = Node('+', l0, l1, l2)
|
|
|
|
|
+ self.assertEquals(generate_line(plus), '1 + 2 + 3')
|