def test_UnevaluatedOnFree(): a = UnevaluatedOnFree(Q.positive) b = UnevaluatedOnFree(Q.positive | Q.negative) c = UnevaluatedOnFree(Q.positive & ~Q.positive) # It shouldn't do any deduction assert a.rcall(x) == UnevaluatedOnFree(Q.positive(x)) assert b.rcall(x) == UnevaluatedOnFree(Q.positive(x) | Q.negative(x)) assert c.rcall(x) == UnevaluatedOnFree(Q.positive(x) & ~Q.positive(x)) assert a.rcall(x).expr == x assert a.rcall(x).pred == Q.positive assert b.rcall(x).pred == Q.positive | Q.negative raises(ValueError, lambda: UnevaluatedOnFree(Q.positive(x) | Q.negative)) raises(ValueError, lambda: UnevaluatedOnFree(Q.positive(x) | Q.negative(y))) class MyUnevaluatedOnFree(UnevaluatedOnFree): def apply(self): return self.args[0] a = MyUnevaluatedOnFree(Q.positive) b = MyUnevaluatedOnFree(Q.positive | Q.negative) c = MyUnevaluatedOnFree(Q.positive(x)) d = MyUnevaluatedOnFree(Q.positive(x) | Q.negative(x)) assert a.rcall(x) == c == Q.positive(x) assert b.rcall(x) == d == Q.positive(x) | Q.negative(x) raises(ValueError, lambda: MyUnevaluatedOnFree(Q.positive(x) | Q.negative(y)))