adding in kwapply things.

This commit is contained in:
Paul R. Tagliamonte 2013-03-09 21:14:30 -05:00
parent b1c3a758f9
commit 4ce12c93a5
3 changed files with 27 additions and 2 deletions

View File

@ -178,6 +178,23 @@ class HyASTCompiler(object):
fn.decorator_list = [self.compile(x) for x in expr]
return fn
@builds("kwapply")
def compile_kwapply_expression(self, expr):
expr.pop(0) # kwapply
call = self.compile(expr.pop(0))
kwargs = expr.pop(0)
if type(call) != ast.Call:
raise TypeError("kwapplying a non-call")
call.keywords = [
ast.keyword(
arg=str(x),
value=self.compile(kwargs[x])
) for x in kwargs]
return call
@builds("=")
@builds("!=")
@builds("<")

View File

@ -1,8 +1,8 @@
;
(import sys)
(import-from tests.resources kwtest)
(import-from os.path exists isdir isfile)
(import sys)
(defn test-sys-argv []
@ -103,3 +103,7 @@
(defn test-decorators []
(assert (= (tfunction) 2)))
(defn test-kwargs []
(assert (= (kwapply (kwtest) {"one" "two"}) {"one" "two"})))

View File

@ -0,0 +1,4 @@
def kwtest(*args, **kwargs):
return kwargs