From ea899471af5caccdf27089c0a2e1c4dab0bfe1e9 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 29 May 2018 11:47:46 -0700 Subject: [PATCH 1/5] Remove an unused compiler function --- hy/compiler.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 387b23d..3d584e6 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): From c3d4c7aa82aece3e05ff7fc47de5c63df445b672 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 29 May 2018 13:26:02 -0700 Subject: [PATCH 2/5] Clean up `else` compilation in `while` --- hy/compiler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 3d584e6..fe47c9b 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -1342,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() From 65e620ed558fcad2f5527e377630becca986e9bf Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Wed, 30 May 2018 10:48:28 -0700 Subject: [PATCH 3/5] Remove an obsolete bug workaround in a test --- tests/native_tests/language.hy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 [] From 498a54e770610c1af720a91ffaec0e46669a4b02 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Wed, 30 May 2018 10:42:00 -0700 Subject: [PATCH 4/5] Fix discovery of tests with mangled names --- setup.cfg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 From d621d7c3ab680f5a36915e1f28fad642d11f9883 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 5 Jun 2018 17:08:13 -0700 Subject: [PATCH 5/5] Update defmacro(/g)! tests for mangling --- tests/native_tests/native_macros.hy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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