background image
<< use_ok() | diag() >>
<< use_ok() | diag() >>
is_deeply()
is_deeply()
For comparing complex data structures
Hashes, lists, hash of lists of hashes of lists of scalar references...
my %expect = ( this => 42, that => [qw(1 2 3)] );
my %got = some_function();
is_deeply( \%got, \%expect );
Will show you where the two structures start to diverge
not ok 1
# Failed test (- at line 2)
# Structures begin differing at:
# $got->{that}[2] = '3'
# $expected->{that}[2] = Does not exist
In CS this is really a "shallow comparison" and is() is "deep".
So the name is wrong because Schwern failed CS.
A stopgap measure
Currently doesn't handle circular structures (patches welcome)