22/28
Part 5 of 6 · The worked exampleLearn and do
Test it on many random pages against the checker
5. Test. Hand-written cases catch the bugs you thought of. Random pages catch the rest, as long as you have a checker that knows a legal output when it sees one. That is obeys_cap.
The recipe:
- Draw a small random page from a seeded
random.Random, so a failure can be replayed. - Run the code on it.
- Check the output with
obeys_cap, and check that each row only holds titles from its input row. - Return the first page that fails, small enough to read.
Small alphabets find more bugs. With titles A to F and rows of up to 6, repeats inside a row and across rows come up on almost every page, which is where this problem's bugs live.
You run 300 random pages with m = 1 against the version that has no set for the row. How many fail?
Pick an answer above to see the rest