コード例 #1
0
def test_lanyseq():
    x = var()
    g = lany((eq(x, i) for i in range(3)))
    assert list(g({})) == [{x: 0}, {x: 1}, {x: 2}]
    assert list(g({})) == [{x: 0}, {x: 1}, {x: 2}]

    # Test lanyseq with an infinite number of goals.
    assert set(run(3, x, lany((eq(x, i) for i in count())))) == {0, 1, 2}
    assert set(run(3, x, lany((eq(x, i) for i in count())))) == {0, 1, 2}
コード例 #2
0
def test_lany():
    x = var('x')
    assert len(tuple(lany(eq(x, 2), eq(x, 3))({}))) == 2
    assert len(tuple(lany((eq, x, 2), (eq, x, 3))({}))) == 2
コード例 #3
0
def test_lany_is_early_safe():
    x = var()
    y = var()
    assert run(0, x, lany((membero, x, y), (eq, x, 2))) == (2, )