Ejemplo n.º 1
0
def test_range_as_function():
    ns = {}
    exec(
        '\n'.join(['def func():'] +
                  ['\t' + x for x in CODE.splitlines() + ['return result']]),
        ns)
    assert with_goto(ns['func'])() == EXPECTED
Ejemplo n.º 2
0
def test_range_as_function():
    ns = {}
    exec('\n'.join(
        ['def func():'] +
        ['\t' + x for x in CODE.splitlines() + ['return result']]
    ), ns)
    assert with_goto(ns['func'])() == EXPECTED
Ejemplo n.º 3
0
def test_function_is_copy():
    def func():
        pass

    func.foo = 'bar'
    newfunc = with_goto(func)

    assert newfunc is not func
    assert newfunc.foo == 'bar'
Ejemplo n.º 4
0
def test_function_is_copy():
    def func():
        pass

    func.foo = 'bar'
    newfunc = with_goto(func)

    assert newfunc is not func
    assert newfunc.foo == 'bar'
Ejemplo n.º 5
0
def test_EXTENDED_ARG():
    code = []
    code.append('result = True')
    code.append('goto .foo')
    for i in range(2**16):
        code.append('label .l{0}'.format(i))
    code.append('result = "dead code"')
    code.append('label .foo')
    assert with_goto(make_function(code))() is True
Ejemplo n.º 6
0
def main():
    print("1、添加目录 2、更新目录")
    a = input()
    if a == "1":
        print("输入想要添加的文件夹目录")
        path = input()
        path = path.replace("\\", "/")
        md5.dir_md5_insert(path, "169.254.252.154")
        with_goto(main())
    if a == "2":
        print("请输入密码:")
        key_1 = input()
        if (md5.string_md5(key_1) == key):
            print("输入想要更新的文件夹目录")
            path = input()
            path = path.replace("\\", "/")
            md5.dir_md5_update(path, "169.254.252.154")
            with_goto(main())
        else:
            print("密码错误")
            with_goto(main())
Ejemplo n.º 7
0
def test_range_as_code():
    ns = {}
    exec(with_goto(compile(CODE, '', 'exec')), ns)
    assert ns['result'] == EXPECTED
Ejemplo n.º 8
0
def test_range_as_code():
    ns = {}
    exec(with_goto(compile(CODE, '', 'exec')), ns)
    assert ns['result'] == EXPECTED
Ejemplo n.º 9
0
def test_range_as_function():
    assert with_goto(make_function(CODE.splitlines()))() == EXPECTED
Ejemplo n.º 10
0
from goto import with_goto

CODIGO = """
a = int(input('Introduce el primer sumando: '))
b = int(input('Introduce el segundo sumando: '))
label .inicio
if a == 0: goto .fin
a -= 1
b += 1
goto .inicio
label .fin
print('La suma vale', b)
"""

exec(with_goto(compile(CODIGO, '', 'exec')))