|
You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site. 6.7. is_deeply( complex_structure, expected_complex structure, name);Compare two Perl data structures: Example 6-5. examples/intro/is_deeply.t #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 3;
my %expected = (
bugs => 3,
errors => 6,
failures => 8,
warnings => 1,
);
my %a = fetch_data_from_bug_tracking_system(0);
is_deeply( \%a, \%expected, "Query 0" );
my %b = fetch_data_from_bug_tracking_system(1);
is_deeply( \%b, \%expected, "Query 1" );
my %c = fetch_data_from_bug_tracking_system(2);
is_deeply( \%c, \%expected, "Query 2" );
sub fetch_data_from_bug_tracking_system {
my @sets = (
{ bugs => 3,
errors => 6,
failures => 8,
warnings => 1,
},
{ bugs => 3,
errors => 9,
failures => 8,
warnings => 1,
},
{ bogs => 3,
erors => 9,
failures => 8,
warnings => 1,
},
);
my $h = $sets[shift];
return %$h;
}
Example 6-6. examples/intro/is_deeply.out 1..3
ok 1 - Query 0
not ok 2 - Query 1
# Failed test 'Query 1'
# in is_deeply.t at line 19.
# Structures begin differing at:
# $got->{errors} = '9'
# $expected->{errors} = '6'
not ok 3 - Query 2
# Failed test 'Query 2'
# in is_deeply.t at line 22.
# Structures begin differing at:
# $got->{errors} = Does not exist
# $expected->{errors} = '6'
# Looks like you failed 2 tests of 3.
|