Why do tests pass when the program is wrong?
Gary Bernhardt’s isolated tests and Andrej Karpathy’s neural network both deliver good news when the code is wrong.
A passing test is useful evidence. What specific mistake could still produce that result? These talks offer two surprisingly different answers.
When the mock shares your mistake
Imagine testing a reminder service. You tell a fake user repository which accounts have expired, then check whether the service emails them. The fake and the caller can agree perfectly even if both misunderstand the real repository. One integration check against real records tests a different promise.
if you don't stub the boundary correctly, your test will pass and your production system will be wrong.Replay 4:14–4:25 →
Running the real program is no guarantee either
Karpathy trains a small network and watches loss fall. But the training loop forgot to clear old gradients. On this easy problem the accumulated gradients took larger steps and appeared to work even better. Falling loss could never distinguish these implementations.
you may have lots of bugs in the code and uh your network might actually workReplay 2:13:44–2:13:51 →
Give the suspected error a chance to fail
For the mock, compare its output with a real query. For gradient accumulation, hand-calculate two small updates and compare the second one. Deliberately introduce the mistake: does the new check turn red?