Seems that starting in perl 5.17, keys() to obtain the keys in a hash is now truly randomized, which means that even within the same process, calling keys() twice on the same hash will result in a different key order.
In previous versions, this used to be just per-process, so you couldn't rely on the sort order from one process invocation to the next, but calling keys() twice on the same hash within the same process always returned consistent results.
This seems like a major challenge for testing applications. If my hash serializer produces different results every time, should my CPAN module have to deal with the daunting task of creating every single permutation of the keys() result that's used underneath, leading to an explosion of application-layer results to test against?
So far, in the test suite for
I've worked around this issue by running keys() once to determine the order, to test against the result generated by my second call by the application.
With perl 5.17, this is no longer possible.
What do people do to test against unpredictable core functions? Shouldn't the core provide some kind of API to figure out what the order is/was for testing?