Front page | perl.qa |
Postings from February 2011
February 18, 2011 08:19
Message ID: firstname.lastname@example.org
I've stumbled on a bit of an odd case where I have constantly shifting data I need to test. Ordinarily I would use cmp_deeply from Test::Deep, but it's not quite structured enough. I need something similar to a Levenshtein edit distance for complex data structures.
Let's say I have an AoA like this:
[ 1, 'North Beach', 'au', 'city' ],
[ 2, 'North Beach', 'us', 'city' ],
[ 3, 'North Beach', 'us', 'city' ],
[ 4, 'North Beach Hotel', 'us', 'hotel' ],
[ 5, 'North Beach', 'us', 'city' ],
[ 6, 'North Beach', 'us', 'city' ],
It's OK if I get back that data structure, but the 2 and 4 records are swapped or maybe the 5 isn't present. However, for any contained array reference its exact data can't change. However, if those came back in the order of 6,5,4,3,2,1, the test should fail (thus, I can't use bag tests).
Does anyone know of any test modules which allows this?
Live and work overseas - http://overseas-exile.blogspot.com/
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://blogs.perl.org/users/ovid/
Twitter - http://twitter.com/OvidPerl/