|go ahead... be a heretic|
Re^2: Diagnostic messages in Test::Deepby KeighleHawk (Scribe)
|on Jul 21, 2015 at 13:31 UTC||Need Help??|
yes, the array can be populated in random order :-).
The data set is slightly different than your example. The keys for each hash within the test run are the same. They differ between runs/tests.
Test 1 sample.
I want these to evaluate as equal, and they do with code like this (similar to yours):
(the ternary operator is there because "no data returned" is also a valid/possible response).
The problem arises with Test 2 which has the following data:
The problem is the sorting key name has changed from 'key_1' to 'key_3' so my sort:
fails on the second data set. I could pass in the key names as variables, but was hoping to avoid that, especially since Test::Deep->bag() does exactly what I want.
The working Test::Deep code looks like this:
(different brackets on bag due to return type, I need to double check that...)
So Test::Deep->bag() works for me because it does magic I don't have to when deciding how to sort the second array.