Ejemplo n.º 1
0
def test_try_decide_less_join(lhs, rhs):
    assert try_decide_less_weak(lhs, join(lhs, rhs)) is True
    assert try_decide_less_weak(rhs, join(lhs, rhs)) is True
Ejemplo n.º 2
0
def test_join_idempotent_1(term):
    assert join(term, term) is term
Ejemplo n.º 3
0
def test_join_idempotent_2(lhs, rhs):
    expected = join(lhs, rhs)
    assert join(lhs, expected) is expected
    assert join(rhs, expected) is expected
Ejemplo n.º 4
0
def test_join_associative(x, y, z):
    assert join(join(x, y), z) is join(x, join(y, z))
Ejemplo n.º 5
0
def test_join_commutative(lhs, rhs):
    assert join(lhs, rhs) is join(rhs, lhs)
Ejemplo n.º 6
0
def test_join_bot(term):
    assert join(term, BOT) is term
    assert join(BOT, term) is term
Ejemplo n.º 7
0
def test_join_top(term):
    assert join(term, TOP) is TOP
    assert join(TOP, term) is TOP
Ejemplo n.º 8
0
def test_join(lhs, rhs, expected):
    assert join(lhs, rhs) is expected
Ejemplo n.º 9
0
    (QQUOTE, ABS(QQUOTE)),
]


@for_each(ABSTRACT_EXAMPLES)
def test_abstract(term, expected):
    assert bohm.abstract(term) is expected


@hypothesis.given(s_terms)
def test_abstract_eta(term):
    assert bohm.abstract(app(bohm.increment_rank(term), i0)) is term


@hypothesis.given(s_terms)
@hypothesis.example(join(TOP, APP(QUOTE(i1), i0)))
def test_app_abstract(term):
    hypothesis.assume(i0 not in quoted_vars(term))
    assert app(bohm.increment_rank(bohm.abstract(term)), i0) is term


QABSTRACT_EXAMPLES = [
    (i0, EVAL),
    (i1, ABS(i1)),
]


@for_each(QABSTRACT_EXAMPLES)
def test_qabstract(term, expected):
    assert bohm.qabstract(term) is expected
Ejemplo n.º 10
0
    (JOIN(IVAR(0), x), JOIN(ABS(IVAR(0)), ABS(x))),
    (QUOTE(IVAR(0)), ABS(QUOTE(IVAR(0)))),
    (APP(QUOTE(IVAR(0)), IVAR(0)), QUOTE(IVAR(0))),
    (EVAL, ABS(EVAL)),
    (QAPP, ABS(QAPP)),
    (QQUOTE, ABS(QQUOTE)),
]


@for_each(ABSTRACT_EXAMPLES)
def test_abstract(code, expected):
    assert abstract(code) is expected


@hypothesis.given(s_codes)
@hypothesis.example(join(TOP, ABS(IVAR(0))))
def test_abstract_eta(code):
    hypothesis.assume(is_const(code))
    assert abstract(app(code, IVAR(0))) is decrement_rank(code)


@for_each([
    (x, x, IVAR(0)),
    (y, x, y),
    (IVAR(0), x, IVAR(1)),
    (EVAL, x, EVAL),
    (ABS(IVAR(0)), x, ABS(IVAR(0))),
    (APP(x, x), x, APP(IVAR(0), IVAR(0))),
    (JOIN(x, y), x, JOIN(IVAR(0), y)),
    (JOIN(x, y), y, JOIN(IVAR(0), x)),
    (QUOTE(x), x, QUOTE(x)),