71
71
def make_known_graph(self, ancestry):
72
72
return self.module.KnownGraph(ancestry, do_cache=self.do_cache)
74
def assertDominator(self, graph, rev, dominator, distance):
74
def assertDominator(self, graph, rev, dominator):
75
75
node = graph._nodes[rev]
76
76
self.assertEqual(dominator, node.linear_dominator)
77
self.assertEqual(distance, node.dominator_distance)
79
78
def assertGDFO(self, graph, rev, gdfo):
80
79
node = graph._nodes[rev]
92
91
def test_dominators_ancestry_1(self):
93
92
graph = self.make_known_graph(test_graph.ancestry_1)
94
self.assertDominator(graph, 'rev1', NULL_REVISION, 1)
95
self.assertDominator(graph, 'rev2b', 'rev2b', 0)
96
self.assertDominator(graph, 'rev2a', 'rev2a', 0)
97
self.assertDominator(graph, 'rev3', 'rev2a', 1)
98
self.assertDominator(graph, 'rev4', 'rev4', 0)
93
self.assertDominator(graph, 'rev1', NULL_REVISION)
94
self.assertDominator(graph, 'rev2b', 'rev2b')
95
self.assertDominator(graph, 'rev2a', 'rev2a')
96
self.assertDominator(graph, 'rev3', 'rev2a')
97
self.assertDominator(graph, 'rev4', 'rev4')
100
99
def test_dominators_feature_branch(self):
101
100
graph = self.make_known_graph(test_graph.feature_branch)
102
self.assertDominator(graph, 'rev1', NULL_REVISION, 1)
103
self.assertDominator(graph, 'rev2b', NULL_REVISION, 2)
104
self.assertDominator(graph, 'rev3b', NULL_REVISION, 3)
101
self.assertDominator(graph, 'rev1', NULL_REVISION)
102
self.assertDominator(graph, 'rev2b', NULL_REVISION)
103
self.assertDominator(graph, 'rev3b', NULL_REVISION)
106
105
def test_dominators_extended_history_shortcut(self):
107
106
graph = self.make_known_graph(test_graph.extended_history_shortcut)
108
self.assertDominator(graph, 'a', NULL_REVISION, 1)
109
self.assertDominator(graph, 'b', 'b', 0)
110
self.assertDominator(graph, 'c', 'b', 1)
111
self.assertDominator(graph, 'd', 'b', 2)
112
self.assertDominator(graph, 'e', 'e', 0)
113
self.assertDominator(graph, 'f', 'f', 0)
107
self.assertDominator(graph, 'a', NULL_REVISION)
108
self.assertDominator(graph, 'b', 'b')
109
self.assertDominator(graph, 'c', 'b')
110
self.assertDominator(graph, 'd', 'b')
111
self.assertDominator(graph, 'e', 'e')
112
self.assertDominator(graph, 'f', 'f')
115
114
def test_gdfo_ancestry_1(self):
116
115
graph = self.make_known_graph(test_graph.ancestry_1)