Choose Inputs for Walkthroughs

If you tried the preceding steps and still don't know what the bug is, you probably need to walk through the code by hand. In a sense, walking through the code is less than ideal. In a perfect world, you would prove to yourself that every section accomplishes its goal, that every variable sticks to its meaning, and that the proper value is returned or displayed, leaving no doubt that the function is correct for all inputs. Walking through the code introduces an element of uncertainty because no matter how many inputs you try, the bug might not be exposed by any of them.

Still, in many cases, the only way to unearth a bug is to walk through the code. To do this, you need to select inputs to the code. Except for short ...

Get Find the Bug A Book of Incorrect Programs now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.