Esempio n. 1
0
def tree(data, height=None):
    if height is None:
        height = st.integer_range(0, 100)(data)
    if height == 0:
        return st.n_byte_unsigned(8)(data)
    heights = st.integer_range(0, height - 1)
    l = heights(data)
    r = heights(data)
    return (tree.base(data, l), tree.base(data, r))
Esempio n. 2
0
def tree(data, height=None):
    if height is None:
        height = st.integer_range(0, 100)(data)
    if height == 0:
        return st.n_byte_unsigned(8)(data)
    heights = st.integer_range(0, height - 1)
    l = heights(data)
    r = heights(data)
    return (tree.base(data, l), tree.base(data, r))
Esempio n. 3
0
def test_constant_lists_through_flatmap():
    x = find(
        st.integer_range(0, 99).flatmap(lambda x: st.lists(st.just(x))),
        lambda x: sum(x) >= 100
    )
    assert sum(x[:-1]) < 100
    assert len(x) * (x[0] - 1) < 100
Esempio n. 4
0
def test_constant_lists_through_flatmap():
    x = find(
        st.integer_range(0, 99).flatmap(lambda x: st.lists(st.just(x))),
        lambda x: sum(x) >= 100)
    assert sum(x[:-1]) < 100
    assert len(x) * (x[0] - 1) < 100