def testNode(self): """Tests a DAFSA with one node can be sorted.""" # 'a' => [ 'a' ] node1 = ( 'a', [ None ] ) source = [ node1 ] nodes = [ node1 ] self.assertEqual(make_dafsa.top_sort(source), nodes)
def testDiamond(self): """Tests nodes in a diamond can be sorted.""" # 'b' # / \ # 'a' 'd' # \ / # 'c' node4 = ( 'd', [ None ] ) node3 = ( 'c', [ node4 ] ) node2 = ( 'b', [ node4 ] ) node1 = ( 'a', [ node2, node3 ] ) source = [ node1 ] nodes = make_dafsa.top_sort(source) self.assertLess(nodes.index(node1), nodes.index(node2)) self.assertLess(nodes.index(node2), nodes.index(node4)) self.assertLess(nodes.index(node3), nodes.index(node4))