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