Ejemplo n.º 1
0
def test_cond(text, expected):
    ast = translate(text)
    assert expected == execute(ast, default_context())
Ejemplo n.º 2
0
def test_definition():
    ast = translate("""
    (define add1 (lambda x (+ x 1)))
    (add1 3)""")
    result = execute(ast, default_context())
    assert 4 == result
Ejemplo n.º 3
0
def test_procedure(text, expected):
    context = default_context()
    print(execute(translate(text), context))
    print(context)
    assert expected == execute(translate(text), default_context())
Ejemplo n.º 4
0
def test_lambda(text, expected):
    context = default_context()
    assert expected == execute(translate(text), default_context())
Ejemplo n.º 5
0
def test_variable():
    ast = translate('a')
    context = default_context()
    result = execute(ast, context.bind(Variable("a"), 1))
    assert 1 == result
Ejemplo n.º 6
0
def test_literal(text, expected):
    print(execute(translate(text), default_context()))
    assert expected == execute(translate(text), default_context())