Esempio n. 1
0
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
Esempio n. 2
0
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')
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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')
Esempio n. 6
0
def test_reduce_equations(term, expected, message):
    with xfail_if_not_implemented():
        actual = reduce(term)
        expected = convert(expected)
    assert actual == expected, message
Esempio n. 7
0
def test_try_compute_step(term, expected):
    with xfail_if_not_implemented():
        assert bohm.try_compute_step(term) is expected
Esempio n. 8
0
def test_convert_runs(sexpr):
    term = sexpr_parse(sexpr)
    with xfail_if_not_implemented():
        graph = convert(term)
    assert isinstance(graph, Graph)
Esempio n. 9
0
def test_reduce_equations(term, expected, message):
    with xfail_if_not_implemented():
        actual = bohm.reduce(term)
        expected = bohm.simplify(expected)
    assert actual == expected, message
Esempio n. 10
0
def test_app(fun, arg, expected):
    with xfail_if_not_implemented():
        assert pretty(app(fun, arg)) == pretty(expected)
Esempio n. 11
0
def test_simplify_runs(code):
    with xfail_if_not_implemented():
        engine.simplify(code)
Esempio n. 12
0
def test_simplify_runs_quoted(quoted):
    with xfail_if_not_implemented():
        engine.simplify(quoted)
Esempio n. 13
0
def test_trace_reduce_equations(code, expected, message):
    with xfail_if_not_implemented():
        actual = engine.reduce(code, BUDGET)
    assert actual == expected, message
Esempio n. 14
0
def test_less_join(x, y):
    with xfail_if_not_implemented():
        assert try_decide_less(x, x | y) is True
Esempio n. 15
0
def test_try_compute_step(code, expected):
    with xfail_if_not_implemented():
        assert try_compute_step(code) is expected
Esempio n. 16
0
def test_app(fun, arg, expected):
    with xfail_if_not_implemented():
        assert app(fun, arg) is expected
Esempio n. 17
0
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))