line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mock::Signature::Dispatcher; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
102
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
3030
|
use Data::PatternCompare; |
|
3
|
|
|
|
|
79430
|
|
|
3
|
|
|
|
|
28
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
1
|
7
|
my $class = shift; |
10
|
3
|
|
|
|
|
6
|
my $method = shift; |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
|
|
55
|
my $params = { |
13
|
|
|
|
|
|
|
_method => $method, |
14
|
|
|
|
|
|
|
_list => [], |
15
|
|
|
|
|
|
|
_cmp => Data::PatternCompare->new, |
16
|
|
|
|
|
|
|
_default => undef, |
17
|
|
|
|
|
|
|
}; |
18
|
3
|
|
|
|
|
67
|
return bless($params, $class); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub add { |
22
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
23
|
4
|
|
|
|
|
7
|
my $meta = shift; |
24
|
4
|
|
|
|
|
15
|
my $list = $self->{'_list'}; |
25
|
4
|
|
|
|
|
10
|
my $cmp = $self->{'_cmp'}; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
17
|
@$list = sort { $cmp->compare_pattern($a->params, $b->params) } @$list, $meta; |
|
1
|
|
|
|
|
6
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub delete { |
31
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
32
|
1
|
|
|
|
|
2
|
my $meta = shift; |
33
|
1
|
|
|
|
|
2
|
my $list = $self->{'_list'}; |
34
|
1
|
|
|
|
|
3
|
my $cmp = $self->{'_cmp'}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
3
|
@$list = grep { !$cmp->eq_pattern($_->params, $meta->params) } @$list; |
|
2
|
|
|
|
|
62
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub compile { |
40
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
41
|
4
|
100
|
|
|
|
17
|
return if defined $self->{'_default'}; |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
7
|
my $list = $self->{'_list'}; |
44
|
3
|
|
|
|
|
5
|
my $cmp = $self->{'_cmp'}; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
33
|
|
|
14
|
$self->{'_default'} ||= do { |
47
|
3
|
|
|
3
|
|
928
|
no strict 'refs'; |
|
3
|
|
|
|
|
32
|
|
|
3
|
|
|
|
|
744
|
|
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
5
|
*{$self->{'_method'}}{'CODE'} |
|
3
|
|
|
|
|
20
|
|
50
|
|
|
|
|
|
|
}; |
51
|
3
|
|
|
|
|
6
|
my $default = $self->{'_default'}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $code = sub { |
54
|
7
|
|
|
7
|
|
741
|
my ($self, @params) = @_; |
55
|
|
|
|
|
|
|
|
56
|
7
|
|
|
|
|
15
|
for my $meta ( @$list ) { |
57
|
8
|
100
|
|
|
|
71
|
if ($cmp->pattern_match(\@params, $meta->params)) { |
58
|
5
|
|
|
|
|
304
|
my $cb = $meta->callback; |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
23
|
goto &$cb; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
103
|
goto &$default; |
65
|
3
|
|
|
|
|
24
|
}; |
66
|
|
|
|
|
|
|
|
67
|
3
|
|
|
3
|
|
17
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
191
|
|
68
|
3
|
|
|
3
|
|
15
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
409
|
|
69
|
3
|
|
|
|
|
7
|
*{$self->{'_method'}} = $code; |
|
3
|
|
|
|
|
22
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub DESTROY { |
73
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
74
|
1
|
|
|
|
|
3
|
my $method = $self->{'_method'}; |
75
|
|
|
|
|
|
|
|
76
|
3
|
|
|
3
|
|
15
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
82
|
|
77
|
3
|
|
|
3
|
|
13
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
184
|
|
78
|
1
|
|
|
|
|
21
|
*$method = $self->{'_default'}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
42; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |