Example #1
0
def test_equal_symmetric(x, y):
    hypothesis.assume(x is not y)
    equal_xy = simplify(lib.equal(x, y))
    equal_yx = simplify(lib.equal(y, x))
    hypothesis.assume(equal_xy in bool_values)
    hypothesis.assume(equal_yx in bool_values)
    assert equal_xy is equal_yx
Example #2
0
def test_less_antisymmetric(x, y):
    hypothesis.assume(x is not y)
    less_xy = simplify(lib.less(x, y))
    less_yx = simplify(lib.less(y, x))
    equal_xy = simplify(lib.equal(x, y))
    hypothesis.assume(less_xy in bool_values)
    hypothesis.assume(less_yx in bool_values)
    if less_xy is true and less_yx is true:
        assert equal_xy is true
    if equal_xy is false:
        assert less_xy is not true or less_yx is not true
Example #3
0
def test_less_transitive(x, y, z):
    # hypothesis.assume(x is not y and x is not z and y is not z)
    less_xy = simplify(lib.less(x, y))
    hypothesis.assume(less_xy in bool_values)
    less_yz = simplify(lib.less(y, z))
    hypothesis.assume(less_yz in bool_values)
    less_xz = simplify(lib.less(x, z))
    hypothesis.assume(less_xz in bool_values)
    if less_xy is true and less_yz is true:
        assert less_xz is true
    if less_xz is false:
        assert less_xy is not true or less_yz is not true
Example #4
0
def test_equal_transitive(x, y, z):
    # hypothesis.assume(x is not y and x is not z and y is not z)
    equal_xy = simplify(lib.equal(x, y))
    hypothesis.assume(equal_xy in bool_values)
    equal_yz = simplify(lib.equal(y, z))
    hypothesis.assume(equal_yz in bool_values)
    equal_xz = simplify(lib.equal(x, z))
    hypothesis.assume(equal_xz in bool_values)
    if equal_xy is true and equal_yz is true:
        assert equal_xz is true
    if equal_xz is false:
        assert equal_xy is false or equal_yz is false
Example #5
0
def test_equal(x, y, expected):
    assert simplify(lib.equal(x, y)) == expected
Example #6
0
def test_simplify_runs(code):
    with xfail_if_not_implemented():
        engine.simplify(code)
Example #7
0
def test_unit_and(x, y, expected):
    assert simplify(lib.unit_and(x, y)) == expected
Example #8
0
def test_unit_test(x, expected):
    assert simplify(lib.unit_test(x)) == expected
Example #9
0
def test_enum_num(y, expected):
    qxs = quote(lib.enum_num)
    assert simplify(lib.enum_contains(qxs, quote(y))) == expected
Example #10
0
def test_num_is_zero(x, expected):
    assert simplify(lib.num_is_zero(x)) == expected
Example #11
0
def test_sum_quote(x, expected):
    quote_inl = lib.unit_quote
    quote_inr = lib.bool_quote
    assert simplify(lib.sum_quote(quote_inl, quote_inr, x)) == expected
Example #12
0
def test_less_reflexive(x):
    less_xx = simplify(lib.less(x, x))
    assert less_xx == true
Example #13
0
def test_less(x, y, expected):
    assert simplify(lib.less(x, y)) == expected
Example #14
0
def test_equal_reflexive(x):
    equal_xx = simplify(lib.equal(x, x))
    assert equal_xx == true
Example #15
0
def test_enum_prod(enum_fst, enum_snd, y, expected):
    qxs = quote(lib.enum_prod(enum_fst, enum_snd))
    assert simplify(lib.enum_contains(qxs, quote(y))) == expected
Example #16
0
def test_byte_get_bit(n, byte):
    for i in xrange(8):
        expected = true if (n & (1 << i)) else false
        assert simplify(lib.byte_get_bit[i](byte)) == expected
Example #17
0
def test_sum_test(x, expected):
    assert simplify(lib.sum_test(x)) == expected
Example #18
0
def test_bool_quote(x, expected):
    assert simplify(lib.bool_quote(x)) == expected
Example #19
0
def test_enum_sum(enum_inl, enum_inr, y, expected):
    qxs = quote(lib.enum_sum(enum_inl, enum_inr))
    assert simplify(lib.enum_contains(qxs, quote(y))) == expected
Example #20
0
def test_bool_if_false(x, expected):
    assert simplify(lib.bool_if_false(x)) == expected
Example #21
0
def test_num_pred(x, expected):
    assert simplify(lib.num_pred(x)) == expected
Example #22
0
def test_maybe_test(x, expected):
    assert simplify(lib.maybe_test(x)) == expected
Example #23
0
def test_list_empty(x, expected):
    assert simplify(lib.list_empty(x)) == expected
Example #24
0
def test_maybe_quote(x, expected):
    quote_some = lib.bool_quote
    assert simplify(lib.maybe_quote(quote_some, x)) == expected
Example #25
0
def test_enum_list(enum_item, y, expected):
    qxs = quote(lib.enum_list(enum_item))
    assert simplify(lib.enum_contains(qxs, quote(y))) == expected
Example #26
0
def test_prod_snd(x, expected):
    assert simplify(lib.prod_snd(x)) == expected
Example #27
0
def test_enum_close(f, xs, expected):
    assert reduce(lib.enum_close(f, xs)) == simplify(expected)
Example #28
0
def test_prod_quote(x, expected):
    quote_fst = lib.unit_quote
    quote_snd = lib.bool_quote
    assert simplify(lib.prod_quote(quote_fst, quote_snd, x)) == expected
Example #29
0
def test_simplify_runs_quoted(quoted):
    with xfail_if_not_implemented():
        engine.simplify(quoted)
Example #30
0
def test_boool_constructed(x, expected):
    assert simplify(app(a_boool, x)) == expected