I'm a little surprised about the behavior of Test::More::is_deeply()

I have a deeply nested data-structure supposed to return contain scalar refs.

But is_deeply() digs into the refs and compares the scalar values.

I can understand why array- and hash-refs are dereferenced ...

Any elegant way to solve this? I also tried Test::Deep::cmp_deeply() but no success

will try Test::Differences now ...

use strict; use warnings; use Data::Dump qw/pp dd/; use Test::More; use Test::Deep; my ($pos1,$pos2)=("a","a"); diag \$pos1,", ",\$pos2; diag 0+\$pos1,", ",0+\$pos2; diag pp \$pos1,\$pos2; is_deeply( \$pos1, \$pos2,"is_deeply"); #should fail cmp_deeply( \$pos1, \$pos2,"cmp_deeply"); #should fail done_testing;

C:/Perl_524/bin\perl.exe -w d:/exp/pm_is_deeply.pl ok 1 - is_deeply ok 2 - cmp_deeply # SCALAR(0xd286e8), SCALAR(0xd28d48) # 13797096, 13798728 # (\"a", \"a") 1..2

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Test scalar refs (not values) in deeply nested structure by LanX

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.