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. 

For example, if I compare:

 [{'hello'=>1}, {'world'=>1}] with  [{'hello'=>1}, {'earth'=>1}]

I would like the error message to look something like this:

The two arrays differed at element 1:
Got:  {'world'=>1}
Expected: {'earth'=>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ésilets, 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 

http://www.wikisym.org/ws2007/


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Perlunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perlunit-users

Reply via email to