Subject: | Using methods() for methods returning lists |
First of all thank you for your extreamly useful module. I've started to use it and it rocks.
I have one feature request though: it would be nice to allow doing methods()-like tests on methods which return lists. Currenly as quick hack I use following code:
sub methods_list {
return MyTest::Deep::MethodsList->new(@_);
}
package MyTest::Deep::MethodsList;
use base qw(Test::Deep::Methods);
use Test::Deep::Cmp;
sub descend
{
my $self = shift;
my $got = shift;
my $data = $self->data;
foreach my $method (@{$self->{methods}}) {
$data->{method} = $method;
my ($call, $exp_res) = @$method;
my ($name, @args) = @$call;
# until this point it was a copy any paste from
# Test::Deep::Methods
my $got_res = UNIVERSAL::can($got, $name) ? [ $got->$name(@args) ] : $Test::Deep::DNE;
# ^^^^ ^^^^^
next if Test::Deep::descend($got_res, $exp_res);
return 0;
}
return 1;
}