def test_less_transitive(x, y, z): with xfail_if_not_implemented(): xy = try_decide_less(x, y) yz = try_decide_less(y, z) xz = try_decide_less(x, z) if xy is True and yz is True: assert xz is True elif xz is False: assert xy is not True or yz is not True
def test_J_equals_I(): """Example from huet1998regular pp. 8.""" p = Presentation() # J x y = (x (J y)) p.define('J', make_combinator(2, make_headex(0, make_pattern('J', 1)))) # I x = x p.define('I', make_combinator(1, make_headex(0))) with xfail_if_not_implemented(): assert p.decide_equal('I', 'J')
def test_try_compute_step_runs(term): for step in xrange(5): with xfail_if_not_implemented(): result = bohm.try_compute_step(term) if is_normal(term): assert result is None return else: assert isinstance(result, Term)
def test_try_compute_step_runs(code): for step in xrange(5): with xfail_if_not_implemented(): result = try_compute_step(code) if is_normal(code): assert result is None return else: assert is_code(result)
def test_fixed_points(): """Example from huet1998regular pp. 6.""" p = Presentation() # Y f = f(Y(f)) p.define('Y', make_combinator(1, make_headex(0, make_pattern('Y', 0)))) # Z0 f = f(Z1(f)) p.define('Z1', make_combinator(1, make_headex(0, make_pattern('Z0', 0)))) # Z1 f = f(Z0(f)) p.define('Z0', make_combinator(1, make_headex(0, make_pattern('Z1', 0)))) with xfail_if_not_implemented(): assert p.decide_equal('Y', 'Z0') assert p.decide_equal('Y', 'Z1') assert p.decide_equal('Z0', 'Z1')
def test_reduce_equations(term, expected, message): with xfail_if_not_implemented(): actual = reduce(term) expected = convert(expected) assert actual == expected, message
def test_try_compute_step(term, expected): with xfail_if_not_implemented(): assert bohm.try_compute_step(term) is expected
def test_convert_runs(sexpr): term = sexpr_parse(sexpr) with xfail_if_not_implemented(): graph = convert(term) assert isinstance(graph, Graph)
def test_reduce_equations(term, expected, message): with xfail_if_not_implemented(): actual = bohm.reduce(term) expected = bohm.simplify(expected) assert actual == expected, message
def test_app(fun, arg, expected): with xfail_if_not_implemented(): assert pretty(app(fun, arg)) == pretty(expected)
def test_simplify_runs(code): with xfail_if_not_implemented(): engine.simplify(code)
def test_simplify_runs_quoted(quoted): with xfail_if_not_implemented(): engine.simplify(quoted)
def test_trace_reduce_equations(code, expected, message): with xfail_if_not_implemented(): actual = engine.reduce(code, BUDGET) assert actual == expected, message
def test_less_join(x, y): with xfail_if_not_implemented(): assert try_decide_less(x, x | y) is True
def test_try_compute_step(code, expected): with xfail_if_not_implemented(): assert try_compute_step(code) is expected
def test_app(fun, arg, expected): with xfail_if_not_implemented(): assert app(fun, arg) is expected
def test_is_linear_app(lhs, rhs): if is_linear(lhs) and is_linear(rhs): with xfail_if_not_implemented(): assert is_linear(lhs(rhs)) assert is_linear(rhs(lhs))