Subject: | array_each() carps being fed with a non-ref |
Here is a self-explanatory example:
$ perl -MTest::Deep -e 'cmp_deeply {a=>"foo"}, {a=>array_each(ignore())}'
Use of uninitialized value in string eq at /home/mvuets/perl5/lib/perl5/Test/Deep/ArrayEach.pm line 23.
not ok 1
# Failed test at -e line 1.
# Compared $data->{"a"}
# got : 'foo'
# expect : [ Test::Deep::Ignore=HASH(0x129cc88), ... ]
# Tests were run but no plan was declared and done_testing() was not seen.
Here is a patch:
--- a/ArrayEach.pm
+++ b/ArrayEach.pm
@@ -20,7 +20,7 @@
my $self = shift;
my $got = shift;
- return unless Scalar::Util::reftype($got) eq 'ARRAY';
+ return unless ref $got && Scalar::Util::reftype($got) eq 'ARRAY';
my $exp = [ ($self->{val}) x @$got ];
return Test::Deep::descend($got, $exp);