Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Test scalar refs (not values) in deeply nested structure

by Corion (Patriarch)
on Jul 23, 2020 at 19:50 UTC ( [id://11119720]=note: print w/replies, xml ) Need Help??


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

The Test::More documentation says for is_deeply:

is_deeply() compares the dereferenced values of references, the references themselves (except for their type) are ignored.

... so I'm not sure what you expect.

If you want to compare the identity of the references too, you will need to write your own comparison tool, but I guess that a simple shallow comparison already is enough for that case.

Replies are listed 'Best First'.
Re^2: Test scalar refs (not values) in deeply nested structure
by LanX (Saint) on Jul 23, 2020 at 19:58 UTC
    unfortunately my data is far from being shallow.

    My pragmatic approach is to write a recursive diver which will replace the scalar values with the stringification of their refs.

    $$ref = "$ref"

    I'll feed this to is_deeply() then, seems to work so far.

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

      So you have a nested data structure, but you want only scalar refs to be compared for identity, while you want to compare everything else structurally?

      If that's not it, maybe show examples and counterexamples of what you want your comparison routine to do.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119720]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found