Dividing with ?LETSHRINK
As you use PropEr, you may find yourself stuck with generators creating huge data structures that take a long time to shrink and often don’t give very interesting results back. This often happens when some very low-probability failure is triggered, meaning that the framework had to generate a lot of data to find it, and has limited chances of shrinking things in a significant manner.
Whenever that happens, the ?LETSHRINK([Pattern, ...], [Generator, ...], Expression) is what you need. In practice, we use the generator like this:
| Erlang |
| ?LETSHRINK([A,B,C], [list(number()), list(number()), list(number())], |
| A ++ B ++ C) |
| Elixir |
| let_shrink([ |
| a <- list(number()), |
| b <- list(number()), |
| c <- list(number()) ... |
Get Property-Based Testing with PropEr, Erlang, and Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.