Skip to content
14 changes: 8 additions & 6 deletions tests/test_shaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@


def parse(tmp_path: Path, content: str) -> list[Any]:
f = tmp_path / "test.scad"
f.write_text(content)
return getASTfromFile(str(f), process_includes=False) or []
test_file = tmp_path / "test.scad"
test_file.write_text(content)
return getASTfromFile(str(test_file), process_includes=False) or []


def make_pool(tmp_path: Path, content: str) -> dict[str, list]:
"""Parse content and return a list-valued pool dict.

This mirrors the private ``_add_to_pool`` behavior in ``openscad_packer.shaker``.
This mirrors the private ``_add_to_pool`` behavior in ``openscad_packer.packer``.
"""
nodes = parse(tmp_path, content)
pool: dict[str, list] = {}
Expand Down Expand Up @@ -98,8 +98,10 @@ def test_collects_chained_calls(self, tmp_path):
def test_does_not_collect_non_identifier_primary_calls(self, tmp_path):
# (function(x) x*2)(5) — PrimaryCall where left is a FunctionLiteral, not Identifier
names = collect_called_names(parse(tmp_path, "y = (function(x) x*2)(5);"))
# No Identifier on the left side, so nothing collected from the call itself
assert "function" not in names
# The callee is a FunctionLiteral (not an Identifier), so the call site
# contributes nothing. The body x*2 has no inner calls either, so the
# full result must be empty.
assert names == set()


class TestComputeReachable:
Expand Down
Loading