Esempio n. 1
0
def test_conditional(text, expected):
    assert expected == translate(text).commands[0]
Esempio n. 2
0
def test_lambda(text, expected):
    result = translate(text).commands[0]
    assert expected == result
Esempio n. 3
0
def test_definition(text, expected):
    assert expected == translate(text).commands[0]
Esempio n. 4
0
def test_transformer(text, expected):
    assert expected == translate(text, debug=False).commands[0]
Esempio n. 5
0
def test_procedure_call(text, expected):
    result = translate(text).commands[0]
    assert expected == result
Esempio n. 6
0
def test_cond(text, expected):
    ast = translate(text)
    assert expected == execute(ast, default_context())
Esempio n. 7
0
def test_set_(text, expected):
    assert expected == translate(text).commands[0]
Esempio n. 8
0
def test_definition():
    ast = translate("""
    (define add1 (lambda x (+ x 1)))
    (add1 3)""")
    result = execute(ast, default_context())
    assert 4 == result
Esempio n. 9
0
def test_procedure(text, expected):
    context = default_context()
    print(execute(translate(text), context))
    print(context)
    assert expected == execute(translate(text), default_context())
Esempio n. 10
0
def test_lambda(text, expected):
    context = default_context()
    assert expected == execute(translate(text), default_context())
Esempio n. 11
0
def test_variable():
    ast = translate('a')
    context = default_context()
    result = execute(ast, context.bind(Variable("a"), 1))
    assert 1 == result
Esempio n. 12
0
def test_literal(text, expected):
    print(execute(translate(text), default_context()))
    assert expected == execute(translate(text), default_context())