def test_draw_write_round_trip(f):
    d = ConjectureData.for_buffer(hbytes(10))
    flt.write_float(d, f)
    d2 = ConjectureData.for_buffer(d.buffer)
    g = flt.draw_float(d2)

    if f == f:
        assert f == g

    assert float_to_int(f) == float_to_int(g)

    d3 = ConjectureData.for_buffer(d2.buffer)
    flt.draw_float(d3)
    assert d3.buffer == d2.buffer
def test_draw_write_round_trip(f):
    d = ConjectureData.for_buffer(bytes(10))
    flt.write_float(d, f)
    d2 = ConjectureData.for_buffer(d.buffer)
    g = flt.draw_float(d2)

    if f == f:
        assert f == g

    assert float_to_int(f) == float_to_int(g)

    d3 = ConjectureData.for_buffer(d2.buffer)
    flt.draw_float(d3)
    assert d3.buffer == d2.buffer
def minimal_from(start, condition):
    runner = float_runner(start, condition)
    runner.shrink_interesting_examples()
    (v, ) = runner.interesting_examples.values()
    result = flt.draw_float(ConjectureData.for_buffer(v.buffer))
    assert condition(result)
    return result
Esempio n. 4
0
 def do_draw(self, data):
     while True:
         data.start_example(FLOAT_STRATEGY_DO_DRAW_LABEL)
         i = self.sampler.sample(data)
         if i == 0:
             result = flt.draw_float(data)
         else:
             result = self.nasty_floats[i - 1]
             flt.write_float(data, result)
         data.stop_example()
         if self.permitted(result):
             return result
 def test_function(data):
     f = flt.draw_float(data)
     if condition(f):
         data.mark_interesting()
 def shrinker(data):
     flt.draw_float(data)
     if hbytes(data.buffer) == base_buf:
         data.mark_interesting()
 def shrinker(data):
     flt.draw_float(data)
     if hbytes(data.buffer) == base_buf:
         data.mark_interesting()