예제 #1
0
파일: test.py 프로젝트: nexxTM/pyamazeballs
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])

my_falsify("lazy implies", lambda x: implies(x, lambda:
                (get_from_gen(cycle(x), 0) == get_from_gen(cycle(x), len(x)))),
           [int])

my_falsify("fix string", lambda s, ps, cs:
                for_all_not_in(ps, fix_string(s, ps, cs), cs),
           str, [str], [str])


class MyInt(int):

    def __new__(cls, v):
        return super(MyInt, cls).__new__(cls, v)


@strategy_for(MyInt)
class MyIntStrategy(SearchStrategy):
    # simplified
    def produce(self, size, flags):
        return MyInt(randint(-2 ** 5, 2 ** 5))
예제 #2
0
파일: test.py 프로젝트: nexxTM/pyamazeballs
 def fix_one(self, problem, correction):
     self.target = fix_string(self.target, [problem], [correction])
     assert problem not in self.target or problem == correction
     self.target = " ".join(self.target)
예제 #3
0
파일: tdd.py 프로젝트: nexxTM/pyamazeballs
def test_fix_string(s, ps, cs):
    assert for_all_not_in(ps, fix_string(s, ps, cs), cs)