line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Compare::Meta; |
2
|
100
|
|
|
100
|
|
1194
|
use strict; |
|
100
|
|
|
|
|
191
|
|
|
100
|
|
|
|
|
2590
|
|
3
|
100
|
|
|
100
|
|
487
|
use warnings; |
|
100
|
|
|
|
|
196
|
|
|
100
|
|
|
|
|
2453
|
|
4
|
|
|
|
|
|
|
|
5
|
100
|
|
|
100
|
|
504
|
use Test::Stream::Delta; |
|
100
|
|
|
|
|
191
|
|
|
100
|
|
|
|
|
1995
|
|
6
|
|
|
|
|
|
|
|
7
|
100
|
|
|
100
|
|
497
|
use Test::Stream::Compare; |
|
100
|
|
|
|
|
194
|
|
|
100
|
|
|
|
|
696
|
|
8
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
9
|
100
|
|
|
|
|
849
|
base => 'Test::Stream::Compare', |
10
|
|
|
|
|
|
|
accessors => [qw/items/], |
11
|
100
|
|
|
100
|
|
568
|
); |
|
100
|
|
|
|
|
206
|
|
12
|
|
|
|
|
|
|
|
13
|
100
|
|
|
100
|
|
544
|
use Carp qw/croak confess/; |
|
100
|
|
|
|
|
207
|
|
|
100
|
|
|
|
|
5288
|
|
14
|
100
|
|
|
100
|
|
516
|
use Scalar::Util qw/reftype blessed/; |
|
100
|
|
|
|
|
193
|
|
|
100
|
|
|
|
|
53430
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
409
|
|
|
409
|
0
|
596
|
my $self = shift; |
18
|
409
|
|
100
|
|
|
1955
|
$self->{+ITEMS} ||= []; |
19
|
409
|
|
|
|
|
1310
|
$self->SUPER::init(); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
1
|
13
|
sub name { '' } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub verify { |
25
|
5
|
|
|
5
|
1
|
10
|
my $self = shift; |
26
|
5
|
|
|
|
|
16
|
my %params = @_; |
27
|
5
|
100
|
|
|
|
33
|
return $params{exists} ? 1 : 0; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub add_prop { |
31
|
514
|
|
|
514
|
0
|
714
|
my $self = shift; |
32
|
514
|
|
|
|
|
826
|
my ($name, $check) = @_; |
33
|
|
|
|
|
|
|
|
34
|
514
|
100
|
|
|
|
1358
|
croak "prop name is required" |
35
|
|
|
|
|
|
|
unless defined $name; |
36
|
|
|
|
|
|
|
|
37
|
513
|
100
|
|
|
|
1125
|
croak "check is required" |
38
|
|
|
|
|
|
|
unless defined $check; |
39
|
|
|
|
|
|
|
|
40
|
512
|
|
|
|
|
1032
|
my $meth = "get_prop_$name"; |
41
|
512
|
100
|
|
|
|
1981
|
croak "'$name' is not a known property" |
42
|
|
|
|
|
|
|
unless $self->can($meth); |
43
|
|
|
|
|
|
|
|
44
|
511
|
|
|
|
|
685
|
push @{$self->{+ITEMS}} => [$meth, $check, $name]; |
|
511
|
|
|
|
|
2426
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub deltas { |
48
|
414
|
|
|
414
|
1
|
570
|
my $self = shift; |
49
|
414
|
|
|
|
|
1241
|
my %params = @_; |
50
|
414
|
|
|
|
|
801
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
51
|
|
|
|
|
|
|
|
52
|
414
|
|
|
|
|
517
|
my @deltas; |
53
|
414
|
|
|
|
|
680
|
my $items = $self->{+ITEMS}; |
54
|
|
|
|
|
|
|
|
55
|
414
|
|
|
|
|
859
|
for my $set (@$items) { |
56
|
533
|
|
|
|
|
1225
|
my ($meth, $check, $name) = @$set; |
57
|
|
|
|
|
|
|
|
58
|
533
|
|
|
|
|
1559
|
$check = $convert->($check); |
59
|
|
|
|
|
|
|
|
60
|
533
|
|
|
|
|
1585
|
my $val = $self->$meth($got); |
61
|
|
|
|
|
|
|
|
62
|
533
|
|
|
|
|
2457
|
push @deltas => $check->run( |
63
|
|
|
|
|
|
|
id => [META => $name], |
64
|
|
|
|
|
|
|
got => $val, |
65
|
|
|
|
|
|
|
convert => $convert, |
66
|
|
|
|
|
|
|
seen => $seen, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
414
|
|
|
|
|
1458
|
return @deltas; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
414
|
|
|
414
|
0
|
1388
|
sub get_prop_blessed { blessed($_[1]) } |
74
|
|
|
|
|
|
|
|
75
|
13
|
|
|
13
|
0
|
47
|
sub get_prop_reftype { reftype($_[1]) } |
76
|
|
|
|
|
|
|
|
77
|
6
|
|
|
6
|
0
|
15
|
sub get_prop_this { $_[1] } |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub get_prop_size { |
80
|
3
|
|
|
3
|
0
|
4
|
my $self = shift; |
81
|
3
|
|
|
|
|
6
|
my ($it) = @_; |
82
|
|
|
|
|
|
|
|
83
|
3
|
|
100
|
|
|
16
|
my $type = reftype($it) || ''; |
84
|
|
|
|
|
|
|
|
85
|
3
|
100
|
|
|
|
11
|
return scalar @$it if $type eq 'ARRAY'; |
86
|
2
|
100
|
|
|
|
8
|
return scalar keys %$it if $type eq 'HASH'; |
87
|
1
|
|
|
|
|
3
|
return undef; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |