We've seen that pure functions have one important property—they return the same output for the same inputs. We've also seen that this property allows us to easily write example-based unit tests for pure functions. Moreover, we can write data-driven tests, allowing one test function to be reused with multiple inputs and outputs.
It turns out that we can do even better. Instead of, or in addition to, writing many lines of data-driven tests, we can take advantage of mathematical properties of pure functions. This technique is possible due to data generators that are enabled by functional programming. These tests are confusingly named property-based tests; you'll have to remember that the name comes from mathematical properties of pure functions, and not from properties implemented in classes or objects.
The following topics will be covered...