Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Recursively traverse two data structures and test for match

by jdporter (Canon)
on May 23, 2005 at 12:07 UTC ( #459519=note: print w/replies, xml ) Need Help??


in reply to Re^3: Recursively traverse two data structures and test for match
in thread Recursively traverse two data structures and test for match

Nor should it. If a class defines the concept of equality for itself, any external equality-testing framework should respect that.

(btw - those interested should refer to FAQ How do I test the deep equality of two hash tables?)

  • Comment on Re^4: Recursively traverse two data structures and test for match

Replies are listed 'Best First'.
Re^5: Recursively traverse two data structures and test for match
by diotalevi (Canon) on May 23, 2005 at 15:18 UTC

    Sometimes it should, especially when testing the overloaded objects. It is the lack of any is_deeply test which is able to see through overloading that lead me to do something hokey and do cmp_eq( Data::Dump::Streamer::Dump($a), 'eq', Data::Dump::Streamer::Dump($b) ) tests instead.

    If an overloaded object wanted to pretend to be normal, it can use an utterly normal test and it'll get called as usual. Its the stuff like Test::More which should be able to have x-ray eyes to see through overloading.

      But I don't think that's a problem. You're doing an "out of band" test, you should have to jump through hoops. Whereas if, in the course of an application, I want to know, "are these two widgets equal?" I should depend on any overloaded equality ops to do the right thing, not to second-guess what the right thing should be.
        My t/whatever.t script using Test::More hardly counts as "in the normal course of an application." This is an environment where you really do want such things to happen, if that's what you intend. Testing environments are abnormal environments and this is a case where it matters that its treated as such.
      Maybe the appropriate action is to have a Test::More flag that specifies whether to use overloading or have xray vision.

      Maybe it should be $Test::More::XRAY_VISION? :-)


      • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
      • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2020-06-02 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (16 votes). Check out past polls.

    Notices?