Rename decorate-with' to with-decorator'

Fixes #158

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2013-04-28 17:14:22 +02:00
parent 08fbd754b6
commit 2ef9a0fdaf
7 changed files with 18 additions and 19 deletions

View File

@ -703,10 +703,10 @@ class HyASTCompiler(object):
ctx=ast.Store())],
value=self.compile(val))
@builds("decorate_with")
@builds("with_decorator")
@checkargs(min=1)
def compile_decorate_expression(self, expr):
expr.pop(0) # decorate-with
expr.pop(0) # with-decorator
fn = self.compile(expr.pop(-1))
if type(fn) != ast.FunctionDef:
raise HyTypeError(expr, "Decorated a non-function")

View File

@ -40,7 +40,7 @@ def router(tree, rkwargs=None):
route = HyExpression([HySymbol("kwapply"), route,
HyDict({HyString("methods"): rkwargs})])
return HyExpression([HySymbol("decorate_with"), route, tree])
return HyExpression([HySymbol("with_decorator"), route, tree])
@macro("route")

View File

@ -64,7 +64,7 @@ class FunctionMangle(HoistableMangle):
an anon function "((fn [] ...))", or using it as an arg in a call)
"""
ignore = ["def", "decorate_with", "setf", "setv", "foreach", "do"]
ignore = ["def", "with_decorator", "setf", "setv", "foreach", "do"]
# ^^ these guys don't affect us, really.
def __init__(self):

View File

@ -6,3 +6,4 @@ from .native_tests.math import * # noqa
from .native_tests.language import * # noqa
from .native_tests.unless import * # noqa
from .native_tests.when import * # noqa
from .native_tests.with_decorator import * # noqa

View File

@ -322,7 +322,7 @@ def test_ast_anon_fns_basics():
def test_ast_non_decoratable():
""" Ensure decorating garbage breaks """
cant_compile("(decorate-with (foo) (* x x))")
cant_compile("(with-decorator (foo) (* x x))")
def test_ast_non_kwapplyable():

View File

@ -132,20 +132,6 @@
(assert (is (isfile ".") false)))
(defn foodec [func]
(lambda [] (+ 1 1)))
(decorate-with foodec
(defn tfunction []
(* 2 2)))
(defn test-decorators []
"NATIVE: test decorators."
(assert (= (tfunction) 2)))
(defn test-kwargs []
"NATIVE: test kwargs things."
(assert (= (kwapply (kwtest) {"one" "two"}) {"one" "two"})))

View File

@ -0,0 +1,12 @@
(defn foodec [func]
(lambda [] (+ 1 1)))
(with-decorator foodec
(defn tfunction []
(* 2 2)))
(defn test-decorators []
"NATIVE: test decorators."
(assert (= (tfunction) 2)))