Commit 122476b1 authored by Taddeus Kroes's avatar Taddeus Kroes

Added negation to node stringification.

parent b3cbdd4e
......@@ -32,7 +32,8 @@ class Node(object):
return copy
def __str__(self):
return '<Node value=%s nodes=%s>' % (str(self.value), str(self.nodes))
return '<Node value=%s nodes=%s negated=%d>' \
% (str(self.value), str(self.nodes), self.negated)
def title(self):
return str(self.value)
......@@ -52,4 +53,4 @@ class Leaf(Node):
return repr(self.value)
def __str__(self):
return str(self.value)
return '-' * self.negated + str(self.value)
......@@ -34,3 +34,11 @@ class TestNode(unittest.TestCase):
def test_title(self):
assert self.node.title() == 'node'
assert self.l0.title() == 'leaf 1'
def test____str__(self):
l1 = Leaf(1)
self.assertEqual(str(l1), '1')
l1 = -l1
self.assertEqual(str(l1), '-1')
l1 = -l1
self.assertEqual(str(l1), '--1')
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