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