2 ms·
Good example for sums: you can write a property that checks whether the sum of a list is the same before and after you randomly shuffle the elements. In practi
by tikhonj 1y ago
Good example for sums: you can write a property that checks whether the sum of a list is the same before and after you randomly shuffle the elements.
In practice sum is a sufficiently well-understood function that this property will only catch the edge-cases people know about up-front (integer overflow, floating point issues...). But for more complex cases, this kind of property will catch problems you didn't think about. And even if you decide that the bug is not important—sometimes we have no real choice but to live with these edgecases—at least you'll know about them explicitly and be able to document them.