def test_cond(text, expected): ast = translate(text) assert expected == execute(ast, default_context())
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())