3 ms·
Here are two scenarios: 1. Calling a function with the same input sometimes gives you a different output. 2. Calling a function with the same input will alway
by edgyswingset 10y ago
Here are two scenarios:
1. Calling a function with the same input sometimes gives you a different output.
2. Calling a function with the same input will always give you the same output.
Which do you think will more reliably give you correct outputs?
> I care about correct output
That's why we unit test. Well, and to protect the requirements of the system from the engineers who change the codebase. Referential Transparency (the concept described above) is a boon to this.