beam: verify toposort None-deps and one-shot materialisation

This commit is contained in:
beam committed 2026-10-24 17:41:49 +00:00
1 parent 969cf8a2ac
commit 23f5a4a8be
1 file changed
+20
+20
View File
@@ -0,0 +1,20 @@
"""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 gen():
yield "b"
# None dep cases
r = topo_sort({"a": None})
assert 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
r = topo_sort({"a": None, "b": ["c"], "c": ["b"]})
assert 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"]
# self-loop unchanged
assert topo_sort({"a": ["a"]}).cycle == ["a"]
print("ALL VERIFIED")