As far as I can tell, cmp_deeply() does exactly what is_deeply() from Test::More does.
Actually, cmp_deeply does a lot more than is_deeply. At its most basic, it does the same thing, but at its most complex, it is soooooo much more. Here is an example from the docs:
This is the Test::More equvalent of doing:cmp_deeply( $obj, listmethods( name => "John", ["favourites", "food"] => ["Mapo tofu", "Gongbao chicken"] ) );
And it gets even better than that when you start looking at the superhash and subhash functions. I have used Test::Deep to validate a large tree-ish data-structure which is used to configure an application. This is all accomplished in a single test, here is a snippet of that code:is($obj->name, "John", '... our name is John); is_deeply([$obj->favourites("food")], ["Mapo tofu", "Gongbao chicken"] +);
To do this with Test::More would not only have been more code, but would really have required a lot of bookkeeping. With Test::Deep, it took me no time at all to but this together and it is far more flexible than any version I would have coded.my $report = do($tree_file) || die "failed to load the report tree\n=> + $@\n"; my $is_string = re('^(\s|\w|\d)*$'); my $is_module_name = re('^(([a-zA-Z0-9_]+)\:\:([a-zA-Z0-9_]+))+$'); cmp_deeply( $report, all( isa("ARRAY"), array_each( subhashof({ report_type => $is_string, report_module => $is_module_name, graphing_modules => isa("HASH"), question_groups => all( isa("ARRAY"), array_each( subhashof({ question_group => $is_string, report_module => $is_module_name, graphing_modules => isa("HASH"), questions => all( isa("ARRAY"), array_each(re('^\d+$') +) ) # all }) # subhashof ) # array_each ) # all }) # subhashof ) # array_each ) # all ); # cmp_deeply
In reply to Re^2: Should a CPAN module list Test:: modules as dependencies?
by stvn
in thread Should a CPAN module list Test:: modules as dependencies?
by grinder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |