示例#1
0
文件: testeval.py 项目: charyorde/dao
 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)
示例#2
0
文件: dinpy.py 项目: hermetique/dao
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))
示例#3
0
文件: testeval.py 项目: charyorde/dao
 def test_unwind_protect2(self):
   eq_(eval(block('foo', unwind_protect(exit_block('foo', 1), 
                           prin(2), prin(3)))), 1)
示例#4
0
文件: dinpy.py 项目: charyorde/dao
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))