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
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
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
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
def test_equal(x, y, expected): assert simplify(lib.equal(x, y)) == expected
def test_simplify_runs(code): with xfail_if_not_implemented(): engine.simplify(code)
def test_unit_and(x, y, expected): assert simplify(lib.unit_and(x, y)) == expected
def test_unit_test(x, expected): assert simplify(lib.unit_test(x)) == expected
def test_enum_num(y, expected): qxs = quote(lib.enum_num) assert simplify(lib.enum_contains(qxs, quote(y))) == expected
def test_num_is_zero(x, expected): assert simplify(lib.num_is_zero(x)) == expected
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
def test_less_reflexive(x): less_xx = simplify(lib.less(x, x)) assert less_xx == true
def test_less(x, y, expected): assert simplify(lib.less(x, y)) == expected
def test_equal_reflexive(x): equal_xx = simplify(lib.equal(x, x)) assert equal_xx == true
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
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
def test_sum_test(x, expected): assert simplify(lib.sum_test(x)) == expected
def test_bool_quote(x, expected): assert simplify(lib.bool_quote(x)) == expected
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
def test_bool_if_false(x, expected): assert simplify(lib.bool_if_false(x)) == expected
def test_num_pred(x, expected): assert simplify(lib.num_pred(x)) == expected
def test_maybe_test(x, expected): assert simplify(lib.maybe_test(x)) == expected
def test_list_empty(x, expected): assert simplify(lib.list_empty(x)) == expected
def test_maybe_quote(x, expected): quote_some = lib.bool_quote assert simplify(lib.maybe_quote(quote_some, x)) == expected
def test_enum_list(enum_item, y, expected): qxs = quote(lib.enum_list(enum_item)) assert simplify(lib.enum_contains(qxs, quote(y))) == expected
def test_prod_snd(x, expected): assert simplify(lib.prod_snd(x)) == expected
def test_enum_close(f, xs, expected): assert reduce(lib.enum_close(f, xs)) == simplify(expected)
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
def test_simplify_runs_quoted(quoted): with xfail_if_not_implemented(): engine.simplify(quoted)
def test_boool_constructed(x, expected): assert simplify(app(a_boool, x)) == expected