[Omaha.pm] Test::More is_deeply()

Jay Hannah jhannah at omnihotels.com
Mon Apr 4 12:02:31 PDT 2005


Wow. is_deeply() is pretty slick.

>From the POD:

       is_deeply
             is_deeply( $this, $that, $test_name );

           Similar to is(), except that if $this and $that are
           hash or array references, it does a deep comparison
           walking each data structure to see if they are equiva-
           lent.  If the two structures are different, it will
           display the place where they start differing.

Over in my test script:

ok(@cros = $f->get_cro_resnos,                       "get_cro_resnos()");
my @should_be = qw(1004427653 1080835469 1004678589 1004763984);
is_deeply(\@cros, \@should_be,                       "   is what we expected");

I've intentionally screwed up the second element of the array, so is_deeply() magically tells me exactly where things went amiss:

ok 4 - get_cro_resnos()
not ok 5 -    is what we expected
#     Failed test (Inbound.t at line 14)
#     Structures begin differing at:
#          $got->[1] = '1090835469'
#     $expected->[1] = '1080835469'

Cool... 

j



More information about the Omaha-pm mailing list