def test_AnyArgs(): a = AnyArgs(Q.zero) b = AnyArgs(Q.positive & Q.negative) assert a.rcall(x * y) == Or(Q.zero(x), Q.zero(y)) assert b.rcall(x * y) == Or( Q.positive(x) & Q.negative(x), Q.positive(y) & Q.negative(y))
def test_class_handler_registry(): my_handler_registry = ClassFactRegistry() # The predicate doesn't matter here, so just use is_true fact1 = Equivalent(Q.is_true, AllArgs(Q.is_true)) fact2 = Equivalent(Q.is_true, AnyArgs(Q.is_true)) my_handler_registry[Mul] = {fact1} my_handler_registry[Expr] = {fact2} assert my_handler_registry[Basic] == set() assert my_handler_registry[Expr] == {fact2} assert my_handler_registry[Mul] == {fact1, fact2}
def test_AnyArgs(): a = AnyArgs(Q.zero) b = AnyArgs(Q.positive & Q.negative) assert a.rcall(x*y) == Or(Q.zero(x), Q.zero(y)) assert b.rcall(x*y) == Or(Q.positive(x) & Q.negative(x), Q.positive(y) & Q.negative(y))