File Coverage

blib/lib/Test/Deep/Any.pm
Criterion Covered Total %
statement 37 37 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 8 8 100.0
pod 0 4 0.0
total 52 56 92.8


line stmt bran cond sub pod time code
1 4     4   27 use strict;
  4         7  
  4         178  
2 4     4   18 use warnings;
  4         77  
  4         316  
3              
4             package Test::Deep::Any 1.205;
5              
6 4     4   19 use Scalar::Util ();
  4         6  
  4         55  
7 4     4   809 use Test::Deep::Cmp;
  4         10  
  4         20  
8              
9             sub init
10             {
11 11     11 0 18 my $self = shift;
12              
13             my @list = map {
14 11         23 (Scalar::Util::blessed($_) && $_->isa('Test::Deep::Any'))
15 19 100 100     147 ? @{ $_->{val} }
  1         2  
16             : $_
17             } @_;
18              
19 11         184 $self->{val} = \@list;
20             }
21              
22             sub descend
23             {
24 9     9 0 21 my $self = shift;
25 9         12 my $got = shift;
26              
27 9         13 foreach my $cmp (@{$self->{val}})
  9         21  
28             {
29 14 100       46 return 1 if Test::Deep::eq_deeply_cache($got, $cmp);
30             }
31              
32 4         12 return 0;
33             }
34              
35             sub renderExp
36             {
37 4     4 0 5 my $self = shift;
38              
39 4         6 my @expect = map {; Test::Deep::wrap($_) } @{ $self->{val} };
  8         14  
  4         11  
40 4         23 my $things = join(", ", map {$_->renderExp} @expect);
  8         18  
41              
42 4         15 return "Any of ( $things )";
43             }
44              
45             sub diagnostics
46             {
47 4     4 0 8 my $self = shift;
48 4         30 my ($where, $last) = @_;
49              
50 4         18 my $got = $self->renderGot($last->{got});
51 4         11 my $exp = $self->renderExp;
52              
53 4         9 my $diag = <
54             Comparing $where with Any
55             got : $got
56             expected : $exp
57             EOM
58              
59 4         30 $diag =~ s/\n+$/\n/;
60 4         9 return $diag;
61             }
62              
63             4;
64              
65             __END__