Permalink
Browse files

make array_each fail, not die, on non-arrayref input

  • Loading branch information...
1 parent 0fa32a8 commit e855a0b1e2c96cec155a9d0cefa8480704a80498 @rjbs committed Apr 1, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/Test/Deep/ArrayEach.pm
View
@@ -4,6 +4,7 @@ use warnings;
package Test::Deep::ArrayEach;
use Test::Deep::Cmp;
+use Scalar::Util ();
sub init
{
@@ -19,9 +20,18 @@ sub descend
my $self = shift;
my $got = shift;
+ return unless Scalar::Util::reftype($got) eq 'ARRAY';
my $exp = [ ($self->{val}) x @$got ];
return Test::Deep::descend($got, $exp);
}
+sub renderExp
+{
+ my $self = shift;
+ my $exp = shift;
+
+ return '[ ' . $self->SUPER::renderExp($self->{val}) . ', ... ]';
+}
+
1;

0 comments on commit e855a0b

Please sign in to comment.