def test_parent_combination(self): p = self.new_binding("p") parent = state.Condition(self._node, None, [[p]]) x = self.new_binding("x") y = self.new_binding("y") z = self.new_binding("z") c = state.Condition(self._node, parent, [[x, y], [z]]) self.assertIs(parent, c.parent) self.check_binding("__split=None x=? y=? | __split=None z=?", c.binding)
def test_parent_combination(self): p = self.new_binding() x = self.new_binding() y = self.new_binding() z = self.new_binding() c = state.Condition(self._node, [[x, y], [z]]) self.check_binding("x=? y=? | z=?", c.binding, p=p, x=x, y=y, z=z)
def test_no_parent(self): x = self.new_binding("x") y = self.new_binding("y") z = self.new_binding("z") c = state.Condition(self._node, None, [[x, y], [z]]) self.assertIsNone(c.parent) self.check_binding("x=? y=? | z=?", c.binding)
def test(self): # Create the following trees (parents are to the left) # # 1 - 2 - 3 - 4 # \ # 5 - 6 # # 7 - 8 conds = [None] # index 0 is the condition of None for number, parent in enumerate([0, 1, 2, 3, 2, 5, 0, 7], 1): binding = self.new_binding("v%d" % number) conds.append( state.Condition(self._node, conds[parent], [[binding]])) def check(expected, left, right): self.assertEquals( conds[expected], state._common_condition(conds[left], conds[right])) # Check that None (conds[0]) is handled correctly. check(0, 0, 0) check(0, 0, 4) check(0, 4, 0) # One condition a descendant of the other. check(2, 2, 4) check(2, 4, 2) # Common ancestor. check(2, 3, 6) check(2, 4, 6) # Unrelated. check(0, 4, 8)
def test(self): # Test that we split both sides and that everything gets passed through # correctly. Don't worry about special cases within _restrict_condition # since those are tested separately. p = self.new_binding("x") parent = state.Condition(self._node, None, [[p]]) var = self._program.NewVariable("v") var.AddBinding(ONLY_TRUE) var.AddBinding(ONLY_FALSE) var.AddBinding(AMBIGUOUS) true_cond, false_cond = state.split_conditions(self._node, parent, var) self.assertIs(parent, true_cond.parent) self.check_binding("__split=None v=? | __split=None v=T", true_cond.binding) self.assertIs(parent, false_cond.parent) self.check_binding("__split=None v=? | __split=None v=F", false_cond.binding)
def setUp(self): super(RestrictConditionTest, self).setUp() p = self.new_binding() self._parent = state.Condition(self._node, [[p]])
def test_no_parent(self): x = self.new_binding() y = self.new_binding() z = self.new_binding() c = state.Condition(self._node, [[x, y], [z]]) self.check_binding("x=? y=? | z=?", c.binding, x=x, y=y, z=z)