Skip to content

Commit

Permalink
Implemented support for tuples in unquote_bind
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Mikulicic committed Jul 30, 2012
1 parent 1329519 commit 73a4b15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 5 additions & 1 deletion metacontext/template.py
Expand Up @@ -29,7 +29,11 @@ def __init__(self):
self.bound_vars = {}

def translate(self, translator, body, args, var):
self.bound_vars[var.id] = args.args[0]
if isinstance(var, ast.Tuple):
for i, v in enumerate(var.elts):
self.bound_vars[v.id] = args.args[i]
else:
self.bound_vars[var.id] = args.args[0]
return body


Expand Down
13 changes: 6 additions & 7 deletions metacontext/tests/testcontext.py
Expand Up @@ -23,11 +23,10 @@ def template(self, translator, body, args, var):
time_module = ast.Name(translator.gensym(), ast.Load())

with quote() as q:
with unquote_bind(var) as res:
with unquote_bind(time_module) as _time:
import time as _time
_start = _time.time()
unquote_stmts(body)
res = _time.time() - _start
unquote_stmts(log)
with unquote_bind(var, time_module) as (res, _time):
import time as _time
_start = _time.time()
unquote_stmts(body)
res = _time.time() - _start
unquote_stmts(log)
return q

0 comments on commit 73a4b15

Please sign in to comment.