The eight test files Q98 leaves open (plus test_bfs.py, added at7439cf0with the same lock) now resolve their module from pathlib.Path(__file__).resolve().parent instead of /root/.hermes/wizard-outputs/<lane>. tools/import_resolve_check.py --repo . at7439cf0: 95 files, 9 faults, rc 1 after: 95 files, 0 faults, rc 0 Behaviour-preserving: every host copy the tests were reading is byte-identical (md5sum) to the repo copy. Three absolute literals in spark/test_validator.py that the static leg does not grade (load_json(...) argument strings at pre-fix lines 12/16/25) are re-pointed too. ledger/test_scratch_manifest.py was red before any edit (str ROOT vs gen_manifest ROOT.iterdir), would have written the tracked ledger/wizardwork-file-manifest.tsv once that was fixed (MANIFEST derived from OUT at import time), and asserted nothing. It now re-points ROOT/OUT/MANIFEST, guards MANIFEST inside a tempfile.mkdtemp(), and asserts the exact manifest row. Non-vacuity: scratch/q98b/poison_probe.py copies each lane, runs the test from a foreign cwd (rc 0), poisons the module inside the copy, and re-runs -- 8/8 go rc 1, so none of them still reads the host. Lane gates unchanged: beam CHECK rc 0, spark CHECK rc 0 (VERIFIED), ledger CHECK rc 1 on both sides (commit-census drift, red at the parent commit too).
31 lines
814 B
Python
31 lines
814 B
Python
#!/usr/bin/env python3
|
|
"""Test file for array_intersection.py"""
|
|
import pathlib
|
|
import sys
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
|
from array_intersection import array_intersection
|
|
|
|
# Test cases
|
|
tests = [
|
|
([1, 2, 3, 4, 5], [3, 4, 5, 6, 7], [3, 4, 5]),
|
|
([1, 1, 2, 2], [2, 2, 3, 3], [2]),
|
|
([], [1, 2, 3], []),
|
|
([1, 2, 3], [], []),
|
|
(['a', 'b'], ['b', 'c'], ['b']),
|
|
]
|
|
|
|
all_passed = True
|
|
for arr1, arr2, expected in tests:
|
|
result = array_intersection(arr1, arr2)
|
|
if result != expected:
|
|
print(f'FAIL: {arr1} ∩ {arr2} = {result}, expected {expected}')
|
|
all_passed = False
|
|
else:
|
|
print(f'PASS: {arr1} ∩ {arr2} = {result}')
|
|
|
|
if all_passed:
|
|
print('All tests passed!')
|
|
sys.exit(0)
|
|
else:
|
|
print('Some tests failed!')
|
|
sys.exit(1) |