adding in kwapply things.
This commit is contained in:
parent
b1c3a758f9
commit
4ce12c93a5
@ -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("<")
|
||||
|
@ -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"})))
|
||||
|
4
tests/resources/__init__.py
Normal file
4
tests/resources/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
def kwtest(*args, **kwargs):
|
||||
return kwargs
|
Loading…
x
Reference in New Issue
Block a user