return True my_falsify("replace if", lambda x, y, z: replace_if(x, y, z) == (z if x in y else x), int, [int], str) def replace_if_prop(x, y, z): return replace_if(x, y, z) == (z if x in y else x) my_falsify("replace if2", replace_if_prop, int, [int], str) my_falsify("replace alternating", lambda ss, ts, rs: for_all_not_in(ts, replace_alternating(ss, ts, rs), rs), [str], [str], [str]) my_falsify("cycle1", lambda x: (not x) or (get_from_gen(cycle(x), 0) == get_from_gen(cycle(x), len(x))), [int]) my_falsify("cycle false", lambda x: (not x) or (get_from_gen(cycle(x), 1) == get_from_gen(cycle(x), 2 + 2 * len(x))), # +1 would be correct [int]) my_falsify("strict evaluation", lambda x: implies(x, (get_from_gen(cycle(x), 0) == get_from_gen(cycle(x), len(x)))), [int])
def test_replace_alternating(ss, ts, rs): assert for_all_not_in(ts, replace_alternating(ss, ts, rs), rs)