Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You are asking the wrong questions. Instead, ask –
My answer to the first is that is_deeply's purpose is to make it easy to test complex observed values by comparing them with given expected values. My answer to the second, then, is that is_deeply should consider the observed and expected values to be equivalent if both have the same structure and subvalues, ignoring sharing. (Remember, I am talking semantics here, not implementation.) Why ignore sharing? Because it rarely matters in tests. By ignoring it we make the common case easier for testers, who frequently hand-roll expected values. This goes back to the purpose of is_deeply; convenience matters. As to your questions, then, here is how I answer. In the first case, $ar1 and $ar2 are equivalent. Both have the same structure and subvalues – [{},{}]. In the second case, they are not equivalent; [{a=>'foo'},{a=>'foo'}] differs from [{a=>'foo'},{}]. Cheers, Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder In reply to Re: Do you consider these different or the same?
by tmoertel
|
|