[Perlunit-users] Comparing deeply nested data structures.
Status: Beta
Brought to you by:
mca1001
From: Desilets, A. <Ala...@nr...> - 2007-05-16 17:17:21
|
I am writing some PerlUnit tests, and I am testing a method that returns = a complex data structure (a reference to an array whose elements are = references to hashtables). I want to easily compare the output of that method to expected output, = and if the two differ, get a good diagnostic message that describes = exactly how the two differ.=20 For example, if I compare: [{'hello'=3D>1}, {'world'=3D>1}] with [{'hello'=3D>1}, {'earth'=3D>1}] I would like the error message to look something like this: The two arrays differed at element 1: Got: {'world'=3D>1} Expected: {'earth'=3D>1} The hashes had different keys Got Keys: ['world'] Expected Keys: ['earth'] Is there something in Perl that would allow me to do this? I stumbled across cmp_deeply(), but I can't figure out how to use it. = It's part of a testing framework different from PerlUnit, and I can't = seem to be able to use it without running it inside that other testing = framework (which I don't have time to learn). Thx. ---- Alain D=E9silets, National Research Council of Canada Chair, WikiSym 2007 2007 International Symposium on Wikis Wikis at Work in the World: Open, Organic, Participatory Media for the 21st Century=20 http://www.wikisym.org/ws2007/ |