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