Exemplo n.º 1
0
def test_lazy_register():
    def f():
        return 3

    def g():
        return f()

    def reg_func():
        1 / 0

    lazy_register(f, reg_func)

    py.test.raises(ZeroDivisionError, interpret, g, [])
Exemplo n.º 2
0
def test_lazy_register():
    def f():
        return 3

    def g():
        return f()
    
    def reg_func():
        1/0

    lazy_register(f, reg_func)

    py.test.raises(ZeroDivisionError, interpret, g, [])
Exemplo n.º 3
0
def test_lazy_register_extdef():
    def g():
        return 3

    x = []

    def register_g():
        x.append('g')
        return extdef([], int, llimpl=lambda: 21)

    nothing = lazy_register(g, register_g)

    assert x == ['g']
    assert nothing is None
    assert interpret(lambda: g(), []) == 21
Exemplo n.º 4
0
def test_lazy_register_extdef():
    def g():
        return 3

    x = []

    def register_g():
        x.append('g')
        return extdef([], int, llimpl=lambda : 21)

    nothing = lazy_register(g, register_g)

    assert x == ['g']
    assert nothing is None
    assert interpret(lambda : g(), []) == 21