Пример #1
0
def link(code):
    code = as_code(code)
    free = free_vars(code)
    to_bind = sorted(var for var in free if var[1].startswith('lib.'))
    for var in to_bind:
        code = bind(code, var)

    return code
Пример #2
0
def test_as_code(arg, expected):
    actual = as_code(arg)
    assert actual == expected
Пример #3
0
def test_link(code, expected):
    expected = as_code(expected)
    actual = link(code)
    assert actual == expected
Пример #4
0
def bind(code, var):
    assert var[1].startswith('lib.')
    name = var[1][4:]
    defn = getattr(lib, name)  # raises AttributeError if not found.
    return substitute(var, as_code(defn), code)
Пример #5
0
def test_intro_forms(name, native):
    assert as_code(getattr(lib, name)) == as_code(native)
Пример #6
0
def test_fun_type_fixes(value, type_):
    assert reduce(app(type_, value)) == reduce(as_code(value))
Пример #7
0
def test_compose(f, g, expected):
    assert reduce(as_code(compose(f, g))) == simplify(as_code(expected))