def test_none_restricted(self): x = self.new_binding("x") y = self.new_binding("y") c = state._restrict_condition(self._node, self._parent, [x, y], False) self.assertIs(self._parent, c) c = state._restrict_condition(self._node, self._parent, [x, y], True) self.assertIs(self._parent, c)
def test_some_restricted_with_parent(self): x = self.new_binding() # Can be true or false. y = self.new_binding(ONLY_FALSE) z = self.new_binding() # Can be true or false. c = state._restrict_condition(self._node, [x, y, z], True) self.check_binding("x=? | z=?", c.binding, x=x, y=y, z=z)
def test_some_restricted_no_parent(self): x = self.new_binding("x") # Can be true or false. y = self.new_binding("y", ONLY_FALSE) z = self.new_binding("z") # Can be true or false. c = state._restrict_condition(self._node, None, [x, y, z], True) self.assertIsNone(c.parent) self.check_binding("x=? | z=?", c.binding)
def test_some_restricted_with_parent(self): x = self.new_binding("x") # Can be true or false. y = self.new_binding("y", ONLY_FALSE) z = self.new_binding("z") # Can be true or false. c = state._restrict_condition(self._node, self._parent, [x, y, z], True) self.assertIs(self._parent, c.parent) self.check_binding("__split=None x=? | __split=None z=?", c.binding)
def test_restricted_to_dnf(self): # DNF for a | (b & c) dnf = [[self.new_binding("a")], [self.new_binding("b"), self.new_binding("c")]] x = self.new_binding("x") # Compatible with everything y = self.new_binding("z", FakeValue("DNF", dnf, False)) # Reduce to dnf c = state._restrict_condition(self._node, None, [x, y], True) self.assertIsNone(c.parent) self.check_binding("a=? | b=? c=? | x=?", c.binding)
def test_restricted_to_dnf(self): # DNF for a | (b & c) a = self.new_binding() b = self.new_binding() c = self.new_binding() dnf = [[a], [b, c]] x = self.new_binding() # Compatible with everything y = self.new_binding(FakeValue("DNF", dnf, False)) # Reduce to dnf cond = state._restrict_condition(self._node, [x, y], True) self.check_binding("a=? | b=? c=? | x=?", cond.binding, a=a, b=b, c=c, x=x, y=y)
def test_all_restricted(self): x = self.new_binding(ONLY_FALSE) y = self.new_binding(ONLY_FALSE) c = state._restrict_condition(self._node, [x, y], True) self.assertIs(state.UNSATISFIABLE, c)
def test_none_restricted(self): x = self.new_binding() y = self.new_binding() state._restrict_condition(self._node, [x, y], False) state._restrict_condition(self._node, [x, y], True)
def test_no_bindings(self): c = state._restrict_condition(self._node, [], False) self.assertIs(state.UNSATISFIABLE, c) c = state._restrict_condition(self._node, [], True) self.assertIs(state.UNSATISFIABLE, c)