Skip to content

Commit

Permalink
Test the avoidance of nested BoolOps
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Oct 1, 2023
1 parent 563a122 commit bc1d6f1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/compilers/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,16 @@ def test_literal_newlines():
assert s("#[[\rhello\rworld]]") == "hello\nworld"



def test_linear_boolop():
"""Operations like `(and 1 2 3)` should use only one `BoolOp`,
instead of an equivalent nested sequence of `BoolOp`s."""
for op in ("and", "or"):
node = can_compile(f'({op} 1 2.0 True "hi" 5)').body[0].value
assert len(node.values) == 5
assert all(isinstance(v, ast.Constant) for v in node.values)


def test_compile_error():
"""Ensure we get compile error in tricky cases"""
with pytest.raises(HyLanguageError) as excinfo:
Expand Down

0 comments on commit bc1d6f1

Please sign in to comment.