3 ms·
The (rhertorical) question the author was asking is how would a machine back out a reasonable set of test cases from the source code. The fact that this code b
by adrianratnapala 9y ago
The (rhertorical) question the author was asking is how would a machine back out a reasonable set of test cases from the source code. The fact that this code branches conditionally on the sign of the input is a hint that the test set should worry about sign.
Tests derived this way will still be useful if the implementation were changed to something that didn't branch.
I suspect though that we shouldn't get too stuck on the testing thing. The author only asked the question to introduce thinking about how to abstract expectations behviour out of concrete code. Test generation is only one of the uses he cites.