line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Chai::Core::Assertions::RespondTo; |
2
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
55
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
51
|
use Exporter qw/import/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
104
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/assert_respond_to/; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Scalar::Util qw/blessed/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
109
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
12
|
use Test::Chai::Util::Flag qw/flag/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
103
|
|
12
|
2
|
|
|
2
|
|
10
|
use Test::Chai::Util::Inspect qw/inspect/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
439
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub assert_respond_to { |
15
|
6
|
|
|
6
|
0
|
11
|
my ($self, $method, $msg) = @_; |
16
|
|
|
|
|
|
|
|
17
|
6
|
100
|
|
|
|
19
|
flag($self, 'message', $msg) if defined $msg; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
15
|
my $obj = flag($self, 'object'); |
21
|
|
|
|
|
|
|
my $context = |
22
|
2
|
|
|
|
|
13
|
blessed $obj ? \&{ref($obj).'::'.$method} : |
23
|
6
|
50
|
|
|
|
32
|
defined $obj ? \&{$obj.'::'.$method} : undef; |
|
4
|
100
|
|
|
|
51
|
|
24
|
|
|
|
|
|
|
|
25
|
6
|
|
66
|
|
|
48
|
return $self->assert( |
26
|
|
|
|
|
|
|
ref $context eq 'CODE' && defined &$context, |
27
|
|
|
|
|
|
|
'expected #{this} to respond to ' . inspect($method), |
28
|
|
|
|
|
|
|
'expected #{this} to not respond to ' . inspect($method) |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |