def test_unwind_protect_loop(self): eq_(eval(let([(i,3)], block(a, set(i, sub(i, 1)), if_(eq(i, 0), exit_block(a, 1)), unwind_protect(continue_block(a), prin(2))), i)), 0)
def make_protect(form, cleanup): if len(form) != 1: form = special.begin(*preparse(form)) else: form = preparse(form[0]) return special.unwind_protect(form, *preparse(cleanup))
def test_unwind_protect2(self): eq_(eval(block('foo', unwind_protect(exit_block('foo', 1), prin(2), prin(3)))), 1)
def make_protect(form, cleanup): if len(form)!=1: form = special.begin(*preparse(form)) else: form = preparse(form[0]) return special.unwind_protect(form, *preparse(cleanup))