Re: [Perlunit-users] Comparing deeply nested data structures.
Status: Beta
Brought to you by:
mca1001
From: Desilets, A. <Ala...@nr...> - 2007-05-25 14:10:28
|
> Hi Alain, >=20 > Apologies for the belated response. Been in bed most of this=20 > week with evil lurgy and have been avoiding e-mail - and=20 > computers in general :-) Sorry to hear about that. Hope you are better now. >=20 > On 23 May 2007, at 21:06, Desilets, Alain wrote: >=20 > > I finally got round to trying assert_deep_equals().=20 > Unfortunately, I=20 > > don't get the kind of nice diagnostic message you mentioned in your=20 > > message of a week ago. Attached is a sample test program.=20 > When I run=20 > > it, all I get is the following error message: > [snip] >=20 > You're not getting the diagnostic because you gave your own =20 > description string for the failure. Leave it out and you'll get the =20 > diagnostics. OK, thx. I had assumed that assert_deep_equals() behaved like all other asserts in PerlUnit, i.e. the error message passed to it got prepended to whatever additional messages the assert might itself generate. I will look into the code for assert_deep_equals() and see if I can change it to behave that way (and submit the change to the PerlUnit team). I kind of like that behaviour, because it allows me to make my error messages more specific to what I am testing. As it turns out, I implemented my own version of something like assert_deep_equals(). Basically, it serializes the two structures using a PrettyPrinter that I found on the web, then does a string comparison between the two. >=20 > As an aside - you should be passing class names as 'Strings' nor =20 > BareWords. It's better style and will save you the no warnings/=20 > warnings.=20 Hum... I was sure I had tried that at some point (long time ago) and that it didn't work. But I'll try again, thx. |