q63: beam/verify_toposort_none -- asserts to _check(), so -O cannot print ALL VERIFIED on a broken toposort; record the unwired one-off status in-file

This commit is contained in:
spark committed 2026-10-24 18:26:47 +00:00
1 parent 89cda97d9b
commit 80a2e3687f
1 file changed
+15 -5
+15 -5
View File
@@ -1,20 +1,30 @@
# Q63 (2026-10-24): no committed gate invokes this file -- `git grep -F -n verify_toposort_none.py HEAD
# -- '*.py' '*.sh' CHECK` matches nothing outside this file -- so it is a one-off
# artifact, run by hand against its subject, not a standing check.
"""Verification artifact for toposort None-deps and one-shot materialisation."""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from toposort import topo_sort
def _check(cond, msg="check failed"):
"""Explicit failure path -- survives `python3 -O`, where `assert` is compiled away."""
if not cond:
raise SystemExit(f"FAIL: {msg}")
def gen():
yield "b"
# None dep cases
r = topo_sort({"a": None})
assert r.sorted == ["a"] and r.cycle is None, r
_check(r.sorted == ["a"] and r.cycle is None, r)
r = topo_sort({"a": ["z"], "z": None})
assert r.sorted == ["z", "a"] and r.cycle is None, r
_check(r.sorted == ["z", "a"] and r.cycle is None, r)
r = topo_sort({"a": None, "b": ["c"], "c": ["b"]})
assert r.sorted is None and set(r.cycle) == {"b", "c"}, r
_check(r.sorted is None and set(r.cycle) == {"b", "c"}, r)
# generator materialisation (must equal list case)
assert topo_sort({"a": gen()}).sorted == topo_sort({"a": ["b"]}).sorted == ["b", "a"]
_check(topo_sort({"a": gen()}).sorted == topo_sort({"a": ["b"]}).sorted == ["b", "a"])
# self-loop unchanged
assert topo_sort({"a": ["a"]}).cycle == ["a"]
_check(topo_sort({"a": ["a"]}).cycle == ["a"])
print("ALL VERIFIED")