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

$a=[]; is_deeply($a, "$a");
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.