Merge pull request #1625 from Kodiologist/potpourri
Miscellaneous small changes
This commit is contained in:
commit
d3bd7c1017
@ -328,14 +328,6 @@ def is_unpack(kind, x):
|
|||||||
and x[0] == "unpack-" + kind)
|
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):
|
class HyASTCompiler(object):
|
||||||
|
|
||||||
def __init__(self, module_name):
|
def __init__(self, module_name):
|
||||||
@ -1350,8 +1342,7 @@ class HyASTCompiler(object):
|
|||||||
|
|
||||||
orel = Result()
|
orel = Result()
|
||||||
if else_expr is not None:
|
if else_expr is not None:
|
||||||
for else_body in else_expr:
|
orel = self._compile_branch(else_expr)
|
||||||
orel += self.compile(else_body)
|
|
||||||
orel += orel.expr_as_stmt()
|
orel += orel.expr_as_stmt()
|
||||||
|
|
||||||
body = self._compile_branch(body)
|
body = self._compile_branch(body)
|
||||||
|
@ -17,9 +17,8 @@ exclude_lines =
|
|||||||
ignore_errors = True
|
ignore_errors = True
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
# Be sure to include Hy test functions whose names end with "?",
|
# Be sure to include Hy test functions with mangled names.
|
||||||
# which will be mangled to begin with "is_".
|
python_functions=test_* is_test_* hyx_test_* hyx_is_test_*
|
||||||
python_functions=test_* is_test_*
|
|
||||||
filterwarnings =
|
filterwarnings =
|
||||||
once::DeprecationWarning
|
once::DeprecationWarning
|
||||||
once::PendingDeprecationWarning
|
once::PendingDeprecationWarning
|
||||||
|
@ -173,8 +173,7 @@
|
|||||||
"Don't treat strings as symbols in the calling position"
|
"Don't treat strings as symbols in the calling position"
|
||||||
(with [(pytest.raises TypeError)] ("setv" True 3)) ; A special form
|
(with [(pytest.raises TypeError)] ("setv" True 3)) ; A special form
|
||||||
(with [(pytest.raises TypeError)] ("abs" -2)) ; A function
|
(with [(pytest.raises TypeError)] ("abs" -2)) ; A function
|
||||||
(with [(pytest.raises TypeError)] ("when" 1 2)) ; A macro
|
(with [(pytest.raises TypeError)] ("when" 1 2))) ; A macro
|
||||||
None) ; Avoid https://github.com/hylang/hy/issues/1320
|
|
||||||
|
|
||||||
|
|
||||||
(defn test-for-loop []
|
(defn test-for-loop []
|
||||||
|
@ -194,7 +194,7 @@
|
|||||||
(assert (in (mangle "_;a|") s2))
|
(assert (in (mangle "_;a|") s2))
|
||||||
(assert (not (= s1 s2))))
|
(assert (not (= s1 s2))))
|
||||||
|
|
||||||
(defn test-defmacro-g! []
|
(defn test-defmacro/g! []
|
||||||
(import ast)
|
(import ast)
|
||||||
(import [astor.code-gen [to-source]])
|
(import [astor.code-gen [to-source]])
|
||||||
(import [hy.importer [import_buffer_to_ast]])
|
(import [hy.importer [import_buffer_to_ast]])
|
||||||
@ -213,8 +213,8 @@
|
|||||||
(setv _ast2 (import_buffer_to_ast macro1 "foo"))
|
(setv _ast2 (import_buffer_to_ast macro1 "foo"))
|
||||||
(setv s1 (to_source _ast1))
|
(setv s1 (to_source _ast1))
|
||||||
(setv s2 (to_source _ast2))
|
(setv s2 (to_source _ast2))
|
||||||
(assert (in "_;res|" s1))
|
(assert (in (mangle "_;res|") s1))
|
||||||
(assert (in "_;res|" s2))
|
(assert (in (mangle "_;res|") s2))
|
||||||
(assert (not (= s1 s2)))
|
(assert (not (= s1 s2)))
|
||||||
|
|
||||||
;; defmacro/g! didn't like numbers initially because they
|
;; defmacro/g! didn't like numbers initially because they
|
||||||
@ -242,8 +242,8 @@
|
|||||||
(setv _ast2 (import_buffer_to_ast macro1 "foo"))
|
(setv _ast2 (import_buffer_to_ast macro1 "foo"))
|
||||||
(setv s1 (to_source _ast1))
|
(setv s1 (to_source _ast1))
|
||||||
(setv s2 (to_source _ast2))
|
(setv s2 (to_source _ast2))
|
||||||
(assert (in "_;res|" s1))
|
(assert (in (mangle "_;res|") s1))
|
||||||
(assert (in "_;res|" s2))
|
(assert (in (mangle "_;res|") s2))
|
||||||
(assert (not (= s1 s2)))
|
(assert (not (= s1 s2)))
|
||||||
|
|
||||||
;; defmacro/g! didn't like numbers initially because they
|
;; defmacro/g! didn't like numbers initially because they
|
||||||
|
Loading…
x
Reference in New Issue
Block a user