def test_do_one():
    def bad(expr):
        raise ValueError()
        yield False

    assert list(do_one(inc)(3)) == [4]
    assert list(do_one(inc, bad)(3)) == [4]
    assert list(do_one(inc, posdec)(3)) == [4]
Esempio n. 2
0
def test_do_one():
    def bad(expr):
        raise ValueError()
        yield False

    assert list(do_one(inc)(3)) == [4]
    assert list(do_one(inc, bad)(3)) == [4]
    assert list(do_one(inc, posdec)(3)) == [4]
Esempio n. 3
0
def test_sall():
    expr = Basic(1, 2)
    expected = Basic(2, 3)
    brl = sall(inc)

    assert list(brl(expr)) == [expected]

    expr = Basic(1, 2, Basic(3, 4))
    expected = Basic(2, 3, Basic(3, 4))
    brl = sall(do_one(inc, identity))

    assert list(brl(expr)) == [expected]
Esempio n. 4
0
def test_sall():
    expr     = Basic(1, 2)
    expected = Basic(2, 3)
    brl = sall(inc)

    assert list(brl(expr)) == [expected]

    expr     = Basic(1, 2, Basic(3, 4))
    expected = Basic(2, 3, Basic(3, 4))
    brl = sall(do_one(inc, identity))

    assert list(brl(expr)) == [expected]
Esempio n. 5
0
def test_sall():
    expr     = Basic(S(1), S(2))
    expected = Basic(S(2), S(3))
    brl = sall(inc)

    assert list(brl(expr)) == [expected]

    expr     = Basic(S(1), S(2), Basic(S(3), S(4)))
    expected = Basic(S(2), S(3), Basic(S(3), S(4)))
    brl = sall(do_one(inc, identity))

    assert list(brl(expr)) == [expected]