Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Test::More - equal_set

by brewer (Sexton)
on Jun 01, 2003 at 01:21 UTC ( [id://262157]=note: print w/replies, xml ) Need Help??


in reply to Re: Test::More - equal_set
in thread Test::More - equal_set

Thanks for that, edoc. That makes at least two of us who've interpreted the docs in a way that wasn't intended.

So, is the best way to proceed to sort my array before I do the test? This time I've already defined a way to order my hashrefs, but I can see that sometimes I might have to write a sorting function when I otherwise might not have needed to.

So now I'm thinking that it should be possible to write a standard comparison function, that works by examining the output of Data::Dumper to force a well defined (but otherwise meaningless) order on an array, so that it could make equal_set work as I thought the docs said it should.

Anyone see why this shouldn't work? Can anybody see any traps I might fall into, if i were to try to write this?

Kind regards,

brewer

Replies are listed 'Best First'.
Re: Re: Test::More - equal_set
by edoc (Chaplain) on Jun 01, 2003 at 02:23 UTC

    ok, knew there had to be something out there... Test::Deep using 'bag' (or set maybe, they look the same in the docs..) Unfortunately it doesn't seem to be a standard Perl module.

    #!/usr/bin/perl use Test::More qw(no_plan); use Test::Deep; my (@this,@that); @this = ( { fred => 1 }, { wilma => 1 } ); @that = ( { wilma => 1 }, { fred => 1 } ); cmp_deeply(\@this, bag(@that), 'cmp_deeply Deep Order Diff');

    cheers,

    J

      Thanks again, It looks like I don't get to write anything - cmp_bag() from Test::Deep gives me one more passed test.

      I'm really starting to see the value in writing tests - I may try writing the tests before the code for the next itch that I scratch.

      Kind regards,

      brewer

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found