I guess it depends on whether I'm going to change the data afterwards. It also depends on why I'm comparing them.
Let's say I'm testing my date and time library. All objects are supposed to be immutable points in in time, numbers of hours, dates etc and
In this case since everything's immutable I don't care about identities, only values. So when I'm testing I'll have a bunch of expected values and a bunch of result values. I might reuse the same date object multiple times in the expected values even though the result values have multiple different occurrences of the same date value. I don't want that to be a problem.
I don't think there's a right anwer, it should be possible to compare in both ways.
Finally in relation to is_deeply, it considers
to be a pass. It also compares string-overloaded objects as strings and refuses to look inside and it completely ignores blessings. I think is_deeply should just keep doing exactly what it's doing. I and others know exactly what it's doing. Sometimes I use it, mostly I don't but changing its behaviour at this stage risks breaking tests and causing confusion.$a=[]; is_deeply($a, "$a");
In reply to Re: Do you consider these different or the same?
by fergal
in thread Do you consider these different or the same?
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |