def test_InteriorNode_prefixTest1(self): leaf1 = LeafNode(5) leaf2 = LeafNode(10) node1 = InteriorNode(Token('+'), leaf1, leaf2) node2 = InteriorNode(Token('*'), leaf1, node1) node3 = InteriorNode(Token('-'), node2, leaf2) s = "- * 5 + 5 10 10" print(node3.prefix()) self.assertEqual(node3.prefix(), s)
def test_InteriorNode_prefixTest2(self): leaf1 = LeafNode(72) leaf2 = LeafNode(14) node1 = InteriorNode(Token('+'), leaf1, leaf2) node2 = InteriorNode(Token('*'), leaf1, node1) node3 = InteriorNode(Token('/'), node2, leaf2) s = "/ * 72 + 72 14 14" self.assertEqual(node3.prefix(), s)