diff --git a/hy/compiler.py b/hy/compiler.py index 387b23d..fe47c9b 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -328,14 +328,6 @@ def is_unpack(kind, x): and x[0] == "unpack-" + kind) -def ends_with_else(expr): - return (expr and - isinstance(expr[-1], HyExpression) and - expr[-1] and - isinstance(expr[-1][0], HySymbol) and - expr[-1][0] == HySymbol("else")) - - class HyASTCompiler(object): def __init__(self, module_name): @@ -1350,9 +1342,8 @@ class HyASTCompiler(object): orel = Result() if else_expr is not None: - for else_body in else_expr: - orel += self.compile(else_body) - orel += orel.expr_as_stmt() + orel = self._compile_branch(else_expr) + orel += orel.expr_as_stmt() body = self._compile_branch(body) body += body.expr_as_stmt() diff --git a/setup.cfg b/setup.cfg index 18c8fbc..e033c3b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,9 +17,8 @@ exclude_lines = ignore_errors = True [tool:pytest] -# Be sure to include Hy test functions whose names end with "?", -# which will be mangled to begin with "is_". -python_functions=test_* is_test_* +# Be sure to include Hy test functions with mangled names. +python_functions=test_* is_test_* hyx_test_* hyx_is_test_* filterwarnings = once::DeprecationWarning once::PendingDeprecationWarning diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 7e44304..1aa6bef 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -173,8 +173,7 @@ "Don't treat strings as symbols in the calling position" (with [(pytest.raises TypeError)] ("setv" True 3)) ; A special form (with [(pytest.raises TypeError)] ("abs" -2)) ; A function - (with [(pytest.raises TypeError)] ("when" 1 2)) ; A macro - None) ; Avoid https://github.com/hylang/hy/issues/1320 + (with [(pytest.raises TypeError)] ("when" 1 2))) ; A macro (defn test-for-loop [] diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index afacee9..e4400ac 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -194,7 +194,7 @@ (assert (in (mangle "_;a|") s2)) (assert (not (= s1 s2)))) -(defn test-defmacro-g! [] +(defn test-defmacro/g! [] (import ast) (import [astor.code-gen [to-source]]) (import [hy.importer [import_buffer_to_ast]]) @@ -213,8 +213,8 @@ (setv _ast2 (import_buffer_to_ast macro1 "foo")) (setv s1 (to_source _ast1)) (setv s2 (to_source _ast2)) - (assert (in "_;res|" s1)) - (assert (in "_;res|" s2)) + (assert (in (mangle "_;res|") s1)) + (assert (in (mangle "_;res|") s2)) (assert (not (= s1 s2))) ;; defmacro/g! didn't like numbers initially because they @@ -242,8 +242,8 @@ (setv _ast2 (import_buffer_to_ast macro1 "foo")) (setv s1 (to_source _ast1)) (setv s2 (to_source _ast2)) - (assert (in "_;res|" s1)) - (assert (in "_;res|" s2)) + (assert (in (mangle "_;res|") s1)) + (assert (in (mangle "_;res|") s2)) (assert (not (= s1 s2))) ;; defmacro/g! didn't like numbers initially because they