Lesson 5-6 · Testing and Swapping — Knowledge ChecksAnswer key
Why are the five property checks stronger than comparing with one expected path?
An exact match passes only the path you wrote down, even if your expectation was wrong. The properties check validity directly, and any shortest path passes.
A planner returns [(0,1), (0,3)] for (0,0) to (0,3). Which property fails, and what does the FAIL line say?
(0,1) and (0,3) are two apart. The first step is fine, the last step is the destination, but the middle is a gap — and the step count (2 instead of 3) fails too.
Inside run_path_test, what does `path = planner(start, destination)` do when the harness was called with run_all_tests("BFS", compute_bfs_path)?
planner is a parameter holding a function. Calling it calls the function that was passed in. Hand it compute_manhattan_path instead and the same line tests Manhattan.
With planner objects, why does the harness keep its own record of what it blocked instead of reading planner.blocked?
The whole point of the swap is that the harness only uses the three shared methods. Reaching inside one planner would tie the harness to that planner.